Go to the documentation of this file.
34 #define RESTORE_PRED(sce, sfb) \
35 if (sce->ics.prediction_used[sfb]) {\
36 sce->ics.prediction_used[sfb] = 0;\
37 sce->band_type[sfb] = sce->band_alt[sfb];\
44 tmp.i = (
tmp.i + 0x00008000
U) & 0xFFFF0000U;
52 tmp.i = (
tmp.i + 0x00007FFF
U + (
tmp.i & 0x00010000
U >> 16)) & 0xFFFF0000
U;
67 const float a = 0.953125;
68 const float alpha = 0.90625;
69 const float k1 = ps->
k1;
70 const float r0 = ps->
r0, r1 = ps->
r1;
71 const float cor0 = ps->
cor0, cor1 = ps->
cor1;
72 const float var0 = ps->
var0, var1 = ps->
var1;
73 const float e0 = *coef - ps->
x_est;
74 const float e1 = e0 - k1 * r0;
125 for (sfb = 0; sfb < pmax; sfb++) {
126 for (k = sce->
ics.
swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
143 for (
i = 1;
i < 31;
i++) {
153 int start,
w, w2,
g,
i, count = 0;
158 const int pmax =
FFMIN(pmax0, pmax1);
170 float ener0 = 0.0f, ener1 = 0.0f, ener01 = 0.0f;
172 if (sfb < PRED_SFB_START || sfb > pmax || sum != 2) {
180 float coef0 = sce0->
pcoeffs[start+(
w+w2)*128+
i];
181 float coef1 = sce1->
pcoeffs[start+(
w+w2)*128+
i];
182 ener0 += coef0*coef0;
183 ener1 += coef1*coef1;
184 ener01 += (coef0 + coef1)*(coef0 + coef1);
188 ener0, ener1,
ener01, 1, -1);
190 ener0, ener1,
ener01, 1, +1);
209 int i, max_group_id_c, max_frame = 0;
210 float avg_frame = 0.0f;
217 for (
i = 1;
i < 31;
i++) {
235 int sfb,
i, count = 0, cost_coeffs = 0, cost_pred = 0;
237 float *O34 = &
s->scoefs[128*0], *P34 = &
s->scoefs[128*1];
238 float *SENT = &
s->scoefs[128*2], *S34 = &
s->scoefs[128*3];
239 float *QERR = &
s->scoefs[128*4];
250 for (
i = 1;
i < 31;
i++)
258 int cost1, cost2, cb_p;
261 const int cb_min = sce->
zeroes[sfb] ? 0 : 1;
264 const int num_coeffs = sce->
ics.
swb_offset[sfb + 1] - start_coef;
265 const FFPsyBand *band = &
s->psy.ch[
s->cur_channel].psy_bands[sfb];
273 s->abs_pow34(O34, &sce->
coeffs[start_coef], num_coeffs);
275 O34, num_coeffs, sce->
sf_idx[sfb],
277 cost_coeffs += cost1;
280 for (
i = 0;
i < num_coeffs;
i++)
282 s->abs_pow34(S34, SENT, num_coeffs);
292 for (
i = 0;
i < num_coeffs;
i++)
293 sce->
prcoeffs[start_coef +
i] += QERR[
i] != 0.0f ? (sce->
prcoeffs[start_coef +
i] - QERR[
i]) : 0.0f;
294 s->abs_pow34(P34, &sce->
prcoeffs[start_coef], num_coeffs);
300 P34, num_coeffs, sce->
sf_idx[sfb],
302 for (
i = 0;
i < num_coeffs;
i++)
303 dist_spec_err += (O34[
i] - P34[
i])*(O34[
i] - P34[
i]);
305 dist2 += dist_spec_err;
319 if (count && cost_coeffs < cost_pred) {
345 for (sfb = 0; sfb < pmax; sfb++)
static void update_pred_resets(SingleChannelElement *sce)
enum BandType band_alt[128]
alternative band type (used by encoder)
#define FF_PROFILE_AAC_MAIN
uint8_t zeroes[128]
band is not coded (used by encoder)
static void reset_all_predictors(PredictorState *ps)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
INTFLOAT pcoeffs[1024]
coefficients for IMDCT, pristine
int num_swb
number of scalefactor window bands
static void predict(PredictorState *ps, float *coef, float *rcoef, int set)
uint8_t prediction_used[41]
IndividualChannelStream ics
int predictor_reset_count[31]
used by encoder to count prediction resets
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
static float flt16_trunc(float pf)
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
void ff_aac_apply_main_pred(AACEncContext *s, SingleChannelElement *sce)
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
Individual Channel Stream.
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
static void reset_predict_state(PredictorState *ps)
single band psychoacoustic information
PredictorState predictor_state[MAX_PREDICTORS]
int sf_idx[128]
scalefactor indices (used by encoder)
const uint8_t ff_aac_pred_sfb_max[]
SingleChannelElement ch[2]
void ff_aac_adjust_common_pred(AACEncContext *s, ChannelElement *cpe)
static int update_counters(IndividualChannelStream *ics, int inc)
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
AAC_FLOAT prcoeffs[1024]
Main prediction coefs (used by encoder)
#define quantize_and_encode_band_cost( s, pb, in, quant, scaled, size, scale_idx, cb, lambda, uplim, bits, energy, rtz)
static float flt16_round(float pf)
Single Channel Element - used for both SCE and LFE elements.
#define i(width, name, range_min, range_max)
static int find_min_book(float maxval, int sf)
channel element - generic struct for SCE/CPE/CCE/LFE
static double erf(double z)
erf function Algorithm taken from the Boost project, source: http://www.boost.org/doc/libs/1_46_1/boo...
@ RESERVED_BT
Band types following are encoded differently from others.
struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe, int start, int w, int g, float ener0, float ener1, float ener01, int use_pcoeffs, int phase)
enum WindowSequence window_sequence[2]
void ff_aac_encode_main_pred(AACEncContext *s, SingleChannelElement *sce)
Encoder predictors data.
static float flt16_even(float pf)
static float find_max_val(int group_len, int swb_size, const float *scaled)
static const int16_t alpha[]
void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
static void reset_predictor_group(SingleChannelElement *sce, int group_num)
uint8_t max_sfb
number of scalefactor bands per group
enum BandType band_type[128]
band types
int predictor_reset_group
#define RESTORE_PRED(sce, sfb)
#define PRED_RESET_FRAME_MIN
int predictor_initialized