55 int i, ch,
tag, chans, cur_channel, start_ch = 0;
58 for (i = 0; i < s->
chan_map[0]; i++) {
62 for (ch = 0; ch < chans; ch++) {
64 cur_channel = start_ch + ch;
77 int i, j, lag, max_corr = 0;
79 for (i = 0; i < 2048; i++) {
80 float corr,
s0 = 0.0f,
s1 = 0.0f;
82 for (j = start; j < 2048; j++) {
83 const int idx = j - i + 1024;
84 s0 +=
new[j]*buf[idx];
85 s1 += buf[idx]*buf[idx];
87 corr =
s1 > 0.0f ? s0/sqrt(
s1) : 0.0f;
88 if (corr > max_corr) {
91 max_ratio = corr/(2048-
start);
94 ltp->
lag =
FFMAX(av_clip_uintp2(lag, 11), 0);
101 int i, samples_num = 2048;
105 }
else if (ltp->
lag < 1024) {
106 samples_num = ltp->
lag + 1024;
108 for (i = 0; i < samples_num; i++)
109 buf[i] = ltp->
coef*buf[i + 2048 - ltp->
lag];
110 memset(&buf[i], 0, (2048 - i)*
sizeof(
float));
147 }
else if (sum == 2) {
164 float *C34 = &s->
scoefs[128*0], *PCD = &s->
scoefs[128*1];
165 float *PCD34 = &s->
scoefs[128*2];
184 if (w*16+g > max_ltp) {
189 int bits_tmp1, bits_tmp2;
192 PCD[i] = sce->
coeffs[start+(w+w2)*128+i] - sce->
lcoeffs[start+(w+w2)*128+i];
208 sce->
coeffs[start+(w+w2)*128+i] -= sce->
lcoeffs[start+(w+w2)*128+i];
210 saved_bits += bits1 -
bits2;
228 sce->
coeffs[start+(w+w2)*128+i] += sce->
lcoeffs[start+(w+w2)*128+i];
AAC encoder long term prediction extension.
void ff_aac_encode_ltp_info(AACEncContext *s, SingleChannelElement *sce, int common_window)
Encode LTP data.
void ff_aac_ltp_insert_new_frame(AACEncContext *s)
static void abs_pow34_v(float *out, const float *in, const int size)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
FFPsyBand psy_bands[PSY_MAX_BANDS]
channel bands information
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
SingleChannelElement ch[2]
const uint8_t * chan_map
channel configuration map
#define FF_PROFILE_AAC_LTP
static const uint8_t bits2[81]
single band psychoacoustic information
int profile
copied from avctx
float * planar_samples[8]
saved preprocessed input
void ff_aac_update_ltp(AACEncContext *s, SingleChannelElement *sce)
Process LTP parameters.
static void generate_samples(float *buf, LongTermPrediction *ltp)
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
INTFLOAT ret_buf[2048]
PCM output buffer.
enum WindowSequence window_sequence[2]
INTFLOAT ltp_state[3072]
time signal for LTP
int cur_channel
current channel for coder context
static const INTFLOAT ltp_coef[8]
static int quant_array_idx(const float val, const float *arr, const int num)
IndividualChannelStream ics
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
int sf_idx[128]
scalefactor indices (used by encoder)
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
Single Channel Element - used for both SCE and LFE elements.
ChannelElement * cpe
channel elements
Individual Channel Stream.
channel element - generic struct for SCE/CPE/CCE/LFE
AAC_FLOAT lcoeffs[1024]
MDCT of LTP coefficients (used by encoder)
FFPsyChannel * ch
single channel information
enum BandType band_type[128]
band types
static void get_lag(float *buf, const float *new, LongTermPrediction *ltp)
void ff_aac_adjust_common_ltp(AACEncContext *s, ChannelElement *cpe)
void ff_aac_search_for_ltp(AACEncContext *s, SingleChannelElement *sce, int common_window)
Mark LTP sfb's.
static float quantize_band_cost(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy, int rtz)
int8_t used[MAX_LTP_LONG_SFB]
float scoefs[1024]
scaled coefficients
static const uint8_t bits1[81]