99 enum OCStatus oc_type,
int get_new_frame);
101 #define overread_err "Input buffer exhausted before END element found\n" 106 for (i = 0; i < tags; i++) {
107 int syn_ele =
layout[i][0];
109 sum += (1 + (syn_ele ==
TYPE_CPE)) *
134 if (!ac->
che[type][
id]) {
151 if (ac->
che[type][
id])
164 for (type = 0; type < 4; type++) {
184 for (ch = 0; ch < avctx->
channels; ch++) {
201 uint64_t right,
int pos)
203 if (layout_map[offset][0] ==
TYPE_CPE) {
205 .av_position = left | right,
207 .elem_id = layout_map[
offset][1],
215 .elem_id = layout_map[
offset][1],
219 .av_position = right,
221 .elem_id = layout_map[offset + 1][1],
231 int num_pos_channels = 0;
235 for (i = *current; i < tags; i++) {
236 if (layout_map[i][2] != pos)
246 num_pos_channels += 2;
257 return num_pos_channels;
262 int i,
n, total_non_cc_elements;
264 int num_front_channels, num_side_channels, num_back_channels;
273 if (num_front_channels < 0)
277 if (num_side_channels < 0)
281 if (num_back_channels < 0)
284 if (num_side_channels == 0 && num_back_channels >= 4) {
285 num_side_channels = 2;
286 num_back_channels -= 2;
290 if (num_front_channels & 1) {
294 .elem_id = layout_map[i][1],
298 num_front_channels--;
300 if (num_front_channels >= 4) {
305 num_front_channels -= 2;
307 if (num_front_channels >= 2) {
312 num_front_channels -= 2;
314 while (num_front_channels >= 2) {
319 num_front_channels -= 2;
322 if (num_side_channels >= 2) {
327 num_side_channels -= 2;
329 while (num_side_channels >= 2) {
334 num_side_channels -= 2;
337 while (num_back_channels >= 4) {
342 num_back_channels -= 2;
344 if (num_back_channels >= 2) {
349 num_back_channels -= 2;
351 if (num_back_channels) {
355 .elem_id = layout_map[i][1],
366 .elem_id = layout_map[i][1],
375 .elem_id = layout_map[i][1],
382 total_non_cc_elements = n = i;
385 for (i = 1; i <
n; i++)
394 for (i = 0; i < total_non_cc_elements; i++) {
395 layout_map[i][0] = e2c_vec[i].
syn_ele;
396 layout_map[i][1] = e2c_vec[i].
elem_id;
413 ac->
oc[0] = ac->
oc[1];
426 ac->
oc[1] = ac->
oc[0];
441 uint8_t layout_map[MAX_ELEM_ID * 4][3],
int tags,
442 enum OCStatus oc_type,
int get_new_frame)
451 memcpy(ac->
oc[1].
layout_map, layout_map, tags *
sizeof(layout_map[0]));
454 for (i = 0; i < tags; i++) {
455 int type = layout_map[i][0];
456 int id = layout_map[i][1];
458 if (id_map[type][
id] >= MAX_ELEM_ID) {
467 for (i = 0; i < tags; i++) {
468 int type = layout_map[i][0];
469 int id = layout_map[i][1];
470 int iid = id_map[
type][
id];
471 int position = layout_map[i][2];
479 if (ac->
oc[1].
m4ac.
ps == 1 && channels == 2) {
505 for (type = 3; type >= 0; type--) {
509 for (j = 0; j <= 1; j++) {
528 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
529 channel_config > 12) {
531 "invalid default channel configuration (%d)\n",
537 *tags *
sizeof(*layout_map));
552 " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" 570 uint8_t layout_map[MAX_ELEM_ID*4][3];
577 &layout_map_tags, 2) < 0)
589 uint8_t layout_map[MAX_ELEM_ID * 4][3];
596 &layout_map_tags, 1) < 0)
632 "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n",
633 type ==
TYPE_SCE ?
"SCE" :
"LFE", elem_id);
654 "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n",
655 type ==
TYPE_SCE ?
"SCE" :
"LFE", elem_id);
717 layout_map[0][2] =
type;
723 int reference_position) {
738 int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc;
748 "Sample rate index in program config element does not " 749 "match the sample rate index configured by the container.\n");
766 if (
get_bits_left(gb) < 5 * (num_front + num_side + num_back + num_cc) + 4 *(num_lfe + num_assoc_data + num_cc)) {
806 int get_bit_alignment,
810 int extension_flag, ret, ep_config, res_flags;
811 uint8_t layout_map[MAX_ELEM_ID*4][3];
838 if (channel_config == 0) {
840 tags =
decode_pce(avctx, m4ac, layout_map, gb, get_bit_alignment);
845 &tags, channel_config)))
851 }
else if (m4ac->
sbr == 1 && m4ac->
ps == -1)
857 if (extension_flag) {
870 "AAC data resilience (flags %x)",
886 "epConfig %d", ep_config);
898 int ret, ep_config, res_flags;
899 uint8_t layout_map[MAX_ELEM_ID*4][3];
901 const int ELDEXT_TERM = 0;
916 "AAC data resilience (flags %x)",
927 while (
get_bits(gb, 4) != ELDEXT_TERM) {
941 &tags, channel_config)))
950 "epConfig %d", ep_config);
972 int get_bit_alignment,
983 "invalid sampling rate index %d\n",
990 "invalid low delay sampling rate index %d\n",
1015 "Audio object type %s%d",
1016 m4ac->
sbr == 1 ?
"SBR+" :
"",
1022 "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
1039 if (bit_size < 0 || bit_size > INT_MAX) {
1044 ff_dlog(avctx,
"audio specific config size %d\n", (
int)bit_size >> 3);
1045 for (i = 0; i < bit_size >> 3; i++)
1046 ff_dlog(avctx,
"%02x ", data[i]);
1065 union {
unsigned u;
int s; } v = { previous_val * 1664525
u + 1013904223 };
1078 if (92017 <= rate)
return 0;
1079 else if (75132 <= rate)
return 1;
1080 else if (55426 <= rate)
return 2;
1081 else if (46009 <= rate)
return 3;
1082 else if (37566 <= rate)
return 4;
1083 else if (27713 <= rate)
return 5;
1084 else if (23004 <= rate)
return 6;
1085 else if (18783 <= rate)
return 7;
1086 else if (13856 <= rate)
return 8;
1087 else if (11502 <= rate)
return 9;
1088 else if (9391 <= rate)
return 10;
1099 #define AAC_INIT_VLC_STATIC(num, size) \ 1100 INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ 1101 ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \ 1102 sizeof(ff_aac_spectral_bits[num][0]), \ 1103 ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \ 1104 sizeof(ff_aac_spectral_codes[num][0]), \ 1182 uint8_t layout_map[MAX_ELEM_ID*4][3];
1183 int layout_map_tags;
1274 "Invalid Predictor Reset Group.\n");
1320 "AAC LD is only defined for ONLY_LONG_SEQUENCE but " 1333 for (i = 0; i < 7; i++) {
1390 "Prediction is not allowed in AAC-LC.\n");
1395 "LTP in ER AAC LD not yet implemented.\n");
1407 "Number of scalefactor bands in group (%d) " 1408 "exceeds limit (%d).\n",
1435 while (k < ics->max_sfb) {
1438 int sect_band_type =
get_bits(gb, 4);
1439 if (sect_band_type == 12) {
1444 sect_len_incr =
get_bits(gb, bits);
1445 sect_end += sect_len_incr;
1450 if (sect_end > ics->
max_sfb) {
1452 "Number of bands (%d) exceeds limit (%d).\n",
1456 }
while (sect_len_incr == (1 << bits) - 1);
1457 for (; k < sect_end; k++) {
1458 band_type [idx] = sect_band_type;
1459 band_type_run_end[idx++] = sect_end;
1477 unsigned int global_gain,
1480 int band_type_run_end[120])
1487 for (i = 0; i < ics->
max_sfb;) {
1488 int run_end = band_type_run_end[idx];
1489 if (band_type[idx] ==
ZERO_BT) {
1490 for (; i < run_end; i++, idx++)
1494 for (; i < run_end; i++, idx++) {
1496 clipped_offset = av_clip(offset[2], -155, 100);
1497 if (offset[2] != clipped_offset) {
1499 "If you heard an audible artifact, there may be a bug in the decoder. " 1500 "Clipped intensity stereo position (%d -> %d)",
1501 offset[2], clipped_offset);
1504 sf[idx] = 100 - clipped_offset;
1509 }
else if (band_type[idx] ==
NOISE_BT) {
1510 for (; i < run_end; i++, idx++) {
1511 if (noise_flag-- > 0)
1515 clipped_offset = av_clip(offset[1], -100, 155);
1516 if (offset[1] != clipped_offset) {
1518 "If you heard an audible artifact, there may be a bug in the decoder. " 1519 "Clipped noise gain (%d -> %d)",
1520 offset[1], clipped_offset);
1523 sf[idx] = -(100 + clipped_offset);
1529 for (; i < run_end; i++, idx++) {
1531 if (offset[0] > 255
U) {
1533 "Scalefactor (%d) out of range.\n", offset[0]);
1537 sf[idx] = -offset[0];
1552 const uint16_t *swb_offset,
int num_swb)
1557 if (pulse_swb >= num_swb)
1559 pulse->
pos[0] = swb_offset[pulse_swb];
1561 if (pulse->
pos[0] >= swb_offset[num_swb])
1564 for (i = 1; i < pulse->
num_pulse; i++) {
1566 if (pulse->
pos[i] >= swb_offset[num_swb])
1581 int w,
filt, i, coef_len, coef_res, coef_compress;
1588 for (filt = 0; filt < tns->
n_filt[
w]; filt++) {
1592 if ((tns->
order[w][filt] =
get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
1594 "TNS filter order %d is greater than maximum %d.\n",
1595 tns->
order[w][filt], tns_max_order);
1599 if (tns->
order[w][filt]) {
1602 coef_len = coef_res + 3 - coef_compress;
1603 tmp2_idx = 2 * coef_compress + coef_res;
1626 if (ms_present == 1) {
1627 for (idx = 0; idx < max_idx; idx++)
1629 }
else if (ms_present == 2) {
1648 int pulse_present,
const Pulse *pulse,
1652 int i, k,
g, idx = 0;
1658 memset(coef + g * 128 + offsets[ics->
max_sfb], 0,
1664 for (i = 0; i < ics->
max_sfb; i++, idx++) {
1665 const unsigned cbt_m1 = band_type[idx] - 1;
1667 int off_len = offsets[i + 1] - offsets[i];
1671 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1672 memset(cfo, 0, off_len *
sizeof(*cfo));
1674 }
else if (cbt_m1 ==
NOISE_BT - 1) {
1675 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1681 for (k = 0; k < off_len; k++) {
1691 band_energy = ac->
fdsp->scalarproduct_fixed(cfo, cfo, off_len);
1696 scale = sf[idx] / sqrtf(band_energy);
1708 switch (cbt_m1 >> 1) {
1710 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1720 cb_idx = cb_vector_idx[code];
1724 cf =
VMUL4(cf, vq, cb_idx, sf + idx);
1731 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1743 cb_idx = cb_vector_idx[code];
1744 nnz = cb_idx >> 8 & 15;
1750 cf =
VMUL4S(cf, vq, cb_idx, bits, sf + idx);
1757 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1767 cb_idx = cb_vector_idx[code];
1771 cf =
VMUL2(cf, vq, cb_idx, sf + idx);
1779 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1791 cb_idx = cb_vector_idx[code];
1792 nnz = cb_idx >> 8 & 15;
1793 sign = nnz ?
SHOW_UBITS(
re, gb, nnz) << (cb_idx >> 12) : 0;
1798 cf =
VMUL2S(cf, vq, cb_idx, sign, sf + idx);
1805 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1811 uint32_t *icf = (uint32_t *) cf;
1831 cb_idx = cb_vector_idx[code];
1837 for (j = 0; j < 2; j++) {
1872 unsigned v = ((
const uint32_t*)vq)[cb_idx & 15];
1873 *icf++ = (bits & 1
U<<31) | v;
1892 if (pulse_present) {
1894 for (i = 0; i < pulse->
num_pulse; i++) {
1896 while (offsets[idx + 1] <= pulse->
pos[i])
1898 if (band_type[idx] !=
NOISE_BT && sf[idx]) {
1902 ico = co + (co > 0 ? -ico : ico);
1904 coef_base[ pulse->
pos[i] ] = ico;
1908 ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico);
1910 coef_base[ pulse->
pos[i] ] =
cbrtf(fabsf(ico)) * ico * sf[idx];
1921 for (i = 0; i < ics->
max_sfb; i++, idx++) {
1922 const unsigned cbt_m1 = band_type[idx] - 1;
1923 int *cfo = coef + offsets[i];
1924 int off_len = offsets[i + 1] - offsets[i];
1928 for (group = 0; group < (
int)g_len; group++, cfo+=128) {
1957 k < sce->ics.swb_offset[sfb + 1];
1974 static const uint8_t gain_mode[4][3] = {
1986 for (bd = 0; bd < max_band; bd++) {
1987 for (wd = 0; wd < gain_mode[
mode][0]; wd++) {
1989 for (ad = 0; ad < adjust_num; ad++) {
1990 skip_bits(gb, 4 + ((wd == 0 && gain_mode[mode][1])
1992 : gain_mode[mode][2]));
2013 int global_gain, eld_syntax, er_syntax, pulse_present = 0;
2029 if (!common_window && !scale_flag) {
2044 if (!eld_syntax && (pulse_present =
get_bits1(gb))) {
2047 "Pulse tool not allowed in eight short sequence.\n");
2053 "Pulse data corrupt or invalid.\n");
2059 if (tns->
present && !er_syntax) {
2073 if (tns->
present && er_syntax) {
2102 int g, i, group, idx = 0;
2105 for (i = 0; i < ics->
max_sfb; i++, idx++) {
2110 for (group = 0; group < ics->
group_len[
g]; group++) {
2111 ac->
fdsp->butterflies_fixed(ch0 + group * 128 + offsets[i],
2112 ch1 + group * 128 + offsets[i],
2113 offsets[i+1] - offsets[i]);
2115 for (group = 0; group < ics->
group_len[
g]; group++) {
2117 ch1 + group * 128 + offsets[i],
2118 offsets[i+1] - offsets[i]);
2142 int g, group, i, idx = 0;
2146 for (i = 0; i < ics->
max_sfb;) {
2150 for (; i < bt_run_end; i++, idx++) {
2151 c = -1 + 2 * (sce1->
band_type[idx] - 14);
2153 c *= 1 - 2 * cpe->
ms_mask[idx];
2154 scale = c * sce1->
sf[idx];
2155 for (group = 0; group < ics->
group_len[
g]; group++)
2158 coef0 + group * 128 + offsets[i],
2161 offsets[i + 1] - offsets[i]);
2164 coef0 + group * 128 + offsets[i],
2166 offsets[i + 1] - offsets[i]);
2171 idx += bt_run_end - i;
2187 int i, ret, common_window, ms_present = 0;
2190 common_window = eld_syntax ||
get_bits1(gb);
2191 if (common_window) {
2202 if (ms_present == 3) {
2205 }
else if (ms_present)
2208 if ((ret =
decode_ics(ac, &cpe->
ch[0], gb, common_window, 0)))
2210 if ((ret =
decode_ics(ac, &cpe->
ch[1], gb, common_window, 0)))
2213 if (common_window) {
2227 1.09050773266525765921,
2228 1.18920711500272106672,
2266 scale = cce_scale[
get_bits(gb, 2)];
2272 for (c = 0; c < num_gain; c++) {
2279 gain = cge ?
get_vlc2(gb, vlc_scalefactors.
table, 7, 3) - 60: 0;
2280 gain_cache =
GET_GAIN(scale, gain);
2282 if ((abs(gain_cache)-1024) >> 3 > 30)
2287 coup->
gain[
c][0] = gain_cache;
2290 for (sfb = 0; sfb < sce->
ics.
max_sfb; sfb++, idx++) {
2303 if ((abs(gain_cache)-1024) >> 3 > 30)
2308 coup->
gain[
c][idx] = gain_cache;
2326 int num_excl_chan = 0;
2329 for (i = 0; i < 7; i++)
2333 return num_excl_chan / 7;
2345 int drc_num_bands = 1;
2366 for (i = 0; i < drc_num_bands; i++) {
2379 for (i = 0; i < drc_num_bands; i++) {
2390 int i, major, minor;
2397 for(i=0; i+1<
sizeof(
buf) && len>=8; i++, len-=8)
2404 if (sscanf(buf,
"libfaac %d.%d", &major, &minor) == 2){
2441 "SBR with 960 frame length");
2498 for (filt = 0; filt < tns->
n_filt[
w]; filt++) {
2510 if ((size = end - start) <= 0)
2522 for (m = 0; m <
size; m++, start += inc)
2523 for (i = 1; i <=
FFMIN(m, order); i++)
2527 for (m = 0; m <
size; m++, start += inc) {
2528 tmp[0] = coef[
start];
2529 for (i = 1; i <=
FFMIN(m, order); i++)
2530 coef[start] +=
AAC_MUL26(tmp[i], lpc[i - 1]);
2531 for (i = order; i > 0; i--)
2532 tmp[i] = tmp[i - 1];
2554 memset(in, 0, 448 *
sizeof(*in));
2561 memset(in + 1024 + 576, 0, 448 *
sizeof(*in));
2578 int16_t num_samples = 2048;
2580 if (ltp->
lag < 1024)
2581 num_samples = ltp->
lag + 1024;
2582 for (i = 0; i < num_samples; i++)
2584 memset(&predTime[i], 0, (2048 - i) *
sizeof(*predTime));
2593 for (i = offsets[sfb]; i < offsets[sfb + 1]; i++)
2611 memcpy(saved_ltp, saved, 512 *
sizeof(*saved_ltp));
2612 memset(saved_ltp + 576, 0, 448 *
sizeof(*saved_ltp));
2615 for (i = 0; i < 64; i++)
2618 memcpy(saved_ltp, ac->
buf_mdct + 512, 448 *
sizeof(*saved_ltp));
2619 memset(saved_ltp + 576, 0, 448 *
sizeof(*saved_ltp));
2622 for (i = 0; i < 64; i++)
2627 for (i = 0; i < 512; i++)
2654 for (i = 0; i < 1024; i += 128)
2659 for (i=0; i<1024; i++)
2660 buf[i] = (buf[i] + 4) >> 3;
2674 memcpy( out, saved, 448 *
sizeof(*out));
2682 memcpy( out + 448 + 4*128, temp, 64 *
sizeof(*out));
2685 memcpy( out + 576, buf + 64, 448 *
sizeof(*out));
2691 memcpy( saved, temp + 64, 64 *
sizeof(*saved));
2695 memcpy( saved + 448, buf + 7*128 + 64, 64 *
sizeof(*saved));
2697 memcpy( saved, buf + 512, 448 *
sizeof(*saved));
2698 memcpy( saved + 448, buf + 7*128 + 64, 64 *
sizeof(*saved));
2700 memcpy( saved, buf + 512, 512 *
sizeof(*saved));
2723 for (i = 0; i < 8; i++)
2740 memcpy( out, saved, 420 *
sizeof(*out));
2748 memcpy( out + 420 + 4*120, temp, 60 *
sizeof(*out));
2751 memcpy( out + 540, buf + 60, 420 *
sizeof(*out));
2757 memcpy( saved, temp + 60, 60 *
sizeof(*saved));
2761 memcpy( saved + 420, buf + 7*120 + 60, 60 *
sizeof(*saved));
2763 memcpy( saved, buf + 480, 420 *
sizeof(*saved));
2764 memcpy( saved + 420, buf + 7*120 + 60, 60 *
sizeof(*saved));
2766 memcpy( saved, buf + 480, 480 *
sizeof(*saved));
2785 for (i = 0; i < 1024; i++)
2786 buf[i] = (buf[i] + 2) >> 2;
2792 memcpy(out, saved, 192 *
sizeof(*out));
2794 memcpy( out + 320, buf + 64, 192 *
sizeof(*out));
2800 memcpy(saved, buf + 256, 256 *
sizeof(*saved));
2811 const int n2 = n >> 1;
2812 const int n4 = n >> 2;
2821 for (i = 0; i < n2; i+=2) {
2823 temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] =
temp;
2824 temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] =
temp;
2834 for (i = 0; i < 1024; i++)
2835 buf[i] = (buf[i] + 1) >> 1;
2838 for (i = 0; i <
n; i+=2) {
2848 for (i = n4; i < n2; i ++) {
2849 out[i - n4] =
AAC_MUL31( buf[ n2 - 1 - i] , window[i - n4]) +
2850 AAC_MUL31( saved[ i + n2] , window[i + n - n4]) +
2851 AAC_MUL31(-saved[n + n2 - 1 - i] , window[i + 2*n - n4]) +
2852 AAC_MUL31(-saved[ 2*n + n2 + i] , window[i + 3*n - n4]);
2854 for (i = 0; i < n2; i ++) {
2855 out[n4 + i] =
AAC_MUL31( buf[ i] , window[i + n2 - n4]) +
2856 AAC_MUL31(-saved[ n - 1 - i] , window[i + n2 + n - n4]) +
2857 AAC_MUL31(-saved[ n + i] , window[i + n2 + 2*n - n4]) +
2858 AAC_MUL31( saved[2*n + n - 1 - i] , window[i + n2 + 3*n - n4]);
2860 for (i = 0; i < n4; i ++) {
2861 out[n2 + n4 + i] =
AAC_MUL31( buf[ i + n2] , window[i + n - n4]) +
2862 AAC_MUL31(-saved[n2 - 1 - i] , window[i + 2*n - n4]) +
2863 AAC_MUL31(-saved[n + n2 + i] , window[i + 3*n - n4]);
2867 memmove(saved + n, saved, 2 * n *
sizeof(*saved));
2868 memcpy( saved, buf, n *
sizeof(*saved));
2891 if (coup->
type[c] == type && coup->
id_select[c] == elem_id) {
2893 apply_coupling_method(ac, &cc->
ch[0], cce, index);
2898 apply_coupling_method(ac, &cc->
ch[1], cce, index++);
2926 for (type = 3; type >= 0; type--) {
2966 for(j = 0; j<samples; j++){
2967 che->
ch[0].
ret[j] = (
int32_t)av_clip64((int64_t)che->
ch[0].
ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
2969 che->
ch[1].
ret[j] = (
int32_t)av_clip64((int64_t)che->
ch[1].
ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
2985 uint8_t layout_map[MAX_ELEM_ID*4][3];
2986 int layout_map_tags, ret;
2994 "More than one AAC RDB per ADTS frame");
3017 layout_map_tags = 2;
3018 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
3020 layout_map[0][1] = 0;
3021 layout_map[1][1] = 1;
3068 if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
3076 if (!(che=
get_che(ac, elem_type, elem_id))) {
3078 "channel element %d.%d is not allocated\n",
3079 elem_type, elem_id);
3085 switch (elem_type) {
3122 int samples = 0, multiplier, audio_found = 0, pce_found = 0;
3123 int is_dmono, sce_count = 0;
3124 int payload_alignment;
3162 if (!(che=
get_che(ac, elem_type, elem_id))) {
3164 elem_type, elem_id);
3172 switch (elem_type) {
3199 uint8_t layout_map[MAX_ELEM_ID*4][3];
3203 if (pce_found && !pushed) {
3216 "Not evaluating a further program_config_element as this construct is dubious at best.\n");
3247 che_prev_type = elem_type;
3266 samples <<= multiplier;
3270 if (ac->
oc[1].
status && audio_found) {
3290 *got_frame_ptr = !!samples;
3293 is_dmono = ac->
dmono_mode && sce_count == 2 &&
3309 int *got_frame_ptr,
AVPacket *avpkt)
3313 int buf_size = avpkt->
size;
3318 int new_extradata_size;
3321 &new_extradata_size);
3322 int jp_dualmono_size;
3327 if (new_extradata && 0) {
3334 memcpy(avctx->
extradata, new_extradata, new_extradata_size);
3345 if (jp_dualmono && jp_dualmono_size > 0)
3350 if (INT_MAX / 8 <= buf_size)
3370 for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
3371 if (buf[buf_offset])
3374 return buf_size > buf_offset ? buf_consumed : buf_size;
3383 for (type = 0; type < 4; type++) {
3384 if (ac->
che[type][i])
3423 #define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM 3425 {
"dual_mono_mode",
"Select the channel to decode for dual mono",
int predictor_initialized
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
Apply AAC-Main style frequency domain prediction.
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
Conduct IMDCT and windowing.
static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
Apply the long term prediction.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_pulses(Pulse *pulse, GetBitContext *gb, const uint16_t *swb_offset, int num_swb)
Decode pulse data; reference: table 4.7.
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
float ff_aac_kbd_short_120[120]
This structure describes decoded (raw) audio or video data.
static void flush(AVCodecContext *avctx)
static const int8_t tags_per_config[16]
static int * DEC_UPAIR(int *dst, unsigned idx, unsigned sign)
static AVOnce aac_table_init
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
#define LIBAVUTIL_VERSION_INT
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
static const float cce_scale[]
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
#define AACDEC_FLAGS
AVOptions for Japanese DTV specific extensions (ADTS only)
static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce)
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
static void aacdec_init(AACContext *ac)
static int * DEC_SQUAD(int *dst, unsigned idx)
static int decode_audio_specific_config_gb(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, GetBitContext *gb, int get_bit_alignment, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
ChannelElement * che[4][MAX_ELEM_ID]
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
const char * av_default_item_name(void *ptr)
Return the context name.
INTFLOAT * ret
PCM output.
static void update_ltp(AACContext *ac, SingleChannelElement *sce)
Update the LTP buffer for next frame.
static void vector_pow43(int *coefs, int len)
INTFLOAT sf[120]
scalefactors
#define AV_EF_BITSTREAM
detect bitstream specification deviations
static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, GetBitContext *gb, int get_bit_alignment, MPEG4AudioConfig *m4ac, int channel_config)
Decode GA "General Audio" specific configuration; reference: table 4.1.
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
static void apply_independent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
static void subband_scale(int *dst, int *src, int scale, int offset, int len)
Dynamic Range Control - decoded from the bitstream but not processed further.
static av_cold int che_configure(AACContext *ac, enum ChannelPosition che_pos, int type, int id, int *channels)
Check for the channel element in the current channel position configuration.
static VLC vlc_scalefactors
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
#define FF_PROFILE_AAC_HE_V2
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
static int output_configure(AACContext *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.
static void decode_channel_map(uint8_t layout_map[][3], enum ChannelPosition type, GetBitContext *gb, int n)
Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit...
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static int aac_decode_er_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, GetBitContext *gb)
Spectral data are scaled white noise not coded in the bitstream.
static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
Decode coupling_channel_element; reference: table 4.8.
static av_always_inline int lcg_random(unsigned previous_val)
linear congruential pseudorandom number generator
int band_incr
Number of DRC bands greater than 1 having DRC info.
const uint8_t ff_aac_num_swb_128[]
void ff_cbrt_tableinit(void)
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
N Error Resilient Long Term Prediction.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
Decode Individual Channel Stream info; reference: table 4.6.
enum AVSampleFormat sample_fmt
audio sample format
float ff_aac_kbd_long_960[960]
uint8_t layout_map[MAX_ELEM_ID *4][3]
Output configuration under trial specified by an inband PCE.
const uint16_t *const ff_swb_offset_480[]
#define FF_DEBUG_PICT_INFO
SingleChannelElement ch[2]
const uint16_t *const ff_swb_offset_512[]
const uint8_t ff_tns_max_bands_480[]
static av_cold int end(AVCodecContext *avctx)
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats...
N Error Resilient Low Delay.
static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, ChannelElement *che, enum RawDataBlockType elem_type)
Decode extension data (incomplete); reference: table 4.51.
const uint8_t ff_aac_scalefactor_bits[121]
CouplingPoint
The point during decoding at which channel coupling is applied.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int num_coupled
number of target elements
#define u(width, name, range_min, range_max)
#define AV_CH_LOW_FREQUENCY
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
static av_cold int aac_decode_init(AVCodecContext *avctx)
static int get_bits_count(const GetBitContext *s)
static int count_channels(uint8_t(*layout)[3], int tags)
Scalefactor data are intensity stereo positions (in phase).
#define AV_LOG_VERBOSE
Detailed information.
static int sample_rate_idx(int rate)
static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
int id_select[8]
element id
const float *const ff_aac_codebook_vector_vals[]
static av_always_inline int fixed_sqrt(int x, int bits)
Calculate the square root.
N Error Resilient Low Complexity.
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
Output configuration set in a global header but not yet locked.
static void spectral_to_sample(AACContext *ac, int samples)
Convert spectral data to samples, applying all supported tools as appropriate.
static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
static int get_bits_left(GetBitContext *gb)
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
void AAC_RENAME() ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, INTFLOAT *L, INTFLOAT *R)
Apply one SBR element to one AAC element.
uint32_t ff_cbrt_tab[1<< 13]
static void pop_output_configuration(AACContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked...
static int decode_fill(AACContext *ac, GetBitContext *gb, int len)
#define UPDATE_CACHE(name, gb)
PredictorState predictor_state[MAX_PREDICTORS]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
const uint8_t ff_aac_num_swb_960[]
static void relative_align_get_bits(GetBitContext *gb, int reference_position)
SpectralBandReplication sbr
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
const uint16_t *const ff_swb_offset_120[]
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
const uint8_t ff_aac_num_swb_1024[]
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, int sync_extension)
Parse MPEG-4 systems extradata from a potentially unaligned GetBitContext to retrieve audio configura...
static void imdct_and_windowing_960(AACContext *ac, SingleChannelElement *sce)
Conduct IMDCT and windowing.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
float ff_aac_kbd_long_1024[1024]
int flags
AV_CODEC_FLAG_*.
static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, GetBitContext *gb, MPEG4AudioConfig *m4ac, int channel_config)
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
void(* apply_ltp)(AACContext *ac, SingleChannelElement *sce)
static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID], uint8_t(*layout_map)[3], int offset, uint64_t left, uint64_t right, int pos)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
uint8_t max_sfb
number of scalefactor bands per group
const float ff_aac_eld_window_512[1920]
static const uint8_t offset[127][2]
#define CLOSE_READER(name, gb)
int num_swb
number of scalefactor window bands
static int count_paired_channels(uint8_t(*layout_map)[3], int tags, int pos, int *current)
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
Output configuration locked in place.
float ff_aac_pow2sf_tab[428]
uint64_t channel_layout
Audio channel layout.
#define SKIP_BITS(name, gb, num)
int warned_remapping_once
INTFLOAT ret_buf[2048]
PCM output buffer.
N Error Resilient Scalable.
static SDL_Window * window
static void reset_predictor_group(PredictorState *ps, int group_num)
void(* apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
static ChannelElement * get_che(AACContext *ac, int type, int elem_id)
enum WindowSequence window_sequence[2]
INTFLOAT ltp_state[3072]
time signal for LTP
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
const uint8_t ff_aac_num_swb_512[]
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
int predictor_reset_group
static int frame_configure_elements(AVCodecContext *avctx)
int dyn_rng_ctl[17]
DRC magnitude information.
static const INTFLOAT ltp_coef[8]
static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, int ms_present)
Decode Mid/Side data; reference: table 4.54.
static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
intensity stereo decoding; reference: 4.6.8.2.3
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
void ff_aacdec_init_mips(AACContext *c)
int AAC_RENAME() ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int crc, int cnt, int id_aac)
Decode one SBR element.
#define LAST_SKIP_BITS(name, gb, num)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static av_cold void aac_static_table_init(void)
void AAC_RENAME() ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
Close one SBR context.
static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, enum RawDataBlockType type, int elem_id, enum CouplingPoint coupling_point, void(*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
channel coupling transformation interface
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_EF_EXPLODE
abort decoding on minor error detection
const uint8_t ff_tns_max_bands_1024[]
#define GET_VLC(code, name, gb, table, bits, max_depth)
If the vlc code is invalid and max_depth=1, then no bits will be removed.
static int AAC_RENAME() compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize)
Levinson-Durbin recursion.
#define AV_CH_FRONT_CENTER
static void decode_ltp(LongTermPrediction *ltp, GetBitContext *gb, uint8_t max_sfb)
Decode Long Term Prediction data; reference: table 4.xx.
static int aac_decode_frame_int(AVCodecContext *avctx, void *data, int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
static void apply_dependent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], GetBitContext *gb, const INTFLOAT sf[120], int pulse_present, const Pulse *pulse, const IndividualChannelStream *ics, enum BandType band_type[120])
Decode spectral data; reference: table 4.50.
void AAC_RENAME() ff_aac_sbr_init(void)
Initialize SBR.
int pce_instance_tag
Indicates with which program the DRC info is associated.
N (code in SoC repo) Scalable Sample Rate.
static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out, INTFLOAT *in, IndividualChannelStream *ics)
Apply windowing and MDCT to obtain the spectral coefficient from the predicted sample by LTP...
static const INTFLOAT *const tns_tmp2_map[4]
#define SHOW_UBITS(name, gb, num)
static int push_output_configuration(AACContext *ac)
Save current output configuration if and only if it has been locked.
#define FF_ARRAY_ELEMS(a)
#define AV_CH_FRONT_RIGHT_OF_CENTER
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
static void reset_all_predictors(PredictorState *ps)
static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
Skip data_stream_element; reference: table 4.10.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int ch_select[8]
[0] shared list of gains; [1] list of gains for right channel; [2] list of gains for left channel; [3...
int frame_size
Number of samples per channel in an audio frame.
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
void(* subband_scale)(int *dst, int *src, int scale, int offset, int len)
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
#define AV_LOG_INFO
Standard information.
int warned_num_aac_frames
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
typedef void(RENAME(mix_any_func_type))
#define AAC_INIT_VLC_STATIC(num, size)
int sample_rate
samples per second
float ff_aac_kbd_short_128[128]
void AAC_RENAME() ff_sine_window_init(INTFLOAT *window, int n)
Generate a sine window.
static const AVOption options[]
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
static int decode_scalefactors(AACContext *ac, INTFLOAT sf[120], GetBitContext *gb, unsigned int global_gain, IndividualChannelStream *ics, enum BandType band_type[120], int band_type_run_end[120])
Decode scalefactors; reference: table 4.47.
static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
Decode a channel_pair_element; reference: table 4.4.
static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4...
main external API structure.
int skip_samples_multiplier
#define NOISE_PRE_BITS
length of preamble
#define OPEN_READER(name, gb)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
IndividualChannelStream ics
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
static av_always_inline float cbrtf(float x)
void AAC_RENAME() ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr, int id_aac)
Initialize one SBR context.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static unsigned int get_bits1(GetBitContext *s)
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)
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
static av_cold int aac_decode_close(AVCodecContext *avctx)
static void skip_bits(GetBitContext *s, int n)
static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
static uint64_t sniff_channel_order(uint8_t(*layout_map)[3], int tags)
const uint16_t *const ff_swb_offset_960[]
static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc, GetBitContext *gb)
Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4...
static void noise_scale(int *coefs, int scale, int band_energy, int len)
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, uint8_t(*layout_map)[3], GetBitContext *gb, int byte_align_ref)
Decode program configuration element; reference: table 4.2.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
OCStatus
Output configuration status.
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
N Error Resilient Bit-Sliced Arithmetic Coding.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
const uint32_t ff_aac_scalefactor_code[121]
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
Output configuration under trial specified by a frame header.
static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
const uint8_t ff_tns_max_bands_128[]
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float *in, float *prev, int ch)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static const int8_t filt[NUMTAPS]
int band_type_run_end[120]
band type run end points
static int decode_band_types(AACContext *ac, enum BandType band_type[120], int band_type_run_end[120], GetBitContext *gb, IndividualChannelStream *ics)
Decode band types (section_data payload); reference: table 4.46.
#define AV_CH_BACK_CENTER
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
Allocate and initialize a fixed DSP context.
static VLC vlc_spectral[11]
Scalefactor data are intensity stereo positions (out of phase).
N Error Resilient Enhanced Low Delay.
static int set_default_channel_config(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...
INTFLOAT coef[8][4][TNS_MAX_ORDER]
const uint8_t ff_aac_num_swb_120[]
DynamicRangeControl che_drc
static av_always_inline void reset_predict_state(PredictorState *ps)
OutputConfiguration oc[2]
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
const uint8_t ff_aac_pred_sfb_max[]
uint8_t prediction_used[41]
const float ff_aac_eld_window_480[1800]
INTFLOAT saved[1536]
overlap
Single Channel Element - used for both SCE and LFE elements.
const uint8_t ff_aac_num_swb_480[]
const uint16_t *const ff_swb_offset_1024[]
void(* vector_pow43)(int *coefs, int len)
Individual Channel Stream.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
const uint16_t *const ff_aac_codebook_vector_idx[]
void(* update_ltp)(AACContext *ac, SingleChannelElement *sce)
static void ff_aac_tableinit(void)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
channel element - generic struct for SCE/CPE/CCE/LFE
static void decode_gain_control(SingleChannelElement *sce, GetBitContext *gb)
static int decode_ics(AACContext *ac, SingleChannelElement *sce, GetBitContext *gb, int common_window, int scale_flag)
Decode an individual_channel_stream payload; reference: table 4.44.
#define FF_DEBUG_STARTCODE
const uint8_t ff_tns_max_bands_512[]
Scalefactors and spectral data are all zero.
int channels
number of audio channels
static int * DEC_SPAIR(int *dst, unsigned idx)
struct AVCodecInternal * internal
Private context used for internal data.
const uint8_t ff_mpeg4audio_channels[8]
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
static const uint8_t * align_get_bits(GetBitContext *s)
#define FF_PROFILE_AAC_HE
enum BandType band_type[128]
band types
static int decode_dynamic_range(DynamicRangeControl *che_drc, GetBitContext *gb)
Decode dynamic range information; reference: table 4.52.
#define AV_CH_FRONT_RIGHT
#define POW_SF2_ZERO
ff_aac_pow2sf_tab index corresponding to pow(2, 0);
static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce)
void(* windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out, INTFLOAT *in, IndividualChannelStream *ics)
int sbr
-1 implicit, 1 presence
static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
Mid/Side stereo decoding; reference: 4.6.8.1.3.
void(* imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce)
#define FFSWAP(type, a, b)
int ps
-1 implicit, 1 presence
int8_t used[MAX_LTP_LONG_SFB]
const uint16_t *const ff_swb_offset_128[]
static const AVClass aac_decoder_class
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
This structure stores compressed data.
mode
Use these values in ebur128_init (or'ed).
int nb_samples
number of audio samples (per channel) described by this frame
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
void AAC_RENAME() ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
static int * DEC_UQUAD(int *dst, unsigned idx, unsigned sign)
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
static const uint8_t aac_channel_layout_map[16][5][3]
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...