36 #define numQMFSlots 32 //numTimeSlots * RATE 
   44     10, 20, 34, 10, 20, 34,
 
   73 #define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ 
   86 static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ 
   87                         int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ 
   89     int b, num = ps->nr_ ## PAR ## _par; \ 
   90     VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \ 
   92         int e_prev = e ? e - 1 : ps->num_env_old - 1; \ 
   93         e_prev = FFMAX(e_prev, 0); \ 
   94         for (b = 0; b < num; b++) { \ 
   95             int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ 
   96             if (MASK) val &= MASK; \ 
  103         for (b = 0; b < num; b++) { \ 
  104             val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ 
  105             if (MASK) val &= MASK; \ 
  113     av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \ 
  130     if (ps->enable_ipdopd) {
 
  131         for (e = 0; e < ps->num_env; e++) {
 
  192         for (e = 1; e <= ps->
num_env; e++)
 
  195         for (e = 1; e <= ps->
num_env; e++)
 
  199         for (e = 0; e < ps->
num_env; e++) {
 
  208         for (e = 0; e < ps->
num_env; e++) {
 
  223             int ps_extension_id = 
get_bits(gb, 2);
 
  240         if (source >= 0 && source != ps->
num_env) {
 
  288     if (bits_consumed <= bits_left) {
 
  290         return bits_consumed;
 
  292     av_log(avctx, 
AV_LOG_ERROR, 
"Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
 
  308     for (i = 0; i < 
len; i++, 
in++) {
 
  309         float re_in = filter[6] * 
in[6][0];          
 
  311         float im_in = filter[6] * in[6][1];          
 
  313         for (j = 0; j < 6; j += 2) {
 
  314             re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]);
 
  315             im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]);
 
  317         out[ reverse][i][0] = re_in + re_op;
 
  318         out[ reverse][i][1] = im_in + im_op;
 
  319         out[!reverse][i][0] = re_in - re_op;
 
  320         out[!reverse][i][1] = im_in - im_op;
 
  332     for (i = 0; i < 
len; i++, 
in++) {
 
  343         out[4][i][1] = temp[2][1] + temp[5][1];
 
  344         out[5][i][0] = temp[3][0] + temp[4][0];
 
  345         out[5][i][1] = temp[3][1] + temp[4][1];
 
  350                             float (*
in)[2], 
float (*
out)[32][2],
 
  355     for (i = 0; i < 
len; i++, 
in++) {
 
  361                             float in[5][44][2], 
float L[2][38][64],
 
  365     for (i = 0; i < 5; i++) {
 
  366         for (j = 0; j < 38; j++) {
 
  367             in[i][j+6][0] = L[0][j][i];
 
  368             in[i][j+6][1] = L[1][j][i];
 
  385     for (i = 0; i < 5; i++) {
 
  386         memcpy(in[i], in[i]+32, 6 * 
sizeof(in[i][0]));
 
  391                              float in[91][32][2], 
int is34, 
int len)
 
  395         for (n = 0; n < 
len; n++) {
 
  396             memset(out[0][n], 0, 5*
sizeof(out[0][n][0]));
 
  397             memset(out[1][n], 0, 5*
sizeof(out[1][n][0]));
 
  398             for (i = 0; i < 12; i++) {
 
  399                 out[0][
n][0] += in[   i][
n][0];
 
  400                 out[1][
n][0] += in[   i][
n][1];
 
  402             for (i = 0; i < 8; i++) {
 
  403                 out[0][
n][1] += in[12+i][
n][0];
 
  404                 out[1][
n][1] += in[12+i][
n][1];
 
  406             for (i = 0; i < 4; i++) {
 
  407                 out[0][
n][2] += in[20+i][
n][0];
 
  408                 out[1][
n][2] += in[20+i][
n][1];
 
  409                 out[0][
n][3] += in[24+i][
n][0];
 
  410                 out[1][
n][3] += in[24+i][
n][1];
 
  411                 out[0][
n][4] += in[28+i][
n][0];
 
  412                 out[1][
n][4] += in[28+i][
n][1];
 
  417         for (n = 0; n < 
len; n++) {
 
  418             out[0][
n][0] = in[0][
n][0] + in[1][
n][0] + in[2][
n][0] +
 
  419                            in[3][
n][0] + in[4][
n][0] + in[5][
n][0];
 
  420             out[1][
n][0] = in[0][
n][1] + in[1][
n][1] + in[2][
n][1] +
 
  421                            in[3][
n][1] + in[4][
n][1] + in[5][
n][1];
 
  422             out[0][
n][1] = in[6][
n][0] + in[7][
n][0];
 
  423             out[1][
n][1] = in[6][
n][1] + in[7][
n][1];
 
  424             out[0][
n][2] = in[8][
n][0] + in[9][
n][0];
 
  425             out[1][
n][2] = in[8][
n][1] + in[9][
n][1];
 
  432 #define DECAY_SLOPE      0.05f 
  455     for (; b >= 0; b--) {
 
  456         par_mapped[2*b+1] = par_mapped[2*
b] = par[
b];
 
  462     par_mapped[ 0] = (2*par[ 0] +   par[ 1]) / 3;
 
  463     par_mapped[ 1] = (  par[ 1] + 2*par[ 2]) / 3;
 
  464     par_mapped[ 2] = (2*par[ 3] +   par[ 4]) / 3;
 
  465     par_mapped[ 3] = (  par[ 4] + 2*par[ 5]) / 3;
 
  466     par_mapped[ 4] = (  par[ 6] +   par[ 7]) / 2;
 
  467     par_mapped[ 5] = (  par[ 8] +   par[ 9]) / 2;
 
  468     par_mapped[ 6] =    par[10];
 
  469     par_mapped[ 7] =    par[11];
 
  470     par_mapped[ 8] = (  par[12] +   par[13]) / 2;
 
  471     par_mapped[ 9] = (  par[14] +   par[15]) / 2;
 
  472     par_mapped[10] =    par[16];
 
  474         par_mapped[11] =    par[17];
 
  475         par_mapped[12] =    par[18];
 
  476         par_mapped[13] =    par[19];
 
  477         par_mapped[14] = (  par[20] +   par[21]) / 2;
 
  478         par_mapped[15] = (  par[22] +   par[23]) / 2;
 
  479         par_mapped[16] = (  par[24] +   par[25]) / 2;
 
  480         par_mapped[17] = (  par[26] +   par[27]) / 2;
 
  481         par_mapped[18] = (  par[28] +   par[29] +   par[30] +   par[31]) / 4;
 
  482         par_mapped[19] = (  par[32] +   par[33]) / 2;
 
  488     par[ 0] = (2*par[ 0] +   par[ 1]) * 0.33333333f;
 
  489     par[ 1] = (  par[ 1] + 2*par[ 2]) * 0.33333333f;
 
  490     par[ 2] = (2*par[ 3] +   par[ 4]) * 0.33333333f;
 
  491     par[ 3] = (  par[ 4] + 2*par[ 5]) * 0.33333333f;
 
  492     par[ 4] = (  par[ 6] +   par[ 7]) * 0.5f;
 
  493     par[ 5] = (  par[ 8] +   par[ 9]) * 0.5f;
 
  496     par[ 8] = (  par[12] +   par[13]) * 0.5f;
 
  497     par[ 9] = (  par[14] +   par[15]) * 0.5f;
 
  502     par[14] = (  par[20] +   par[21]) * 0.5f;
 
  503     par[15] = (  par[22] +   par[23]) * 0.5f;
 
  504     par[16] = (  par[24] +   par[25]) * 0.5f;
 
  505     par[17] = (  par[26] +   par[27]) * 0.5f;
 
  506     par[18] = (  par[28] +   par[29] +   par[30] +   par[31]) * 0.25f;
 
  507     par[19] = (  par[32] +   par[33]) * 0.5f;
 
  513         par_mapped[33] = par[9];
 
  514         par_mapped[32] = par[9];
 
  515         par_mapped[31] = par[9];
 
  516         par_mapped[30] = par[9];
 
  517         par_mapped[29] = par[9];
 
  518         par_mapped[28] = par[9];
 
  519         par_mapped[27] = par[8];
 
  520         par_mapped[26] = par[8];
 
  521         par_mapped[25] = par[8];
 
  522         par_mapped[24] = par[8];
 
  523         par_mapped[23] = par[7];
 
  524         par_mapped[22] = par[7];
 
  525         par_mapped[21] = par[7];
 
  526         par_mapped[20] = par[7];
 
  527         par_mapped[19] = par[6];
 
  528         par_mapped[18] = par[6];
 
  529         par_mapped[17] = par[5];
 
  530         par_mapped[16] = par[5];
 
  534     par_mapped[15] = par[4];
 
  535     par_mapped[14] = par[4];
 
  536     par_mapped[13] = par[4];
 
  537     par_mapped[12] = par[4];
 
  538     par_mapped[11] = par[3];
 
  539     par_mapped[10] = par[3];
 
  540     par_mapped[ 9] = par[2];
 
  541     par_mapped[ 8] = par[2];
 
  542     par_mapped[ 7] = par[2];
 
  543     par_mapped[ 6] = par[2];
 
  544     par_mapped[ 5] = par[1];
 
  545     par_mapped[ 4] = par[1];
 
  546     par_mapped[ 3] = par[1];
 
  547     par_mapped[ 2] = par[0];
 
  548     par_mapped[ 1] = par[0];
 
  549     par_mapped[ 0] = par[0];
 
  555         par_mapped[33] =  par[19];
 
  556         par_mapped[32] =  par[19];
 
  557         par_mapped[31] =  par[18];
 
  558         par_mapped[30] =  par[18];
 
  559         par_mapped[29] =  par[18];
 
  560         par_mapped[28] =  par[18];
 
  561         par_mapped[27] =  par[17];
 
  562         par_mapped[26] =  par[17];
 
  563         par_mapped[25] =  par[16];
 
  564         par_mapped[24] =  par[16];
 
  565         par_mapped[23] =  par[15];
 
  566         par_mapped[22] =  par[15];
 
  567         par_mapped[21] =  par[14];
 
  568         par_mapped[20] =  par[14];
 
  569         par_mapped[19] =  par[13];
 
  570         par_mapped[18] =  par[12];
 
  571         par_mapped[17] =  par[11];
 
  573     par_mapped[16] =  par[10];
 
  574     par_mapped[15] =  par[ 9];
 
  575     par_mapped[14] =  par[ 9];
 
  576     par_mapped[13] =  par[ 8];
 
  577     par_mapped[12] =  par[ 8];
 
  578     par_mapped[11] =  par[ 7];
 
  579     par_mapped[10] =  par[ 6];
 
  580     par_mapped[ 9] =  par[ 5];
 
  581     par_mapped[ 8] =  par[ 5];
 
  582     par_mapped[ 7] =  par[ 4];
 
  583     par_mapped[ 6] =  par[ 4];
 
  584     par_mapped[ 5] =  par[ 3];
 
  585     par_mapped[ 4] = (par[ 2] + par[ 3]) / 2;
 
  586     par_mapped[ 3] =  par[ 2];
 
  587     par_mapped[ 2] =  par[ 1];
 
  588     par_mapped[ 1] = (par[ 0] + par[ 1]) / 2;
 
  589     par_mapped[ 0] =  par[ 0];
 
  623     par[ 4] = (par[ 2] + par[ 3]) * 0.5f;
 
  626     par[ 1] = (par[ 0] + par[ 1]) * 0.5f;
 
  639     const float peak_decay_factor = 0.76592833836465f;
 
  640     const float transient_impact  = 1.5f;
 
  641     const float a_smooth          = 0.25f; 
 
  645     memset(power, 0, 34 * 
sizeof(*power));
 
  655     for (k = 0; k < NR_BANDS[is34]; k++) {
 
  661     for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
 
  662         for (n = n0; n < nL; n++) {
 
  663             float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
 
  665             peak_decay_nrg[i] = 
FFMAX(decayed_peak, power[i][n]);
 
  666             power_smooth[i] += a_smooth * (power[i][
n] - power_smooth[i]);
 
  667             peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][
n] - peak_decay_diff_smooth[i]);
 
  668             denom = transient_impact * peak_decay_diff_smooth[i];
 
  669             transient_gain[i][
n]   = (denom > power_smooth[i]) ?
 
  670                                          power_smooth[i] / denom : 1.0f;
 
  682     for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
 
  684         float g_decay_slope = 1.f - 
DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
 
  685         g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
 
  686         memcpy(delay[k], delay[k]+nL, 
PS_MAX_DELAY*
sizeof(delay[k][0]));
 
  689             memcpy(ap_delay[k][m],   ap_delay[k][m]+
numQMFSlots,           5*
sizeof(ap_delay[k][m][0]));
 
  694                             transient_gain[b], g_decay_slope, nL - n0);
 
  696     for (; k < SHORT_DELAY_BAND[is34]; k++) {
 
  698         memcpy(delay[k], delay[k]+nL, 
PS_MAX_DELAY*
sizeof(delay[k][0]));
 
  702                                 transient_gain[i], nL - n0);
 
  704     for (; k < NR_BANDS[is34]; k++) {
 
  706         memcpy(delay[k], delay[k]+nL, 
PS_MAX_DELAY*
sizeof(delay[k][0]));
 
  710                                 transient_gain[i], nL - n0);
 
  715                     int8_t           (*par)[PS_MAX_NR_IIDICC],
 
  716                     int num_par, 
int num_env, 
int full)
 
  720     if (num_par == 20 || num_par == 11) {
 
  721         for (e = 0; e < num_env; e++) {
 
  724     } 
else if (num_par == 10 || num_par == 5) {
 
  725         for (e = 0; e < num_env; e++) {
 
  733 static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
 
  734                     int8_t           (*par)[PS_MAX_NR_IIDICC],
 
  735                     int num_par, 
int num_env, 
int full)
 
  739     if (num_par == 34 || num_par == 17) {
 
  740         for (e = 0; e < num_env; e++) {
 
  743     } 
else if (num_par == 10 || num_par == 5) {
 
  744         for (e = 0; e < num_env; e++) {
 
  775         memcpy(H11[0][0], H11[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H11[0][0][0]));
 
  776         memcpy(H11[1][0], H11[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H11[1][0][0]));
 
  777         memcpy(H12[0][0], H12[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H12[0][0][0]));
 
  778         memcpy(H12[1][0], H12[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H12[1][0][0]));
 
  779         memcpy(H21[0][0], H21[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H21[0][0][0]));
 
  780         memcpy(H21[1][0], H21[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H21[1][0][0]));
 
  781         memcpy(H22[0][0], H22[0][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H22[0][0][0]));
 
  782         memcpy(H22[1][0], H22[1][ps->
num_env_old], PS_MAX_NR_IIDICC*
sizeof(H22[1][0][0]));
 
  824     for (e = 0; e < ps->
num_env; e++) {
 
  825         for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
 
  826             float h11, h12, h21, h22;
 
  827             h11 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][0];
 
  828             h12 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][1];
 
  829             h21 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][2];
 
  830             h22 = H_LUT[iid_mapped[e][
b] + 7 + 23 * ps->
iid_quant][icc_mapped[e][
b]][3];
 
  835                 float h11i, h12i, h21i, h22i;
 
  836                 float ipd_adj_re, ipd_adj_im;
 
  837                 int opd_idx = opd_hist[
b] * 8 + opd_mapped[e][
b];
 
  838                 int ipd_idx = ipd_hist[
b] * 8 + ipd_mapped[e][
b];
 
  843                 opd_hist[
b] = opd_idx & 0x3F;
 
  844                 ipd_hist[
b] = ipd_idx & 0x3F;
 
  846                 ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
 
  847                 ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
 
  850                 h12i = h12 * ipd_adj_im;
 
  851                 h12  = h12 * ipd_adj_re;
 
  854                 h22i = h22 * ipd_adj_im;
 
  855                 h22  = h22 * ipd_adj_re;
 
  856                 H11[1][e+1][
b] = h11i;
 
  857                 H12[1][e+1][
b] = h12i;
 
  858                 H21[1][e+1][
b] = h21i;
 
  859                 H22[1][e+1][
b] = h22i;
 
  861             H11[0][e+1][
b] = h11;
 
  862             H12[0][e+1][
b] = h12;
 
  863             H21[0][e+1][
b] = h21;
 
  864             H22[0][e+1][
b] = h22;
 
  866         for (k = 0; k < NR_BANDS[is34]; k++) {
 
  873             h[0][0] = H11[0][e][
b];
 
  874             h[0][1] = H12[0][e][
b];
 
  875             h[0][2] = H21[0][e][
b];
 
  876             h[0][3] = H22[0][e][
b];
 
  879             if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
 
  880                 h[1][0] = -H11[1][e][
b];
 
  881                 h[1][1] = -H12[1][e][
b];
 
  882                 h[1][2] = -H21[1][e][
b];
 
  883                 h[1][3] = -H22[1][e][
b];
 
  885                 h[1][0] = H11[1][e][
b];
 
  886                 h[1][1] = H12[1][e][
b];
 
  887                 h[1][2] = H21[1][e][
b];
 
  888                 h[1][3] = H22[1][e][
b];
 
  892             h_step[0][0] = (H11[0][e+1][
b] - h[0][0]) * width;
 
  893             h_step[0][1] = (H12[0][e+1][
b] - h[0][1]) * width;
 
  894             h_step[0][2] = (H21[0][e+1][
b] - h[0][2]) * width;
 
  895             h_step[0][3] = (H22[0][e+1][
b] - h[0][3]) * width;
 
  897                 h_step[1][0] = (H11[1][e+1][
b] - h[1][0]) * width;
 
  898                 h_step[1][1] = (H12[1][e+1][
b] - h[1][1]) * width;
 
  899                 h_step[1][2] = (H21[1][e+1][
b] - h[1][2]) * width;
 
  900                 h_step[1][3] = (H22[1][e+1][
b] - h[1][3]) * width;
 
  903                 l[k] + start + 1, 
r[k] + start + 1,
 
  911     float (*Lbuf)[32][2] = ps->
Lbuf;
 
  912     float (*Rbuf)[32][2] = ps->
Rbuf;
 
  916     top += NR_BANDS[is34] - 64;
 
  917     memset(ps->
delay+top, 0, (NR_BANDS[is34] - top)*
sizeof(ps->
delay[0]));
 
  918     if (top < NR_ALLPASS_BANDS[is34])
 
  919         memset(ps->
ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*
sizeof(ps->
ap_delay[0]));
 
  922     decorrelation(ps, Rbuf, (
const float (*)[32][2]) Lbuf, is34);
 
  930 #define PS_INIT_VLC_STATIC(num, size) \ 
  931     INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size,    \ 
  932                     ps_tmp[num].ps_bits, 1, 1,                                          \ 
  933                     ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \ 
  936 #define PS_VLC_ROW(name) \ 
  937     { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } 
  941     static const struct {
 
  942         const void *ps_codes, *ps_bits;
 
  943         const unsigned int table_size, elem_size;
 
static void hybrid4_8_12_cx(PSDSPContext *dsp, float(*in)[2], float(*out)[32][2], TABLE_CONST float(*filter)[8][2], int N, int len)
 
static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
 
int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
 
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits. 
 
av_cold void ff_psdsp_init(PSDSPContext *s)
 
void(* decorrelate)(float(*out)[2], float(*delay)[2], float(*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], const float phi_fract[2], const float(*Q_fract)[2], const float *transient_gain, float g_decay_slope, int len)
 
static void skip_bits_long(GetBitContext *s, int n)
 
static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
 
void(* hybrid_analysis_ileave)(float(*out)[32][2], float L[2][38][64], int i, int len)
 
float H12[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
 
static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], float in[5][44][2], float L[2][38][64], int is34, int len)
 
static const int NR_BANDS[]
Number of frequency bands that can be addressed by the sub subband index, k. 
 
float delay[PS_MAX_SSB][PS_QMF_TIME_SLOTS+PS_MAX_DELAY][2]
 
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(* mul_pair_single)(float(*dst)[2], float(*src0)[2], float *src1, int n)
 
static void hybrid6_cx(PSDSPContext *dsp, float(*in)[2], float(*out)[32][2], TABLE_CONST float(*filter)[8][2], int len)
Split one subband into 6 subsubbands with a complex filter. 
 
static float pd_im_smooth[8 *8 *8]
 
static const int8_t k_to_i_34[]
Table 8.49. 
 
float peak_decay_diff_smooth[34]
 
static float f34_1_8[8][8][2]
 
#define PS_INIT_VLC_STATIC(num, size)
 
#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION)
 
static av_cold void ps_tableinit(void)
 
void(* stereo_interpolate[2])(float(*l)[2], float(*r)[2], float h[2][4], float h_step[2][4], int len)
 
static void decorrelation(PSContext *ps, float(*out)[32][2], const float(*s)[32][2], int is34)
 
static float f20_0_8[8][8][2]
 
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)
 
static float phi_fract[2][50][2]
 
bitstream reader API header. 
 
const uint8_t ff_log2_tab[256]
 
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. 
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
 
int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-Channel Coherence Parameters. 
 
static float f34_2_4[4][8][2]
 
void(* hybrid_synthesis_deint)(float out[2][38][64], float(*in)[32][2], int i, int len)
 
static int read_iid_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*iid)[34], int table_idx, int e, int dt)
\ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \ * Inter-channel Phase Differen...
 
static const int SHORT_DELAY_BAND[]
First stereo band using the short one sample delay. 
 
#define PS_BASELINE
Operate in Baseline PS mode. 
 
av_cold void ff_ps_ctx_init(PSContext *ps)
 
void(* hybrid_analysis)(float(*out)[2], float(*in)[2], const float(*filter)[8][2], int stride, int n)
 
Libavcodec external API header. 
 
static int read_icc_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*icc)[34], int table_idx, int e, int dt)
\ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \ * Inter-channel Phase Differen...
 
float H11[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
 
common internal API header 
 
static const float g1_Q2[]
 
static float HA[46][8][4]
 
static int read_ipdopd_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int8_t(*ipdopd)[34], int table_idx, int e, int dt)
\ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \ * Inter-channel Phase Differen...
 
int8_t ipd_hist[PS_MAX_NR_IIDICC]
 
static float pd_re_smooth[8 *8 *8]
 
static const int huff_iid[]
 
int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Phase Difference Parameters. 
 
static const int8_t nr_iidicc_par_tab[]
 
float ap_delay[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2]
 
av_cold void ff_ps_init(void)
 
static const int NR_ALLPASS_BANDS[]
Number of all-pass filer bands. 
 
static const int8_t num_env_tab[2][4]
 
main external API structure. 
 
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
 
static unsigned int get_bits1(GetBitContext *s)
 
int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Inter-channel Intensity Difference Parameters. 
 
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 map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
 
static void skip_bits(GetBitContext *s, int n)
 
static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], float in[91][32][2], int is34, int len)
 
static TABLE_CONST float Q_fract_allpass[2][50][3][2]
 
static float HB[46][8][4]
 
int8_t opd_hist[PS_MAX_NR_IIDICC]
 
int border_position[PS_MAX_NUM_ENV+1]
 
static void hybrid2_re(float(*in)[2], float(*out)[32][2], const float filter[8], int len, int reverse)
Split one subband into 2 subsubbands with a symmetric real filter. 
 
static float f34_0_12[12][8][2]
 
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
 
common internal and external API header 
 
static const int8_t k_to_i_20[]
Table 8.48. 
 
float H22[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]
 
#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)
 
void(* add_squares)(float *dst, const float(*src)[2], int n)
 
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
 
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 void stereo_processing(PSContext *ps, float(*l)[32][2], float(*r)[32][2], int is34)
 
int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
 
int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]
Overall Phase Difference Parameters. 
 
static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
 
float H21[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]