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++) {
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);
191 erf = ph_err1.
error < ph_err2.
error ? &ph_err1 : &ph_err2;
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;
275 O34, num_coeffs, sce->
sf_idx[sfb],
277 cost_coeffs += cost1;
280 for (i = 0; i < num_coeffs; i++)
281 SENT[i] = sce->
coeffs[start_coef + i] - sce->
prcoeffs[start_coef + i];
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;
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;
307 if (dist2 <= dist1 && cb_p <= cb_n) {
319 if (count && cost_coeffs < cost_pred) {
345 for (sfb = 0; sfb < pmax; sfb++)
int predictor_initialized
Band types following are encoded differently from others.
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
#define PRED_RESET_FRAME_MIN
static void abs_pow34_v(float *out, const float *in, const int size)
static void reset_predict_state(PredictorState *ps)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static double erf(double z)
erf function Algorithm taken from the Boost project, source: http://www.boost.org/doc/libs/1_46_1/boo...
FFPsyBand psy_bands[PSY_MAX_BANDS]
channel bands information
static float flt16_trunc(float pf)
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
#define FF_PROFILE_AAC_MAIN
static void predict(PredictorState *ps, float *coef, float *rcoef, int set)
Spectral data are scaled white noise not coded in the bitstream.
#define quantize_and_encode_band_cost(s, pb, in, quant, scaled, size, scale_idx, cb, lambda, uplim, bits, energy, rtz)
AAC_FLOAT prcoeffs[1024]
Main prediction coefs (used by encoder)
INTFLOAT pcoeffs[1024]
coefficients for IMDCT, pristine
static float flt16_even(float pf)
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
static float flt16_round(float pf)
SingleChannelElement ch[2]
int samplerate_index
MPEG-4 samplerate index.
static void reset_all_predictors(PredictorState *ps)
AAC encoder main-type prediction.
void ff_aac_encode_main_pred(AACEncContext *s, SingleChannelElement *sce)
Encoder predictors data.
single band psychoacoustic information
int profile
copied from avctx
#define RESTORE_PRED(sce, sfb)
static double alpha(void *priv, double x, double y)
PredictorState predictor_state[MAX_PREDICTORS]
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
enum BandType band_alt[128]
alternative band type (used by encoder)
enum WindowSequence window_sequence[2]
int predictor_reset_group
void ff_aac_adjust_common_pred(AACEncContext *s, ChannelElement *cpe)
int cur_channel
current channel for coder context
void ff_aac_apply_main_pred(AACEncContext *s, SingleChannelElement *sce)
AAC encoder Intensity Stereo.
static int find_min_book(float maxval, int sf)
static int update_counters(IndividualChannelStream *ics, int inc)
static void reset_predictor_group(SingleChannelElement *sce, int group_num)
IndividualChannelStream ics
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
uint8_t zeroes[128]
band is not coded (used by encoder)
int sf_idx[128]
scalefactor indices (used by encoder)
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
int predictor_reset_count[31]
used by encoder to count prediction resets
Scalefactor data are intensity stereo positions (out of phase).
const uint8_t ff_aac_pred_sfb_max[]
uint8_t prediction_used[41]
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)
Single Channel Element - used for both SCE and LFE elements.
Individual Channel Stream.
channel element - generic struct for SCE/CPE/CCE/LFE
FFPsyChannel * ch
single channel information
static void update_pred_resets(SingleChannelElement *sce)
enum BandType band_type[128]
band types
static float find_max_val(int group_len, int swb_size, const float *scaled)
float scoefs[1024]
scaled coefficients