Go to the documentation of this file.
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"); \
121 return AVERROR_INVALIDDATA; \
137 if (ps->enable_ipdopd) {
138 for (e = 0; e < ps->num_env; e++) {
149 static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
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++) {
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;
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));
325 for (j = 0; j < 6; j += 2) {
331 re_op = (re_op + 0x40000000) >> 31;
332 im_op = (im_op + 0x40000000) >> 31;
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++) {
420 for (
i = 0;
i < 8;
i++) {
424 for (
i = 0;
i < 4;
i++) {
435 for (
n = 0;
n <
len;
n++) {
450 #define DECAY_SLOPE Q30(0.05f)
455 static const int NR_BANDS[] = { 71, 91 };
464 static void map_idx_10_to_20(int8_t *par_mapped,
const int8_t *par,
int full)
473 for (;
b >= 0;
b--) {
474 par_mapped[2*
b+1] = par_mapped[2*
b] = par[
b];
478 static void map_idx_34_to_20(int8_t *par_mapped,
const int8_t *par,
int full)
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.33333333
f;
517 par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333
f;
518 par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333
f;
519 par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333
f;
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.25
f;
543 static void map_idx_10_to_34(int8_t *par_mapped,
const int8_t *par,
int full)
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];
585 static void map_idx_20_to_34(int8_t *par_mapped,
const int8_t *par,
int full)
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.76592833836465
f);
680 memset(power, 0, 34 *
sizeof(*power));
690 for (k = 0; k <
NR_BANDS[is34]; k++) {
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;
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.0
f;
742 g_decay_slope = 1 << 30;
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);
766 memcpy(delay[k], delay[k]+nL,
PS_MAX_DELAY*
sizeof(delay[k][0]));
770 transient_gain[
i], nL - n0);
774 memcpy(delay[k], delay[k]+nL,
PS_MAX_DELAY*
sizeof(delay[k][0]));
778 transient_gain[
i], nL - n0);
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++) {
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++) {
892 for (e = 0; e < ps->
num_env; e++) {
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++) {
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;
989 memset(ps->delay+top, 0, (
NR_BANDS[is34] - top)*
sizeof(ps->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;
static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
#define AAC_MADD30(x, y, a, b)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int f34_2_4[4][8][2]
static int pd_im_smooth[8 *8 *8]
static int get_bits_count(const GetBitContext *s)
INTFLOAT peak_decay_diff_smooth[34]
static TABLE_CONST int Q_fract_allpass[2][50][3][2]
static const int8_t nr_iidicc_par_tab[]
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 int f20_0_8[8][8][2]
av_cold void AAC_RENAME() ff_ps_init(void)
static const int NR_PAR_BANDS[]
Number of frequency bands that can be addressed by the parameter index, b(k)
#define PS_QMF_TIME_SLOTS
static int f34_0_12[12][8][2]
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
static uint32_t reverse(uint32_t num, int bits)
int8_t ipd_hist[PS_MAX_NR_IIDICC]
int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Phase Difference Parameters.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int pd_re_smooth[8 *8 *8]
int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Overall Phase Difference Parameters.
#define DECAY_SLOPE
All-pass filter decay slope.
void(* add_squares)(INTFLOAT *dst, const INTFLOAT(*src)[2], int n)
INTFLOAT H12[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], INTFLOAT in[91][32][2], int is34, int len)
static int read_ipdopd_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*ipdopd)[34], int table_idx, int e, int dt)
static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full)
Table 8.46.
static const int NR_BANDS[]
Number of frequency bands that can be addressed by the sub subband index, k.
static int read_iid_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*iid)[34], int table_idx, int e, int dt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int8_t k_to_i_34[]
Table 8.49.
int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Intensity Difference Parameters.
static const int NR_ALLPASS_BANDS[]
Number of all-pass filer bands.
#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION)
#define AAC_HALF_SUM(x, y)
INTFLOAT delay[PS_MAX_SSB][PS_QMF_TIME_SLOTS+PS_MAX_DELAY][2]
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.
static const int huff_iid[]
#define AAC_MSUB30(x, y, a, b)
static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC])
static const int SHORT_DELAY_BAND[]
First stereo band using the short one sample delay.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC])
static const int8_t huff_offset[]
INTFLOAT ap_delay[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2]
static const int NR_IPDOPD_BANDS[]
static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
INTFLOAT power_smooth[34]
static unsigned int get_bits1(GetBitContext *s)
void(* hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT(*in)[32][2], int i, int len)
int border_position[PS_MAX_NUM_ENV+1]
static int f34_1_8[8][8][2]
void(* mul_pair_single)(INTFLOAT(*dst)[2], INTFLOAT(*src0)[2], INTFLOAT *src1, int n)
void(* hybrid_analysis_ileave)(INTFLOAT(*out)[32][2], INTFLOAT L[2][38][64], int i, int len)
const uint8_t ff_log2_tab[256]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
#define PS_BASELINE
Operate in Baseline PS mode.
static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
static const int DECAY_CUTOFF[]
Start frequency band for the all-pass filter decay slope.
static const uint8_t header[24]
static int read_icc_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*icc)[34], int table_idx, int e, int dt)
av_cold void AAC_RENAME() ff_ps_ctx_init(PSContext *ps)
static void skip_bits1(GetBitContext *s)
INTFLOAT H22[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
#define AAC_MSUB31_V3(x, y, z)
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)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define i(width, name, range_min, range_max)
int8_t opd_hist[PS_MAX_NR_IIDICC]
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)
int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-Channel Coherence Parameters.
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)
void(* stereo_interpolate[2])(INTFLOAT(*l)[2], INTFLOAT(*r)[2], INTFLOAT h[2][4], INTFLOAT h_step[2][4], int len)
void AAC_RENAME() ff_psdsp_init(PSDSPContext *s)
main external API structure.
static int phi_fract[2][50][2]
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.
static void ps_tableinit(void)
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)
#define LOCAL_ALIGNED_16(t, v,...)
static const INTFLOAT g1_Q2[]
#define PS_INIT_VLC_STATIC(num, size)
static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
int AAC_RENAME() ff_ps_apply(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top)
INTFLOAT H11[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
static const int8_t k_to_i_20[]
Table 8.48.
void(* hybrid_analysis)(INTFLOAT(*out)[2], INTFLOAT(*in)[2], const INTFLOAT(*filter)[8][2], ptrdiff_t stride, int n)
static const int8_t num_env_tab[2][4]
static void stereo_processing(PSContext *ps, INTFLOAT(*l)[32][2], INTFLOAT(*r)[32][2], int is34)
INTFLOAT peak_decay_nrg[34]
static const int8_t nr_iidopd_par_tab[]
int AAC_RENAME() ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
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 void decorrelation(PSContext *ps, INTFLOAT(*out)[32][2], const INTFLOAT(*s)[32][2], int is34)
INTFLOAT H21[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]