42 int i, w,
filt, coef_len, coef_compress = 0;
53 for (filt = 0; filt < tns->
n_filt[i]; filt++) {
56 if (tns->
order[i][filt]) {
59 coef_len = coef_res + 3 - coef_compress;
60 for (w = 0; w < tns->
order[i][
filt]; w++) {
75 const double iqfac_p = ((1 << (TNS_Q_BITS-1)) - 0.5)/(
M_PI/2.0);
76 const double iqfac_m = ((1 << (TNS_Q_BITS-1)) + 0.5)/(
M_PI/2.0);
77 for (i = 0; i < order; i++) {
78 idx[i] = ceilf(asin(coef[i])*((coef[i] >= 0) ? iqfac_p : iqfac_m));
79 u_coef = (idx[i])&(~(~0<<TNS_Q_BITS));
80 lpc[i] = quant_arr[u_coef];
89 int w,
filt,
m, i, top, order, bottom,
start,
end,
size, inc;
95 for (filt = 0; filt < tns->
n_filt[w]; filt++) {
107 if ((size = end - start) <= 0)
118 for (m = 0; m <
size; m++, start += inc)
119 for (i = 1; i <=
FFMIN(m, order); i++)
134 int sfb_end = av_clip(sce->
ics.
num_swb, 0, mmm);
137 float e_ratio = 0.0f, threshold = 0.0f, spread = 0.0f, en[2] = {0.0, 0.0f};
143 if (w*16+g < sfb_start || w*16+g > sfb_end)
147 if ((w+w2)*16+g > sfb_start + ((sfb_end - sfb_start)/2))
156 if (coef_len <= 0 || (sfb_end - sfb_start) <= 0)
159 e_ratio = en[0]/en[1];
163 coef_len, order, coefs);
170 for (g = 0; g < tns->
n_filt[w]; g++) {
171 tns->
length[w][
g] = sfb_end - sfb_start;
179 for (g = 0; g < tns->
n_filt[w]; g++) {
181 tns->
order[w][
g] = !g ? order/2 : order - tns->
order[w][g-1];
182 tns->
length[w][
g] = !g ? (sfb_end - sfb_start)/2 : \
183 (sfb_end - sfb_start) - tns->
length[w][g-1];
static const uint8_t *const tns_min_sfb[2]
#define TNS_SPREAD_THRESHOLD
int coef_idx[8][4][TNS_MAX_ORDER]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
float pcoeffs[1024]
coefficients for IMDCT, pristine
FFPsyBand psy_bands[PSY_MAX_BANDS]
channel bands information
void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce)
Encode TNS data.
#define TNS_GAIN_THRESHOLD_LOW
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
LPCContext lpc
used by TNS
int samplerate_index
MPEG-4 samplerate index.
static av_cold int end(AVCodecContext *avctx)
single band psychoacoustic information
int profile
copied from avctx
float coeffs[1024]
coefficients for IMDCT, maybe processed
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce)
void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce)
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
enum WindowSequence window_sequence[2]
static int AAC_RENAME() compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize)
Levinson-Durbin recursion.
static const INTFLOAT *const tns_tmp2_map[4]
#define TNS_GAIN_THRESHOLD_HIGH
#define FF_PROFILE_AAC_LOW
IndividualChannelStream ics
double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len, int order, double *ref)
static const int8_t filt[NUMTAPS]
INTFLOAT coef[8][4][TNS_MAX_ORDER]
Single Channel Element - used for both SCE and LFE elements.
Individual Channel Stream.
FFPsyChannel * ch
single channel information
AAC encoder temporal noise shaping.
static void quantize_coefs(double *coef, int *idx, float *lpc, int order)