37#define SFB_PER_PRED_BAND 2
42 if (
val < ((1 << nb1) - 1))
46 if (nb3 && (val2 == ((1 << nb2) - 1)))
136 for (
int i = 0;
i < nb_album;
i++) {
145 for (
int i = 0;
i < nb_info;
i++) {
171 if (method == 1 || method == 2)
201 uint8_t size_bits =
get_bits(gb, 4) + 4;
229 uint8_t header_extra1;
230 uint8_t header_extra2;
294 int numBands = ((
int[]){0,28,20,14,10,7,5,4})[e->
mps.
freq_res];
303 int otts_bands_phase = ((
int[]){0,10,10,7,5,3,2,2})[e->
mps.
freq_res];
306 if (otts_bands_phase > numBands)
313 int residual_bands =
get_bits(gb, 5);
314 if (residual_bands > numBands)
332 int base_channel_count =
get_bits(gb, 7);
335 for (
int i = 0;
i < base_channel_count;
i++)
338 return base_channel_count;
344 int target_channel_count;
346 target_channel_count =
get_bits(gb, 7);
349 skip_bits_long(gb, 4 * target_channel_count * base_channel_count);
362 int add_downmix_cnt =
get_bits(gb, 3);
363 for (
int j = 0; j < add_downmix_cnt; j++)
368 if ((set_effects & (3 << 10)) == 0) {
384 int nb_downmix_instr, nb_coeff_basic = 0, nb_instr_basic = 0;
385 int nb_coeff_uni, nb_instr_uni;
386 int base_channel_count;
404 if (nb_coeff_uni || nb_instr_uni) {
406 "AAC USAC uniDrc DRC processing");
412 for (
int i = 0;
i < nb_downmix_instr;
i++)
415 for (
int i = 0;
i < nb_coeff_basic;
i++)
418 for (
int i = 0;
i < nb_instr_basic;
i++)
424 uint8_t size_bits =
get_bits(gb, 4) + 4;
440 int len = 0, ext_config_len;
495 int elem_id[3 ] = { 0, 0, 0 };
528 memset(
us, 0,
sizeof(*
us));
533 for (
int j = 0; j < ch; j++) {
537 memset(
ue, 0,
sizeof(*
ue));
540 ue->noise.seed = 0x3039;
557 uint8_t channel_config_idx;
559 int ratio_mult, ratio_dec;
573 memset(usac, 0,
sizeof(*usac));
577 if (freq_idx == 0x1f) {
599 if (sbr_ratio == 2) {
602 }
else if (sbr_ratio == 3) {
605 }
else if (sbr_ratio == 4) {
615 m4ac->
sample_rate = (samplerate * ratio_dec) / ratio_mult;
618 m4ac->
sbr = sbr_ratio > 0;
620 channel_config_idx =
get_bits(gb, 5);
621 if (!channel_config_idx) {
624 if (nb_channels > 64)
633 for (
int i = 0;
i < nb_channels;
i++) {
649 &nb_elements, channel_config_idx)))
653 for (
int i = 0;
i < nb_elements;
i++)
654 nb_channels += layout_map[
i][0] ==
TYPE_CPE ? 2 : 1;
660 elem_id[0] = elem_id[1] = elem_id[2] = 0;
670 int map_count = elem_id[0] + elem_id[1] + elem_id[2];
672 memset(e, 0,
sizeof(*e));
682 (map_count >= nb_elements ||
685 "channel configuration\n",
i);
702 layout_map[map_count][0] =
TYPE_SCE;
703 layout_map[map_count][1] = elem_id[0]++;
714 layout_map[map_count][0] =
TYPE_CPE;
715 layout_map[map_count][1] = elem_id[1]++;
724 layout_map[map_count][0] =
TYPE_LFE;
725 layout_map[map_count][1] = elem_id[2]++;
738 if (map_pos_set && elem_id[0] + elem_id[1] + elem_id[2] != nb_elements) {
740 "channel configuration\n");
756 for (
int i = 0;
i < nb_extensions;
i++) {
791 "USAC input loudness: %.2f LKFS (bsMethodValue=%d)\n",
809 int offset_sf = global_gain;
811 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
814 if (offset_sf > 255U) {
816 "Scalefactor (%d) out of range.\n", offset_sf);
837 int reset, uint16_t
len, uint16_t
N)
859 for (
i = 0;
i <
len/2;
i++) {
863 for (lvl=esc_nb=0;;) {
875 if ((esc_nb = lvl) > 7)
890 for (
int l = lvl; l > 0; l--) {
891 int lsbidx = !
a ? 1 : (!
b ? 0 : 2);
894 a = (
a << 1) | (
r & 1);
895 b = (
b << 1) | ((
r >> 1) & 1);
907 skip_bits(gb, gb_count2 - gb_count - 14);
914 for (;
i <
N/2;
i++) {
920 for (
i = 0;
i <
len;
i++) {
932 int num_window_groups,
933 int prev_num_window_groups,
940 for (
int g = 0;
g < num_window_groups;
g++) {
949 for (
int g = 0;
g < num_window_groups;
g++)
957 us->use_prev_frame = 0;
958 if (
us->complex_coef && !indep_flag)
966 for (
int g = 0;
g < num_window_groups;
g++) {
968 float last_alpha_q_re = 0;
969 float last_alpha_q_im = 0;
970 if (delta_code_time) {
981 const int wg = prev_num_window_groups - 1;
982 last_alpha_q_re =
us->prev_alpha_q_re[wg*cpe->
max_sfb_ste + sfb];
983 last_alpha_q_im =
us->prev_alpha_q_im[wg*cpe->
max_sfb_ste + sfb];
997 last_alpha_q_re +=
val * 0.1f;
998 if (
us->complex_coef) {
1000 last_alpha_q_im +=
val * 0.1f;
1042 for (
int j = 0; j < 7; j++) {
1044 if (
ue->scale_factor_grouping & (1 << (6 - j)))
1070 "Number of scalefactor bands in group (%d) "
1071 "exceeds limit (%d).\n",
1088 int ret, tns_active;
1098 us->common_window = 0;
1103 memset(
us->alpha_q_re, 0,
sizeof(
us->alpha_q_re));
1104 memset(
us->alpha_q_im, 0,
sizeof(
us->alpha_q_im));
1112 if (!
us->common_window || indep_flag) {
1113 memset(
us->prev_alpha_q_re, 0,
sizeof(
us->prev_alpha_q_re));
1114 memset(
us->prev_alpha_q_im, 0,
sizeof(
us->prev_alpha_q_im));
1117 if (
us->common_window) {
1137 memset(
us->prev_alpha_q_re, 0,
sizeof(
us->prev_alpha_q_re));
1138 memset(
us->prev_alpha_q_im, 0,
sizeof(
us->prev_alpha_q_im));
1169 if (
us->ms_mask_mode == 1) {
1173 }
else if (
us->ms_mask_mode == 2) {
1188 "AAC USAC timewarping");
1196 if (
us->common_window)
1204 memcpy(&sce2->
tns, &sce1->
tns,
sizeof(sce1->
tns));
1228 unsigned int new_seed = *
seed = ((*seed) * 69069) + 5;
1229 if (((new_seed) & 0x10000) > 0)
1240 float noise_val = powf(2, ((
float)
ue->noise.level - 14.0f)/3.0f);
1241 int noise_offset =
ue->noise.offset - 16;
1251 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
1254 int band_quantized_to_zero = 1;
1259 for (
int group = 0; group < (unsigned)g_len; group++,
cb += 128) {
1260 for (
int z = 0; z < cb_len; z++) {
1264 band_quantized_to_zero = 0;
1268 if (band_quantized_to_zero) {
1283 if (
ue->noise.level)
1294 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
1297 float sf = sce->sf[
g*ics->
max_sfb + sfb];
1299 for (
int group = 0; group < (unsigned)g_len; group++,
cb += 128)
1316 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1320 float *
c1 = coef1 + off;
1321 float *
c2 = coef2 + off;
1322 float *dm = dmix_re + off;
1324 for (
int group = 0; group < (unsigned)g_len;
1325 group++,
c1 += 128,
c2 += 128, dm += 128) {
1326 for (
int z = 0; z < cb_len; z++)
1327 dm[z] = 0.5*(
c1[z] + sign*
c2[z]);
1331 coef1 += g_len << 7;
1332 coef2 += g_len << 7;
1333 dmix_re += g_len << 7;
1348 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1352 float *
c1 = coef1 + off;
1353 float *
c2 = coef2 + off;
1354 float *dm = dmix_re + off;
1357 for (
int group = 0; group < (unsigned)g_len;
1358 group++,
c1 += 128,
c2 += 128, dm += 128) {
1359 for (
int z = 0; z < cb_len; z++)
1360 dm[z] = 0.5*(
c1[z] + sign*
c2[z]);
1363 for (
int group = 0; group < (unsigned)g_len;
1364 group++,
c1 += 128,
c2 += 128, dm += 128) {
1365 for (
int z = 0; z < cb_len; z++)
1371 coef1 += g_len << 7;
1372 coef2 += g_len << 7;
1373 dmix_re += g_len << 7;
1378 int len,
int factor_even,
int factor_odd)
1383 s =
f[6]*re[2] +
f[5]*re[1] +
f[4]*re[0] +
1385 f[2]*re[1] +
f[1]*re[2] +
f[0]*re[3];
1386 im[
i] +=
s*factor_even;
1389 s =
f[6]*re[1] +
f[5]*re[0] +
f[4]*re[0] +
1391 f[2]*re[2] +
f[1]*re[3] +
f[0]*re[4];
1392 im[
i] +=
s*factor_odd;
1395 s =
f[6]*re[0] +
f[5]*re[0] +
f[4]*re[1] +
1397 f[2]*re[3] +
f[1]*re[4] +
f[0]*re[5];
1399 im[
i] +=
s*factor_even;
1400 for (
i = 3;
i <
len - 4;
i += 2) {
1401 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1403 f[2]*re[
i+1] +
f[1]*re[
i+2] +
f[0]*re[
i+3];
1404 im[
i+0] +=
s*factor_odd;
1406 s =
f[6]*re[
i-2] +
f[5]*re[
i-1] +
f[4]*re[
i] +
1408 f[2]*re[
i+2] +
f[1]*re[
i+3] +
f[0]*re[
i+4];
1409 im[
i+1] +=
s*factor_even;
1413 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1415 f[2]*re[
i+1] +
f[1]*re[
i+2] +
f[0]*re[
i+2];
1416 im[
i] +=
s*factor_odd;
1419 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1421 f[2]*re[
i+1] +
f[1]*re[
i+1] +
f[0]*re[
i];
1422 im[
i] +=
s*factor_even;
1425 s =
f[6]*re[
i-3] +
f[5]*re[
i-2] +
f[4]*re[
i-1] +
1427 f[2]*re[
i] +
f[1]*re[
i-1] +
f[0]*re[
i-2];
1428 im[
i] +=
s*factor_odd;
1437 float *dmix_im =
us->dmix_im;
1441 for (
int sfb = 0; sfb < cpe->
max_sfb_ste; sfb++) {
1445 float *
c1 = coef1 + off;
1446 float *
c2 = coef2 + off;
1447 float *dm_im = dmix_im + off;
1455 for (
int group = 0; group < (unsigned)g_len;
1456 group++,
c1 += 128,
c2 += 128, dm_im += 128) {
1457 for (
int z = 0; z < cb_len; z++) {
1459 side =
c2[z] - alpha_re*
c1[z] - alpha_im*dm_im[z];
1460 c2[z] =
c1[z] - side;
1461 c1[z] =
c1[z] + side;
1465 for (
int group = 0; group < (unsigned)g_len;
1466 group++,
c1 += 128,
c2 += 128, dm_im += 128) {
1467 for (
int z = 0; z < cb_len; z++) {
1469 mid =
c2[z] - alpha_re*
c1[z] - alpha_im*dm_im[z];
1470 c2[z] = mid -
c1[z];
1471 c1[z] = mid +
c1[z];
1477 coef1 += g_len << 7;
1478 coef2 += g_len << 7;
1479 dmix_im += g_len << 7;
1528 for (
int ch = 0; ch < nb_channels; ch++) {
1536 if (nb_channels > 1 &&
us->common_window) {
1537 for (
int ch = 0; ch < nb_channels; ch++) {
1545 if (
us->ms_mask_mode == 3) {
1553 if (
us->use_prev_frame) {
1560 }
else if (
us->ms_mask_mode > 0) {
1566 if (nb_channels > 1) {
1568 for (
int ch = 0; ch < nb_channels; ch++) {
1570 memcpy(sce->prev_coeffs, sce->
coeffs,
sizeof(sce->
coeffs));
1572 memcpy(us2->prev_alpha_q_re, us2->alpha_q_re,
sizeof(us2->alpha_q_re));
1573 memcpy(us2->prev_alpha_q_im, us2->alpha_q_im,
sizeof(us2->alpha_q_im));
1576 for (
int ch = 0; ch < nb_channels; ch++) {
1580 if (sce->
tns.
present && ((nb_channels == 1) || (
us->tns_on_lr)))
1590 255 , 28, 20, 14, 10, 7, 5, 4,
1598 int nb_tr_slots,
int nb_slots)
1600 int nb_bits =
av_log2(nb_slots / (nb_tr_slots + 1));
1602 for (
int k = 0; k < nb_slots; k++)
1605 int p = nb_tr_slots + 1;
1606 for (
int k = nb_slots - 1; k >= 0; k--) {
1613 for (
int h = 2;
h <= p &&
c <=
s;
h++) {
1647 int indep = frame_indep_flag;
1648 if (!frame_indep_flag)
1652 (nb_time_slots - 1);
1703 int nb_data_bands = (nb_bands - 1);
1705 for (
int j = 0; j < nb_data_bands; j++)
1718 for (
int i = 0;
i < 2;
i++)
1724 "Error parsing TSD reshape data!\n");
1736 for (
int i = 0;
i < nb_time_slots;
i++) {
1751 int arith_reset_flag;
1753 int core_nb_channels = nb_channels;
1756 uint8_t global_gain;
1758 us->common_window = 0;
1760 for (
int ch = 0; ch < core_nb_channels; ch++) {
1765 ue->tns_data_present = 0;
1771 core_nb_channels = 1;
1773 if (core_nb_channels == 2) {
1779 for (
int ch = 0; ch < core_nb_channels; ch++) {
1784 if (
ue->core_mode) {
1791 if ((core_nb_channels == 1) ||
1798 ue->noise.level = 0;
1804 if (!
us->common_window) {
1827 "AAC USAC timewarping");
1836 if (
ue->tns_data_present) {
1844 arith_reset_flag = indep_flag;
1845 if (!arith_reset_flag)
1849 memset(&sce->
coeffs[0], 0, 1024*
sizeof(
float));
1859 arith_reset_flag && (
win == 0), lg,
N);
1876 int sbr_ch = nb_channels;
1877 if (nb_channels == 2 &&
1910 uint8_t temp_data[512];
1911 uint8_t *tmp_buf = temp_data;
1912 size_t tmp_buf_size =
sizeof(temp_data);
1915 int num_preroll_frames;
1933 if (!memcmp(m4ac, &m4ac_bak,
sizeof(m4ac_bak)))
1942 for (
int i = 0;
i < num_preroll_frames;
i++) {
1943 int got_frame_ptr = 0;
1946 if (au_len*8 > tmp_buf_size) {
1948 tmp_buf = tmp_buf == temp_data ?
NULL : tmp_buf;
1951 if (tmp_buf != temp_data)
1959 for (
int j = 0; j < au_len; j++)
1971 if (tmp_buf != temp_data)
1980 uint8_t pl_frag_start = 1;
1981 uint8_t pl_frag_end = 1;
2008 if (!(pl_frag_start && pl_frag_end)) {
2024 for (
int i = 0;
i <
len;
i++)
2036 if (!(pl_frag_start && pl_frag_end)) {
2072 int ret, is_dmono = 0;
2073 int indep_flag, samples = 0;
2074 int audio_found = 0;
2075 int elem_id[3 ] = { 0, 0, 0 };
2078 int ratio_mult, ratio_dec;
2085 if (sbr_ratio == 2) {
2088 }
else if (sbr_ratio == 3) {
2091 }
else if (sbr_ratio == 4) {
2113 layout_id = elem_id[0]++;
2117 layout_id = elem_id[1]++;
2121 layout_id = elem_id[2]++;
2128 "channel element %d.%d is not allocated\n",
2129 layout_type, layout_id);
2165 samples = (samples * ratio_mult) / ratio_dec;
2167 if (ac->
oc[1].
status && audio_found) {
2173 if (!
frame->data[0] && samples) {
2179 frame->nb_samples = samples;
2191 if (method_val < 0) {
2194 "target_level set but no program/anchor loudness "
2195 "measurement available; normalization skipped\n");
2200 float input_loudness = -57.75f + 0.25f * method_val;
2202 float gain = powf(10.0f, gain_dB / 20.0f);
2204 for (
int ch = 0; ch <
frame->ch_layout.nb_channels; ch++)
2206 (
float *)
frame->extended_data[ch],
2207 gain,
frame->nb_samples);
2212 is_dmono = ac->
dmono_mode && elem_id[0] == 2 &&
static int ff_aac_sample_rate_idx(int rate)
@ ESC_BT
Spectral data are coded with an escape sequence.
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
@ ID_EXT_ELE_AUDIOPREROLL
@ ID_CONFIG_EXT_LOUDNESS_INFO
@ ID_CONFIG_EXT_STREAM_ID
@ OC_LOCKED
Output configuration locked in place.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
uint32_t ff_aac_ac_get_pk(uint32_t c)
uint32_t ff_aac_ac_get_context(AACArithState *state, uint32_t c, int i, int N)
uint16_t ff_aac_ac_decode(AACArith *ac, GetBitContext *gb, const uint16_t *cdf, uint16_t cdf_len)
void ff_aac_ac_update_context(AACArithState *state, int idx, uint16_t a, uint16_t b)
uint32_t ff_aac_ac_map_process(AACArithState *state, int reset, int N)
void ff_aac_ac_finish(AACArithState *state, int offset, int N)
void ff_aac_ac_init(AACArith *ac, GetBitContext *gb)
int ff_aac_ldp_parse_channel_stream(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemData *ce, GetBitContext *gb)
int ff_aac_parse_fac_data(AACUsacElemData *ce, GetBitContext *gb, int use_gain, int len)
VLCElem ff_vlc_scalefactors[352]
static void decode_drc_instructions_basic(AACUsacElemConfig *e, GetBitContext *gb)
static int decode_usac_element_pair(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
static void complex_stereo_downmix_cur(AACDecContext *ac, ChannelElement *cpe, float *dmix_re)
int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, GetBitContext *gb, int *got_frame_ptr)
static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemConfig *ec, ChannelElement *cpe, GetBitContext *gb, int indep_flag)
static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, AACUsacElemConfig *ec, ChannelElement *che, GetBitContext *gb, int indep_flag, int nb_channels)
static int parse_audio_preroll(AACDecContext *ac, GetBitContext *gb)
static int decode_drc_channel_layout(GetBitContext *gb)
static void apply_complex_stereo(AACDecContext *ac, ChannelElement *cpe)
static void skip_drc_downmix_instructions(GetBitContext *gb, int base_channel_count)
static const float * complex_stereo_get_filter(ChannelElement *cpe, int is_prev)
static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac, GetBitContext *gb)
int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc)
static int decode_usac_scale_factors(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, uint8_t global_gain)
static int decode_loudness_set_v1(AACDecContext *ac, AACUSACConfig *usac, GetBitContext *gb)
int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, OutputConfiguration *oc, int channel_config)
static int methodvalue_width(int method_def)
static void complex_stereo_interpolate_imag(float *im, float *re, const float f[7], int len, int factor_even, int factor_odd)
#define SFB_PER_PRED_BAND
static const uint8_t mps_fr_nb_bands[8]
static void complex_stereo_downmix_prev(AACDecContext *ac, ChannelElement *cpe, float *dmix_re)
static int decode_spectrum_ac(AACDecContext *s, float coef[1024], GetBitContext *gb, AACArithState *state, int reset, uint16_t len, uint16_t N)
Decode and dequantize arithmetically coded, uniformly quantized value.
static int decode_usac_sbr_data(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
static int decode_drc_config(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
static void decode_tsd(GetBitContext *gb, int *data, int nb_tr_slots, int nb_slots)
static uint32_t get_escaped_value(GetBitContext *gb, int nb1, int nb2, int nb3)
static void decode_usac_element_core(AACUsacElemConfig *e, GetBitContext *gb, int sbr_ratio)
static void spectrum_scale(AACDecContext *ac, SingleChannelElement *sce, AACUsacElemData *ue)
static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e, GetBitContext *gb)
static int setup_sce(AACDecContext *ac, SingleChannelElement *sce, AACUSACConfig *usac)
static int decode_loudness_info(AACDecContext *ac, AACUSACLoudnessInfo *info, GetBitContext *gb, int v1)
static int parse_mps212(AACDecContext *ac, AACUSACConfig *usac, AACUsacMPSData *mps, AACUsacElemConfig *ec, GetBitContext *gb, int frame_indep_flag)
static const uint8_t mps_fr_stride_smg[4]
static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, ChannelElement *cpe, int nb_channels)
static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us, ChannelElement *cpe, GetBitContext *gb, int num_window_groups, int prev_num_window_groups, int indep_flag)
static void apply_noise_fill(AACDecContext *ac, SingleChannelElement *sce, AACUsacElemData *ue)
static enum AVChannel usac_ch_pos_to_av[64]
static float noise_random_sign(unsigned int *seed)
static int select_loudness_measurement(const AACUSACConfig *usac)
int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld, enum AACMPSDataType data_type, int default_val, int start_band, int end_band, int frame_indep_flag, int indep_flag, int nb_param_sets)
int ff_aac_huff_dec_reshape(GetBitContext *gb, int16_t *out_data, int nb_val)
int ff_aac_map_index_data(AACMPSLosslessData *ld, enum AACMPSDataType data_type, int dst_idx[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS], int default_value, int start_band, int stop_band, int nb_param_sets, const int *param_set_idx, int extend_frame)
AAC Spectral Band Replication function declarations.
int ff_aac_sbr_config_usac(AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue)
Due to channel allocation not being known upon SBR parameter transmission, supply the parameters sepa...
int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue, GetBitContext *gb, int sbr_ch, int indep_flag)
Decode frame SBR data, USAC.
const int ff_aac_usac_samplerate[32]
const uint16_t ff_aac_ac_lsb_cdfs[3][4]
const uint16_t ff_aac_ac_msb_cdfs[64][17]
const uint8_t ff_aac_num_swb_96[]
const uint16_t *const ff_swb_offset_128[]
const uint16_t *const ff_swb_offset_1024[]
const uint8_t ff_aac_num_swb_768[]
const uint16_t *const ff_swb_offset_96[]
const float ff_aac_usac_mdst_filt_cur[4][4][7]
const uint8_t ff_aac_num_swb_1024[]
const uint8_t ff_aac_num_swb_128[]
const uint8_t ff_tns_max_bands_usac_128[]
const uint8_t ff_usac_noise_fill_start_offset[2][2]
const uint16_t *const ff_swb_offset_768[]
const uint8_t ff_tns_max_bands_usac_1024[]
static double val(void *priv, double ch)
static const int8_t filt[NUMTAPS *2]
static float win(SuperEqualizerContext *s, float n, int N)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define ue(name, range_min, range_max)
#define i(width, name, range_min, range_max)
#define AV_PROFILE_AAC_USAC
static struct @346255127015250356166251341105367306144006377143 state
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
#define AV_CHANNEL_LAYOUT_STEREO
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
@ AV_CHAN_TOP_SURROUND_RIGHT
-110 degrees, Rvs, TpRS
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_SIDE_SURROUND_RIGHT
-90 degrees, Rss, SiR
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_TOP_SURROUND_LEFT
+110 degrees, Lvs, TpLS
@ AV_CHAN_SIDE_SURROUND_LEFT
+90 degrees, Lss, SiL
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_SURROUND_DIRECT_RIGHT
@ AV_CHAN_BOTTOM_FRONT_CENTER
@ AV_CHAN_BOTTOM_FRONT_RIGHT
@ AV_CHAN_BOTTOM_FRONT_LEFT
@ AV_CHAN_SURROUND_DIRECT_LEFT
@ AV_CHAN_TOP_FRONT_CENTER
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID *4][3], int tags, enum OCStatus oc_type, int get_new_frame)
Configure output channel order based on the current program configuration element.
ChannelElement * ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t(*layout_map)[3], int *tags, int channel_config)
Set up channel positions based on a default channel configuration as specified in table 1....
#define us(width, name, range_min, range_max, subs,...)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
Memory handling functions.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
#define AV_REFSTRUCT_FLAG_NO_ZEROING
If this flag is set in av_refstruct_alloc_ext_c(), the object will not be initially zeroed.
#define FF_ARRAY_ELEMS(a)
main AAC decoding context
int target_level
Target output loudness in dBFS, used for xHE-AAC loudness normalization based on the parsed loudnessI...
int warned_loudness_missing
struct AVCodecContext * avctx
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
OutputConfiguration oc[2]
void(* apply_tns)(void *_coef_param, TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
void(* imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce)
void(* apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe)
void(* imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce)
void(* dequant_scalefactors)(SingleChannelElement *sce)
void(* sbr_apply)(AACDecContext *ac, ChannelElement *che, int id_aac, int fl960, void *L, void *R)
AACUSACLoudnessInfo album_info[64]
uint8_t core_sbr_frame_len_idx
AACUSACLoudnessInfo info[64]
struct AACUSACConfig::@255231064241100350351340257372241321307313006210 loudness
uint16_t stream_identifier
int input_method_val
Raw bsMethodValue (μ) of the program/anchor-loudness measurement selected for normalization at config...
AACUsacElemConfig elems[MAX_ELEM_ID]
struct AACUSACLoudnessInfo::@144211065203337024143363352034022367376254316171 measurements[16]
struct AACUSACLoudnessInfo::@321071037316376126376256250004061141151267156374 sample_peak
struct AACUSACLoudnessInfo::@243062262052376245203144120027045262312013170327 true_peak
struct AACUsacElemConfig::@355171322144321232200235357333175172075212042356::@272034025153077076322075376027006155226106336120 dflt
struct AACUsacElemConfig::@155117225007163044355101232061326353222222330310 drc
uint8_t stereo_config_index
struct AACUsacElemConfig::@031364347270230120164276243152035317262270312044 mps
uint8_t temp_shape_config
struct AACUsacElemConfig::@253167335173233142055027357074223104054112322124 ext
uint8_t otts_bands_phase_present
struct AACUsacElemConfig::@155117225007163044355101232061326353222222330310::@250177363014367151273127351060337350061157103052 loudness
struct AACUsacElemConfig::@355171322144321232200235357333175172075212042356 sbr
uint8_t scale_factor_grouping
struct AACUsacElemData::@012163364245105102247341275343124375031174205057 noise
int smooth_mode[MPS_MAX_PARAM_SETS]
int smooth_time[MPS_MAX_PARAM_SETS]
int16_t temp_shape_data[MPS_MAX_TIME_SLOTS]
int param_sets[MPS_MAX_PARAM_SETS]
int ott_idx[MPS_ELE_NB][MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS]
AACMPSLosslessData ott[MPS_ELE_NB]
int freq_res_stride_smg[MPS_MAX_PARAM_SETS]
bool smg_data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS]
bool temp_shape_enable_ch[2]
An AVChannelCustom defines a single channel within a custom order layout.
An AVChannelLayout holds information about the channel layout of audio data.
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
int sample_rate
samples per second
int frame_size
Number of samples per channel in an audio frame.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
This structure describes decoded (raw) audio or video data.
channel element - generic struct for SCE/CPE/CCE/LFE
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
SingleChannelElement ch[2]
uint8_t max_sfb_ste
(USAC) Maximum of both max_sfb values
Individual Channel Stream.
uint8_t max_sfb
number of scalefactor bands per group
int prev_num_window_groups
Previous frame's number of window groups.
int num_swb
number of scalefactor window bands
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
enum WindowSequence window_sequence[2]
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
int sbr
-1 implicit, 1 presence
AVChannelLayout ch_layout
uint8_t layout_map[MAX_ELEM_ID *4][3]
Single Channel Element - used for both SCE and LFE elements.
float coeffs[1024]
coefficients for IMDCT, maybe processed
int sfo[128]
scalefactor offsets
AACUsacElemData ue
USAC element data.
float * output
PCM output.
enum BandType band_type[128]
band types
IndividualChannelStream ics
static double cb(void *priv, double x, double y)