43 #define numQMFSlots 32 //numTimeSlots * RATE 51 10, 20, 34, 10, 20, 34,
80 #define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ 93 static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ 94 int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ 96 int b, num = ps->nr_ ## PAR ## _par; \ 97 VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \ 99 int e_prev = e ? e - 1 : ps->num_env_old - 1; \ 100 e_prev = FFMAX(e_prev, 0); \ 101 for (b = 0; b < num; b++) { \ 102 int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ 103 if (MASK) val &= MASK; \ 110 for (b = 0; b < num; b++) { \ 111 val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ 112 if (MASK) val &= MASK; \ 120 av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \ 137 if (ps->enable_ipdopd) {
138 for (e = 0; e < ps->num_env; e++) {
169 if (ps->enable_iid) {
177 ps->iid_quant = iid_mode > 2;
181 if (ps->enable_icc) {
183 if (ps->icc_mode > 5) {
194 ps->num_env_old = ps->num_env;
197 ps->border_position[0] = -1;
198 if (ps->frame_class) {
199 for (e = 1; e <= ps->num_env; e++) {
200 ps->border_position[e] =
get_bits(gb, 5);
201 if (ps->border_position[e] < ps->border_position[e-1]) {
207 for (e = 1; e <= ps->num_env; e++)
210 if (ps->enable_iid) {
211 for (e = 0; e < ps->num_env; e++) {
213 if (read_iid_data(avctx, gb, ps, ps->iid_par,
huff_iid[2*dt+ps->iid_quant], e, dt))
217 memset(ps->iid_par, 0,
sizeof(ps->iid_par));
220 for (e = 0; e < ps->num_env; e++) {
226 memset(ps->icc_par, 0,
sizeof(ps->icc_par));
228 if (ps->enable_ext) {
235 int ps_extension_id =
get_bits(gb, 2);
248 if (!ps->num_env || ps->border_position[ps->num_env] <
numQMFSlots - 1) {
250 int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
252 if (source >= 0 && source != ps->num_env) {
253 if (ps->enable_iid) {
254 memcpy(ps->iid_par+ps->num_env, ps->iid_par+source,
sizeof(ps->iid_par[0]));
256 if (ps->enable_icc) {
257 memcpy(ps->icc_par+ps->num_env, ps->icc_par+source,
sizeof(ps->icc_par[0]));
259 if (ps->enable_ipdopd) {
260 memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source,
sizeof(ps->ipd_par[0]));
261 memcpy(ps->opd_par+ps->num_env, ps->opd_par+source,
sizeof(ps->opd_par[0]));
265 for (b = 0; b < ps->nr_iid_par; b++) {
266 if (
FFABS(ps->iid_par[ps->num_env][b]) > 7 + 8 * ps->iid_quant) {
273 for (b = 0; b < ps->nr_iid_par; b++) {
274 if (ps->icc_par[ps->num_env][b] > 7
U) {
281 ps->border_position[ps->num_env] =
numQMFSlots - 1;
285 ps->is34bands_old = ps->is34bands;
286 if (!
PS_BASELINE && (ps->enable_iid || ps->enable_icc))
287 ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
288 (ps->enable_icc && ps->nr_icc_par == 34);
291 if (!ps->enable_ipdopd) {
292 memset(ps->ipd_par, 0,
sizeof(ps->ipd_par));
293 memset(ps->opd_par, 0,
sizeof(ps->opd_par));
300 if (bits_consumed <= bits_left) {
302 return bits_consumed;
304 av_log(avctx,
AV_LOG_ERROR,
"Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
308 memset(ps->iid_par, 0,
sizeof(ps->iid_par));
309 memset(ps->icc_par, 0,
sizeof(ps->icc_par));
310 memset(ps->ipd_par, 0,
sizeof(ps->ipd_par));
311 memset(ps->opd_par, 0,
sizeof(ps->opd_par));
320 for (i = 0; i <
len; i++,
in++) {
325 for (j = 0; j < 6; j += 2) {
331 re_op = (re_op + 0x40000000) >> 31;
332 im_op = (im_op + 0x40000000) >> 31;
350 for (i = 0; i <
len; i++,
in++) {
361 out[4][i][1] = temp[2][1] + temp[5][1];
362 out[5][i][0] = temp[3][0] + temp[4][0];
363 out[5][i][1] = temp[3][1] + temp[4][1];
373 for (i = 0; i <
len; i++,
in++) {
383 for (i = 0; i < 5; i++) {
384 for (j = 0; j < 38; j++) {
385 in[i][j+6][0] = L[0][j][i];
386 in[i][j+6][1] = L[1][j][i];
403 for (i = 0; i < 5; i++) {
404 memcpy(in[i], in[i]+32, 6 *
sizeof(in[i][0]));
413 for (n = 0; n <
len; n++) {
414 memset(out[0][n], 0, 5*
sizeof(out[0][n][0]));
415 memset(out[1][n], 0, 5*
sizeof(out[1][n][0]));
416 for (i = 0; i < 12; i++) {
417 out[0][
n][0] += in[ i][
n][0];
418 out[1][
n][0] += in[ i][
n][1];
420 for (i = 0; i < 8; i++) {
421 out[0][
n][1] += in[12+i][
n][0];
422 out[1][
n][1] += in[12+i][
n][1];
424 for (i = 0; i < 4; i++) {
425 out[0][
n][2] += in[20+i][
n][0];
426 out[1][
n][2] += in[20+i][
n][1];
427 out[0][
n][3] += in[24+i][
n][0];
428 out[1][
n][3] += in[24+i][
n][1];
429 out[0][
n][4] += in[28+i][
n][0];
430 out[1][
n][4] += in[28+i][
n][1];
435 for (n = 0; n <
len; n++) {
436 out[0][
n][0] = in[0][
n][0] + in[1][
n][0] + in[2][
n][0] +
437 in[3][
n][0] + in[4][
n][0] + in[5][
n][0];
438 out[1][
n][0] = in[0][
n][1] + in[1][
n][1] + in[2][
n][1] +
439 in[3][
n][1] + in[4][
n][1] + in[5][
n][1];
440 out[0][
n][1] = in[6][
n][0] + in[7][
n][0];
441 out[1][
n][1] = in[6][
n][1] + in[7][
n][1];
442 out[0][
n][2] = in[8][
n][0] + in[9][
n][0];
443 out[1][
n][2] = in[8][
n][1] + in[9][
n][1];
450 #define DECAY_SLOPE Q30(0.05f) 473 for (; b >= 0; b--) {
474 par_mapped[2*b+1] = par_mapped[2*
b] = par[
b];
480 par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3;
481 par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3;
482 par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3;
483 par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3;
484 par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2;
485 par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2;
486 par_mapped[ 6] = par[10];
487 par_mapped[ 7] = par[11];
488 par_mapped[ 8] = ( par[12] + par[13]) / 2;
489 par_mapped[ 9] = ( par[14] + par[15]) / 2;
490 par_mapped[10] = par[16];
492 par_mapped[11] = par[17];
493 par_mapped[12] = par[18];
494 par_mapped[13] = par[19];
495 par_mapped[14] = ( par[20] + par[21]) / 2;
496 par_mapped[15] = ( par[22] + par[23]) / 2;
497 par_mapped[16] = ( par[24] + par[25]) / 2;
498 par_mapped[17] = ( par[26] + par[27]) / 2;
499 par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4;
500 par_mapped[19] = ( par[32] + par[33]) / 2;
507 par[ 0] = (
int)(((int64_t)(par[ 0] + (
unsigned)(par[ 1]>>1)) * 1431655765 + \
509 par[ 1] = (
int)(((int64_t)((par[ 1]>>1) + (
unsigned)par[ 2]) * 1431655765 + \
511 par[ 2] = (
int)(((int64_t)(par[ 3] + (unsigned)(par[ 4]>>1)) * 1431655765 + \
513 par[ 3] = (
int)(((int64_t)((par[ 4]>>1) + (
unsigned)par[ 5]) * 1431655765 + \
516 par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
517 par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
518 par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
519 par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
536 par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2));
538 par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
546 par_mapped[33] = par[9];
547 par_mapped[32] = par[9];
548 par_mapped[31] = par[9];
549 par_mapped[30] = par[9];
550 par_mapped[29] = par[9];
551 par_mapped[28] = par[9];
552 par_mapped[27] = par[8];
553 par_mapped[26] = par[8];
554 par_mapped[25] = par[8];
555 par_mapped[24] = par[8];
556 par_mapped[23] = par[7];
557 par_mapped[22] = par[7];
558 par_mapped[21] = par[7];
559 par_mapped[20] = par[7];
560 par_mapped[19] = par[6];
561 par_mapped[18] = par[6];
562 par_mapped[17] = par[5];
563 par_mapped[16] = par[5];
567 par_mapped[15] = par[4];
568 par_mapped[14] = par[4];
569 par_mapped[13] = par[4];
570 par_mapped[12] = par[4];
571 par_mapped[11] = par[3];
572 par_mapped[10] = par[3];
573 par_mapped[ 9] = par[2];
574 par_mapped[ 8] = par[2];
575 par_mapped[ 7] = par[2];
576 par_mapped[ 6] = par[2];
577 par_mapped[ 5] = par[1];
578 par_mapped[ 4] = par[1];
579 par_mapped[ 3] = par[1];
580 par_mapped[ 2] = par[0];
581 par_mapped[ 1] = par[0];
582 par_mapped[ 0] = par[0];
588 par_mapped[33] = par[19];
589 par_mapped[32] = par[19];
590 par_mapped[31] = par[18];
591 par_mapped[30] = par[18];
592 par_mapped[29] = par[18];
593 par_mapped[28] = par[18];
594 par_mapped[27] = par[17];
595 par_mapped[26] = par[17];
596 par_mapped[25] = par[16];
597 par_mapped[24] = par[16];
598 par_mapped[23] = par[15];
599 par_mapped[22] = par[15];
600 par_mapped[21] = par[14];
601 par_mapped[20] = par[14];
602 par_mapped[19] = par[13];
603 par_mapped[18] = par[12];
604 par_mapped[17] = par[11];
606 par_mapped[16] = par[10];
607 par_mapped[15] = par[ 9];
608 par_mapped[14] = par[ 9];
609 par_mapped[13] = par[ 8];
610 par_mapped[12] = par[ 8];
611 par_mapped[11] = par[ 7];
612 par_mapped[10] = par[ 6];
613 par_mapped[ 9] = par[ 5];
614 par_mapped[ 8] = par[ 5];
615 par_mapped[ 7] = par[ 4];
616 par_mapped[ 6] = par[ 4];
617 par_mapped[ 5] = par[ 3];
618 par_mapped[ 4] = (par[ 2] + par[ 3]) / 2;
619 par_mapped[ 3] = par[ 2];
620 par_mapped[ 2] = par[ 1];
621 par_mapped[ 1] = (par[ 0] + par[ 1]) / 2;
622 par_mapped[ 0] = par[ 0];
672 const float transient_impact = 1.5f;
673 const float a_smooth = 0.25f;
678 const INTFLOAT peak_decay_factor =
Q31(0.76592833836465f);
680 memset(power, 0, 34 *
sizeof(*power));
690 for (k = 0; k < NR_BANDS[is34]; k++) {
697 for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
698 for (n = n0; n < nL; n++) {
700 decayed_peak = (
int)(((int64_t)peak_decay_factor * \
701 peak_decay_nrg[i] + 0x40000000) >> 31);
702 peak_decay_nrg[i] =
FFMAX(decayed_peak, power[i][n]);
703 power_smooth[i] += (power[i][
n] + 2LL - power_smooth[i]) >> 2;
704 peak_decay_diff_smooth[i] += (peak_decay_nrg[i] + 2LL - power[i][
n] - \
705 peak_decay_diff_smooth[i]) >> 2;
707 if (peak_decay_diff_smooth[i]) {
708 transient_gain[i][
n] =
FFMIN(power_smooth[i]*43691LL / peak_decay_diff_smooth[i], 1<<16);
710 transient_gain[i][
n] = 1 << 16;
714 for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
715 for (n = n0; n < nL; n++) {
716 float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
718 peak_decay_nrg[i] =
FFMAX(decayed_peak, power[i][n]);
719 power_smooth[i] += a_smooth * (power[i][
n] - power_smooth[i]);
720 peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][
n] - peak_decay_diff_smooth[i]);
721 denom = transient_impact * peak_decay_diff_smooth[i];
722 transient_gain[i][
n] = (denom > power_smooth[i]) ?
723 power_smooth[i] / denom : 1.0f;
736 for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
741 if (k - DECAY_CUTOFF[is34] <= 0) {
742 g_decay_slope = 1 << 30;
744 else if (k - DECAY_CUTOFF[is34] >= 20) {
748 g_decay_slope = (1 << 30) -
DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
751 float g_decay_slope = 1.f -
DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
752 g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
754 memcpy(delay[k], delay[k]+nL,
PS_MAX_DELAY*
sizeof(delay[k][0]));
757 memcpy(ap_delay[k][m], ap_delay[k][m]+
numQMFSlots, 5*
sizeof(ap_delay[k][m][0]));
762 transient_gain[b], g_decay_slope, nL - n0);
764 for (; k < SHORT_DELAY_BAND[is34]; k++) {
766 memcpy(delay[k], delay[k]+nL,
PS_MAX_DELAY*
sizeof(delay[k][0]));
770 transient_gain[i], nL - n0);
772 for (; k < NR_BANDS[is34]; k++) {
774 memcpy(delay[k], delay[k]+nL,
PS_MAX_DELAY*
sizeof(delay[k][0]));
778 transient_gain[i], nL - n0);
783 int8_t (*par)[PS_MAX_NR_IIDICC],
784 int num_par,
int num_env,
int full)
788 if (num_par == 20 || num_par == 11) {
789 for (e = 0; e < num_env; e++) {
792 }
else if (num_par == 10 || num_par == 5) {
793 for (e = 0; e < num_env; e++) {
801 static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
802 int8_t (*par)[PS_MAX_NR_IIDICC],
803 int num_par,
int num_env,
int full)
807 if (num_par == 34 || num_par == 17) {
808 for (e = 0; e < num_env; e++) {
811 }
else if (num_par == 10 || num_par == 5) {
812 for (e = 0; e < num_env; e++) {
843 memcpy(H11[0][0], H11[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H11[0][0][0]));
844 memcpy(H11[1][0], H11[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H11[1][0][0]));
845 memcpy(H12[0][0], H12[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H12[0][0][0]));
846 memcpy(H12[1][0], H12[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H12[1][0][0]));
847 memcpy(H21[0][0], H21[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H21[0][0][0]));
848 memcpy(H21[1][0], H21[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H21[1][0][0]));
849 memcpy(H22[0][0], H22[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H22[0][0][0]));
850 memcpy(H22[1][0], H22[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H22[1][0][0]));
892 for (e = 0; e < ps->
num_env; e++) {
893 for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
895 h11 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][0];
896 h12 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][1];
897 h21 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][2];
898 h22 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][3];
905 int opd_idx = opd_hist[
b] * 8 + opd_mapped[e][
b];
906 int ipd_idx = ipd_hist[
b] * 8 + ipd_mapped[e][
b];
911 opd_hist[
b] = opd_idx & 0x3F;
912 ipd_hist[
b] = ipd_idx & 0x3F;
914 ipd_adj_re =
AAC_MADD30(opd_re, ipd_re, opd_im, ipd_im);
915 ipd_adj_im =
AAC_MSUB30(opd_im, ipd_re, opd_re, ipd_im);
924 H11[1][e+1][
b] = h11i;
925 H12[1][e+1][
b] = h12i;
926 H21[1][e+1][
b] = h21i;
927 H22[1][e+1][
b] = h22i;
929 H11[0][e+1][
b] = h11;
930 H12[0][e+1][
b] = h12;
931 H21[0][e+1][
b] = h21;
932 H22[0][e+1][
b] = h22;
934 for (k = 0; k < NR_BANDS[is34]; k++) {
941 width =
FFMIN(2
U*width, INT_MAX);
944 h[0][0] = H11[0][e][
b];
945 h[0][1] = H12[0][e][
b];
946 h[0][2] = H21[0][e][
b];
947 h[0][3] = H22[0][e][
b];
950 if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
951 h[1][0] = -H11[1][e][
b];
952 h[1][1] = -H12[1][e][
b];
953 h[1][2] = -H21[1][e][
b];
954 h[1][3] = -H22[1][e][
b];
956 h[1][0] = H11[1][e][
b];
957 h[1][1] = H12[1][e][
b];
958 h[1][2] = H21[1][e][
b];
959 h[1][3] = H22[1][e][
b];
986 int is34 = ps->is34bands;
988 top += NR_BANDS[is34] - 64;
989 memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*
sizeof(ps->delay[0]));
990 if (top < NR_ALLPASS_BANDS[is34])
991 memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*
sizeof(ps->ap_delay[0]));
1002 #define PS_INIT_VLC_STATIC(num, size) \ 1003 INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \ 1004 ps_tmp[num].ps_bits, 1, 1, \ 1005 ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \ 1008 #define PS_VLC_ROW(name) \ 1009 { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } 1013 static const struct {
1014 const void *ps_codes, *ps_bits;
1015 const unsigned int table_size, elem_size;
void AAC_RENAME() ff_psdsp_init(PSDSPContext *s)
void(* mul_pair_single)(INTFLOAT(*dst)[2], INTFLOAT(*src0)[2], INTFLOAT *src1, int n)
static const INTFLOAT g1_Q2[]
static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
INTFLOAT peak_decay_diff_smooth[34]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static TABLE_CONST int Q_fract_allpass[2][50][3][2]
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
INTFLOAT peak_decay_nrg[34]
static const int NR_BANDS[]
Number of frequency bands that can be addressed by the sub subband index, k.
int AAC_RENAME() ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
static const int8_t nr_iidopd_par_tab[]
static const int NR_IPDOPD_BANDS[]
static const int8_t huff_offset[]
static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full)
Table 8.46.
static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
void(* hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT(*in)[32][2], int i, int len)
INTFLOAT ap_delay[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2]
static const int8_t k_to_i_34[]
Table 8.49.
#define PS_INIT_VLC_STATIC(num, size)
int AAC_RENAME() ff_ps_apply(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top)
#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION)
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static int pd_im_smooth[8 *8 *8]
INTFLOAT H21[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
INTFLOAT delay[PS_MAX_SSB][PS_QMF_TIME_SLOTS+PS_MAX_DELAY][2]
static uint32_t reverse(uint32_t num, int bits)
void(* decorrelate)(INTFLOAT(*out)[2], INTFLOAT(*delay)[2], INTFLOAT(*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], const INTFLOAT phi_fract[2], const INTFLOAT(*Q_fract)[2], const INTFLOAT *transient_gain, INTFLOAT g_decay_slope, int len)
static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2], INTFLOAT in[5][44][2], INTFLOAT L[2][38][64], int is34, int len)
static void remap34(int8_t(**p_par_mapped)[PS_MAX_NR_IIDICC], int8_t(*par)[PS_MAX_NR_IIDICC], int num_par, int num_env, int full)
static int get_bits_count(const GetBitContext *s)
void(* add_squares)(INTFLOAT *dst, const INTFLOAT(*src)[2], int n)
bitstream reader API header.
static int f34_0_12[12][8][2]
static const uint8_t header[24]
static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
#define DECAY_SLOPE
All-pass filter decay slope.
static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT(*in)[2], INTFLOAT(*out)[32][2], TABLE_CONST INTFLOAT(*filter)[8][2], int len)
Split one subband into 6 subsubbands with a complex filter.
#define AAC_MSUB30(x, y, a, b)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void hybrid2_re(INTFLOAT(*in)[2], INTFLOAT(*out)[32][2], const INTFLOAT filter[8], int len, int reverse)
Split one subband into 2 subsubbands with a symmetric real filter.
int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-Channel Coherence Parameters.
#define AAC_HALF_SUM(x, y)
static const int SHORT_DELAY_BAND[]
First stereo band using the short one sample delay.
#define PS_BASELINE
Operate in Baseline PS mode.
INTFLOAT H22[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
void(* hybrid_analysis)(INTFLOAT(*out)[2], INTFLOAT(*in)[2], const INTFLOAT(*filter)[8][2], ptrdiff_t stride, int n)
static int phi_fract[2][50][2]
common internal API header
static int f34_1_8[8][8][2]
void(* stereo_interpolate[2])(INTFLOAT(*l)[2], INTFLOAT(*r)[2], INTFLOAT h[2][4], INTFLOAT h_step[2][4], int len)
static void stereo_processing(PSContext *ps, INTFLOAT(*l)[32][2], INTFLOAT(*r)[32][2], int is34)
static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC])
static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], INTFLOAT in[91][32][2], int is34, int len)
int8_t ipd_hist[PS_MAX_NR_IIDICC]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const int huff_iid[]
int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Phase Difference Parameters.
av_cold void AAC_RENAME() ff_ps_init(void)
static const int8_t nr_iidicc_par_tab[]
const uint8_t ff_log2_tab[256]
static const int NR_ALLPASS_BANDS[]
Number of all-pass filer bands.
Libavcodec external API header.
typedef void(RENAME(mix_any_func_type))
static const int8_t num_env_tab[2][4]
static void hybrid4_8_12_cx(PSDSPContext *dsp, INTFLOAT(*in)[2], INTFLOAT(*out)[32][2], TABLE_CONST INTFLOAT(*filter)[8][2], int N, int len)
main external API structure.
static void decorrelation(PSContext *ps, INTFLOAT(*out)[32][2], const INTFLOAT(*s)[32][2], int is34)
static void ps_tableinit(void)
static unsigned int get_bits1(GetBitContext *s)
int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Intensity Difference Parameters.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static void skip_bits1(GetBitContext *s)
static const int NR_PAR_BANDS[]
Number of frequency bands that can be addressed by the parameter index, b(k)
static void skip_bits(GetBitContext *s, int n)
INTFLOAT power_smooth[34]
av_cold void AAC_RENAME() ff_ps_ctx_init(PSContext *ps)
int8_t opd_hist[PS_MAX_NR_IIDICC]
int border_position[PS_MAX_NUM_ENV+1]
#define AAC_MADD30(x, y, a, b)
#define AAC_MSUB31_V3(x, y, z)
common internal and external API header
static const int8_t k_to_i_20[]
Table 8.48.
void(* hybrid_analysis_ileave)(INTFLOAT(*out)[32][2], INTFLOAT L[2][38][64], int i, int len)
#define PS_QMF_TIME_SLOTS
static void remap20(int8_t(**p_par_mapped)[PS_MAX_NR_IIDICC], int8_t(*par)[PS_MAX_NR_IIDICC], int num_par, int num_env, int full)
static int pd_re_smooth[8 *8 *8]
INTFLOAT H12[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
static int f34_2_4[4][8][2]
static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC])
INTFLOAT H11[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
static const int DECAY_CUTOFF[]
Start frequency band for the all-pass filter decay slope.
static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
#define LOCAL_ALIGNED_16(t, v,...)
static int f20_0_8[8][8][2]
int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Overall Phase Difference Parameters.