Go to the documentation of this file.
101 enum OCStatus oc_type,
int get_new_frame);
103 #define overread_err "Input buffer exhausted before END element found\n"
108 for (
i = 0;
i < tags;
i++) {
111 sum += (1 + (syn_ele ==
TYPE_CPE)) *
202 uint8_t (*layout_map)[3],
int offset, uint64_t
left,
203 uint64_t right,
int pos, uint64_t *
layout)
207 .av_position =
left | right,
209 .elem_id = layout_map[
offset][1],
212 if (e2c_vec[
offset].av_position != UINT64_MAX)
220 .elem_id = layout_map[
offset][1],
224 .av_position = right,
226 .elem_id = layout_map[
offset + 1][1],
229 if (
left != UINT64_MAX)
232 if (right != UINT64_MAX)
242 int num_pos_channels = 0;
246 for (
i = *current;
i < tags;
i++) {
247 if (layout_map[
i][2] !=
pos)
257 num_pos_channels += 2;
268 return num_pos_channels;
271 #define PREFIX_FOR_22POINT2 (AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_LOW_FREQUENCY_2)
274 int i, n, total_non_cc_elements;
276 int num_front_channels, num_side_channels, num_back_channels;
285 if (num_front_channels < 0)
289 if (num_side_channels < 0)
293 if (num_back_channels < 0)
296 if (num_side_channels == 0 && num_back_channels >= 4) {
297 num_side_channels = 2;
298 num_back_channels -= 2;
302 if (num_front_channels & 1) {
306 .elem_id = layout_map[
i][1],
311 num_front_channels--;
313 if (num_front_channels >= 4) {
318 num_front_channels -= 2;
320 if (num_front_channels >= 2) {
325 num_front_channels -= 2;
327 while (num_front_channels >= 2) {
332 num_front_channels -= 2;
335 if (num_side_channels >= 2) {
340 num_side_channels -= 2;
342 while (num_side_channels >= 2) {
347 num_side_channels -= 2;
350 while (num_back_channels >= 4) {
355 num_back_channels -= 2;
357 if (num_back_channels >= 2) {
362 num_back_channels -= 2;
364 if (num_back_channels) {
368 .elem_id = layout_map[
i][1],
380 .elem_id = layout_map[
i][1],
390 .elem_id = layout_map[
i][1],
400 .elem_id = layout_map[
i][1],
409 for (
int j = 0; j < tags; j++) {
410 if (layout_map[j][0] != reference_layout_map[j][0] ||
411 layout_map[j][2] != reference_layout_map[j][2])
412 goto end_of_layout_definition;
417 .syn_ele = layout_map[
i][0],
418 .elem_id = layout_map[
i][1],
419 .aac_position = layout_map[
i][2]
433 .syn_ele = layout_map[
i][0],
434 .elem_id = layout_map[
i][1],
435 .aac_position = layout_map[
i][2]
444 .syn_ele = layout_map[
i][0],
445 .elem_id = layout_map[
i][1],
446 .aac_position = layout_map[
i][2]
450 .syn_ele = layout_map[
i][0],
451 .elem_id = layout_map[
i][1],
452 .aac_position = layout_map[
i][2]
461 end_of_layout_definition:
463 total_non_cc_elements = n =
i;
481 for (
i = 1;
i < n;
i++)
482 if (e2c_vec[
i - 1].av_position > e2c_vec[
i].av_position) {
491 for (
i = 0;
i < total_non_cc_elements;
i++) {
507 ac->
oc[0] = ac->
oc[1];
520 ac->
oc[1] = ac->
oc[0];
535 enum OCStatus oc_type,
int get_new_frame)
541 uint8_t type_counts[
TYPE_END] = { 0 };
544 memcpy(ac->
oc[1].
layout_map, layout_map, tags *
sizeof(layout_map[0]));
547 for (
i = 0;
i < tags;
i++) {
548 int type = layout_map[
i][0];
549 int id = layout_map[
i][1];
558 #if FF_API_OLD_CHANNEL_LAYOUT
567 for (
i = 0;
i < tags;
i++) {
568 int type = layout_map[
i][0];
569 int id = layout_map[
i][1];
570 int iid = id_map[
type][
id];
571 int position = layout_map[
i][2];
615 for (j = 0; j <= 1; j++) {
630 uint8_t (*layout_map)[3],
634 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
635 channel_config > 13) {
637 "invalid default channel configuration (%d)\n",
643 *tags *
sizeof(*layout_map));
661 " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
686 &layout_map_tags, 2) < 0)
705 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
707 layout_map[0][1] = 0;
708 layout_map[1][1] = 1;
749 "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n",
771 "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n",
834 layout_map[0][0] = syn_ele;
836 layout_map[0][2] =
type;
842 int reference_position) {
854 uint8_t (*layout_map)[3],
857 int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc;
867 "Sample rate index in program config element does not "
868 "match the sample rate index configured by the container.\n");
885 if (
get_bits_left(gb) < 5 * (num_front + num_side + num_back + num_cc) + 4 *(num_lfe + num_assoc_data + num_cc)) {
925 int get_bit_alignment,
929 int extension_flag,
ret, ep_config, res_flags;
957 if (channel_config == 0) {
959 tags =
decode_pce(avctx, m4ac, layout_map, gb, get_bit_alignment);
964 &tags, channel_config)))
970 }
else if (m4ac->
sbr == 1 && m4ac->
ps == -1)
976 if (extension_flag) {
989 "AAC data resilience (flags %x)",
1005 "epConfig %d", ep_config);
1017 int ret, ep_config, res_flags;
1020 const int ELDEXT_TERM = 0;
1035 "AAC data resilience (flags %x)",
1046 while (
get_bits(gb, 4) != ELDEXT_TERM) {
1050 if (
len == 15 + 255)
1060 &tags, channel_config)))
1069 "epConfig %d", ep_config);
1091 int get_bit_alignment,
1105 "invalid sampling rate index %d\n",
1113 "invalid low delay sampling rate index %d\n",
1139 "Audio object type %s%d",
1140 m4ac->
sbr == 1 ?
"SBR+" :
"",
1146 "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
1157 const uint8_t *
data, int64_t bit_size,
1163 if (bit_size < 0 || bit_size > INT_MAX) {
1168 ff_dlog(avctx,
"audio specific config size %d\n", (
int)bit_size >> 3);
1169 for (
i = 0; i < bit_size >> 3;
i++)
1189 union {
unsigned u;
int s; } v = { previous_val * 1664525
u + 1013904223 };
1202 if (92017 <= rate)
return 0;
1203 else if (75132 <= rate)
return 1;
1204 else if (55426 <= rate)
return 2;
1205 else if (46009 <= rate)
return 3;
1206 else if (37566 <= rate)
return 4;
1207 else if (27713 <= rate)
return 5;
1208 else if (23004 <= rate)
return 6;
1209 else if (18783 <= rate)
return 7;
1210 else if (13856 <= rate)
return 8;
1211 else if (11502 <= rate)
return 9;
1212 else if (9391 <= rate)
return 10;
1228 294 + 306 + 268 + 510 + 366 + 462];
1229 for (
unsigned i = 0,
offset = 0;
i < 11;
i++) {
1307 int layout_map_tags;
1398 "Invalid Predictor Reset Group.\n");
1444 "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
1457 for (
i = 0;
i < 7;
i++) {
1514 "Prediction is not allowed in AAC-LC.\n");
1519 "LTP in ER AAC LD not yet implemented.\n");
1531 "Number of scalefactor bands in group (%d) "
1532 "exceeds limit (%d).\n",
1559 while (k < ics->max_sfb) {
1560 uint8_t sect_end = k;
1562 int sect_band_type =
get_bits(gb, 4);
1563 if (sect_band_type == 12) {
1569 sect_end += sect_len_incr;
1574 if (sect_end > ics->
max_sfb) {
1576 "Number of bands (%d) exceeds limit (%d).\n",
1580 }
while (sect_len_incr == (1 <<
bits) - 1);
1581 for (; k < sect_end; k++) {
1582 band_type [idx] = sect_band_type;
1583 band_type_run_end[idx++] = sect_end;
1601 unsigned int global_gain,
1604 int band_type_run_end[120])
1612 int run_end = band_type_run_end[idx];
1613 if (band_type[idx] ==
ZERO_BT) {
1614 for (;
i < run_end;
i++, idx++)
1618 for (;
i < run_end;
i++, idx++) {
1621 if (
offset[2] != clipped_offset) {
1623 "If you heard an audible artifact, there may be a bug in the decoder. "
1624 "Clipped intensity stereo position (%d -> %d)",
1625 offset[2], clipped_offset);
1628 sf[idx] = 100 - clipped_offset;
1633 }
else if (band_type[idx] ==
NOISE_BT) {
1634 for (;
i < run_end;
i++, idx++) {
1635 if (noise_flag-- > 0)
1640 if (
offset[1] != clipped_offset) {
1642 "If you heard an audible artifact, there may be a bug in the decoder. "
1643 "Clipped noise gain (%d -> %d)",
1644 offset[1], clipped_offset);
1647 sf[idx] = -(100 + clipped_offset);
1653 for (;
i < run_end;
i++, idx++) {
1657 "Scalefactor (%d) out of range.\n",
offset[0]);
1676 const uint16_t *swb_offset,
int num_swb)
1681 if (pulse_swb >= num_swb)
1683 pulse->
pos[0] = swb_offset[pulse_swb];
1685 if (pulse->
pos[0] >= swb_offset[num_swb])
1690 if (pulse->
pos[
i] >= swb_offset[num_swb])
1705 int w,
filt,
i, coef_len, coef_res, coef_compress;
1718 "TNS filter order %d is greater than maximum %d.\n",
1726 coef_len = coef_res + 3 - coef_compress;
1727 tmp2_idx = 2 * coef_compress + coef_res;
1750 if (ms_present == 1) {
1751 for (idx = 0; idx < max_idx; idx++)
1753 }
else if (ms_present == 2) {
1772 int pulse_present,
const Pulse *pulse,
1776 int i, k,
g, idx = 0;
1789 const unsigned cbt_m1 = band_type[idx] - 1;
1795 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1796 memset(cfo, 0, off_len *
sizeof(*cfo));
1798 }
else if (cbt_m1 ==
NOISE_BT - 1) {
1799 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1802 for (k = 0; k < off_len; k++) {
1807 band_energy = ac->
fdsp->scalarproduct_fixed(cfo, cfo, off_len);
1813 for (k = 0; k < off_len; k++) {
1830 switch (cbt_m1 >> 1) {
1832 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1846 cf =
VMUL4(cf, vq, cb_idx, sf + idx);
1853 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1866 nnz = cb_idx >> 8 & 15;
1879 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1893 cf =
VMUL2(cf, vq, cb_idx, sf + idx);
1901 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1914 nnz = cb_idx >> 8 & 15;
1915 sign = nnz ?
SHOW_UBITS(
re, gb, nnz) << (cb_idx >> 12) : 0;
1920 cf =
VMUL2S(cf, vq, cb_idx, sign, sf + idx);
1927 for (group = 0; group < (
AAC_SIGNE)g_len; group++, cfo+=128) {
1933 uint32_t *icf = (uint32_t *) cf;
1948 if (cb_idx == 0x0000) {
1959 for (j = 0; j < 2; j++) {
1994 unsigned v = ((
const uint32_t*)vq)[cb_idx & 15];
1995 *icf++ = (
bits & 1
U<<31) | v;
2014 if (pulse_present) {
2020 if (band_type[idx] !=
NOISE_BT && sf[idx]) {
2024 ico = co + (co > 0 ? -ico : ico);
2026 coef_base[ pulse->
pos[
i] ] = ico;
2044 const unsigned cbt_m1 = band_type[idx] - 1;
2050 for (group = 0; group < (
int)g_len; group++, cfo+=128) {
2079 k < sce->ics.swb_offset[sfb + 1];
2096 static const uint8_t gain_mode[4][3] = {
2107 uint8_t max_band =
get_bits(gb, 2);
2108 for (bd = 0; bd < max_band; bd++) {
2109 for (wd = 0; wd < gain_mode[
mode][0]; wd++) {
2110 uint8_t adjust_num =
get_bits(gb, 3);
2111 for (ad = 0; ad < adjust_num; ad++) {
2114 : gain_mode[
mode][2]));
2135 int global_gain, eld_syntax, er_syntax, pulse_present = 0;
2151 if (!common_window && !scale_flag) {
2166 if (!eld_syntax && (pulse_present =
get_bits1(gb))) {
2169 "Pulse tool not allowed in eight short sequence.\n");
2175 "Pulse data corrupt or invalid.\n");
2181 if (tns->
present && !er_syntax) {
2195 if (tns->
present && er_syntax) {
2224 int g,
i, group, idx = 0;
2232 for (group = 0; group < ics->
group_len[
g]; group++) {
2233 ac->
fdsp->butterflies_fixed(ch0 + group * 128 +
offsets[
i],
2237 for (group = 0; group < ics->
group_len[
g]; group++) {
2264 int g, group,
i, idx = 0;
2272 for (;
i < bt_run_end;
i++, idx++) {
2277 for (group = 0; group < ics->
group_len[
g]; group++)
2293 idx += bt_run_end -
i;
2309 int i,
ret, common_window, ms_present = 0;
2312 common_window = eld_syntax ||
get_bits1(gb);
2313 if (common_window) {
2324 if (ms_present == 3) {
2327 }
else if (ms_present)
2335 if (common_window) {
2349 1.09050773266525765921,
2350 1.18920711500272106672,
2394 for (
c = 0;
c < num_gain;
c++) {
2404 if ((
abs(gain_cache)-1024) >> 3 > 30)
2409 coup->
gain[
c][0] = gain_cache;
2412 for (sfb = 0; sfb < sce->
ics.
max_sfb; sfb++, idx++) {
2425 if ((
abs(gain_cache)-1024) >> 3 > 30)
2430 coup->
gain[
c][idx] = gain_cache;
2448 int num_excl_chan = 0;
2451 for (
i = 0;
i < 7;
i++)
2455 return num_excl_chan / 7;
2467 int drc_num_bands = 1;
2488 for (
i = 0;
i < drc_num_bands;
i++) {
2501 for (
i = 0;
i < drc_num_bands;
i++) {
2519 for(
i=0;
i+1<
sizeof(buf) &&
len>=8;
i++,
len-=8)
2526 if (sscanf(buf,
"libfaac %d.%d", &
major, &
minor) == 2){
2563 "SBR with 960 frame length");
2614 int bottom, top, order, start, end,
size, inc;
2636 if ((
size = end - start) <= 0)
2648 for (m = 0; m <
size; m++, start += inc)
2649 for (
i = 1;
i <=
FFMIN(m, order);
i++)
2653 for (m = 0; m <
size; m++, start += inc) {
2654 tmp[0] = coef[start];
2655 for (
i = 1;
i <=
FFMIN(m, order);
i++)
2657 for (
i = order;
i > 0;
i--)
2680 memset(in, 0, 448 *
sizeof(*in));
2687 memset(in + 1024 + 576, 0, 448 *
sizeof(*in));
2704 int16_t num_samples = 2048;
2706 if (ltp->
lag < 1024)
2707 num_samples = ltp->
lag + 1024;
2708 for (
i = 0;
i < num_samples;
i++)
2710 memset(&predTime[
i], 0, (2048 -
i) *
sizeof(*predTime));
2737 memcpy(saved_ltp, saved, 512 *
sizeof(*saved_ltp));
2738 memset(saved_ltp + 576, 0, 448 *
sizeof(*saved_ltp));
2741 for (
i = 0;
i < 64;
i++)
2744 memcpy(saved_ltp, ac->
buf_mdct + 512, 448 *
sizeof(*saved_ltp));
2745 memset(saved_ltp + 576, 0, 448 *
sizeof(*saved_ltp));
2748 for (
i = 0;
i < 64;
i++)
2753 for (
i = 0;
i < 512;
i++)
2780 for (
i = 0;
i < 1024;
i += 128)
2785 for (
i=0;
i<1024;
i++)
2786 buf[
i] = (buf[
i] + 4LL) >> 3;
2800 memcpy(
out, saved, 448 *
sizeof(*
out));
2808 memcpy(
out + 448 + 4*128,
temp, 64 *
sizeof(*
out));
2811 memcpy(
out + 576, buf + 64, 448 *
sizeof(*
out));
2817 memcpy( saved,
temp + 64, 64 *
sizeof(*saved));
2821 memcpy( saved + 448, buf + 7*128 + 64, 64 *
sizeof(*saved));
2823 memcpy( saved, buf + 512, 448 *
sizeof(*saved));
2824 memcpy( saved + 448, buf + 7*128 + 64, 64 *
sizeof(*saved));
2826 memcpy( saved, buf + 512, 512 *
sizeof(*saved));
2849 for (
i = 0;
i < 8;
i++)
2866 memcpy(
out, saved, 420 *
sizeof(*
out));
2874 memcpy(
out + 420 + 4*120,
temp, 60 *
sizeof(*
out));
2877 memcpy(
out + 540, buf + 60, 420 *
sizeof(*
out));
2883 memcpy( saved,
temp + 60, 60 *
sizeof(*saved));
2887 memcpy( saved + 420, buf + 7*120 + 60, 60 *
sizeof(*saved));
2889 memcpy( saved, buf + 480, 420 *
sizeof(*saved));
2890 memcpy( saved + 420, buf + 7*120 + 60, 60 *
sizeof(*saved));
2892 memcpy( saved, buf + 480, 480 *
sizeof(*saved));
2911 for (
i = 0;
i < 1024;
i++)
2912 buf[
i] = (buf[
i] + 2) >> 2;
2918 memcpy(
out, saved, 192 *
sizeof(*
out));
2920 memcpy(
out + 320, buf + 64, 192 *
sizeof(*
out));
2926 memcpy(saved, buf + 256, 256 *
sizeof(*saved));
2937 const int n2 = n >> 1;
2938 const int n4 = n >> 2;
2947 for (
i = 0;
i < n2;
i+=2) {
2949 temp = in[
i ]; in[
i ] = -in[n - 1 -
i]; in[n - 1 -
i] =
temp;
2950 temp = -in[
i + 1]; in[
i + 1] = in[n - 2 -
i]; in[n - 2 -
i] =
temp;
2960 for (
i = 0;
i < 1024;
i++)
2961 buf[
i] = (buf[
i] + 1) >> 1;
2964 for (
i = 0;
i < n;
i+=2) {
2974 for (
i = n4;
i < n2;
i ++) {
2980 for (
i = 0;
i < n2;
i ++) {
2986 for (
i = 0;
i < n4;
i ++) {
2993 memmove(saved + n, saved, 2 * n *
sizeof(*saved));
2994 memcpy( saved, buf, n *
sizeof(*saved));
3019 apply_coupling_method(ac, &cc->
ch[0], cce,
index);
3024 apply_coupling_method(ac, &cc->
ch[1], cce,
index++);
3112 int layout_map_tags,
ret;
3120 "More than one AAC RDB per ADTS frame");
3143 layout_map_tags = 2;
3144 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
3146 layout_map[0][1] = 0;
3147 layout_map[1][1] = 1;
3194 if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
3202 if (!(che=
get_che(ac, elem_type, elem_id))) {
3204 "channel element %d.%d is not allocated\n",
3205 elem_type, elem_id);
3211 switch (elem_type) {
3249 int samples = 0, multiplier, audio_found = 0, pce_found = 0;
3250 int is_dmono, sce_count = 0;
3251 int payload_alignment;
3290 if (che_presence[elem_type][elem_id]) {
3291 int error = che_presence[elem_type][elem_id] > 1;
3293 elem_type, elem_id);
3299 che_presence[elem_type][elem_id]++;
3301 if (!(che=
get_che(ac, elem_type, elem_id))) {
3303 elem_type, elem_id);
3311 switch (elem_type) {
3342 if (pce_found && !pushed) {
3355 "Not evaluating a further program_config_element as this construct is dubious at best.\n");
3375 while (elem_id > 0) {
3392 che_prev_type = elem_type;
3415 if (ac->
oc[1].
status && audio_found) {
3438 is_dmono = ac->
dmono_mode && sce_count == 2 &&
3455 int *got_frame_ptr,
AVPacket *avpkt)
3458 const uint8_t *buf = avpkt->
data;
3459 int buf_size = avpkt->
size;
3464 size_t new_extradata_size;
3467 &new_extradata_size);
3468 size_t jp_dualmono_size;
3473 if (new_extradata) {
3478 new_extradata_size * 8LL, 1);
3485 if (jp_dualmono && jp_dualmono_size > 0)
3490 if (INT_MAX / 8 <= buf_size)
3510 for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
3511 if (buf[buf_offset])
3514 return buf_size > buf_offset ? buf_consumed : buf_size;
3564 #define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
3566 {
"dual_mono_mode",
"Select the channel to decode for dual mono",
3575 {
"channel_order",
"Order in which the channels are to be exported",
3580 {
"coded",
"order in which the channels are coded in the bitstream",
static void error(const char *err)
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
static void vector_pow43(int *coefs, int len)
int frame_size
Number of samples per channel in an audio frame.
CouplingPoint
The point during decoding at which channel coupling is applied.
#define FF_ENABLE_DEPRECATION_WARNINGS
@ AV_SAMPLE_FMT_FLTP
float, planar
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline int lcg_random(unsigned previous_val)
linear congruential pseudorandom number generator
const uint8_t ff_tns_max_bands_128[]
static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
Mid/Side stereo decoding; reference: 4.6.8.1.3.
static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, GetBitContext *gb, MPEG4AudioConfig *m4ac, int channel_config)
static void update_ltp(AACContext *ac, SingleChannelElement *sce)
Update the LTP buffer for next frame.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_CH_TOP_SIDE_LEFT
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
Conduct IMDCT and windowing.
#define AV_CH_TOP_FRONT_CENTER
int sample_rate
samples per second
#define AV_CH_LOW_FREQUENCY_2
#define u(width, name, range_min, range_max)
const uint16_t ff_aac_spectral_sizes[11]
const float *const ff_aac_codebook_vector_vals[]
static int decode_fill(AACContext *ac, GetBitContext *gb, int len)
static av_cold int aac_decode_init(AVCodecContext *avctx)
static INTFLOAT aac_kbd_short_120[120]
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#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 decode_prediction(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
void ff_cbrt_tableinit(void)
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...
static int get_bits_count(const GetBitContext *s)
void(* subband_scale)(int *dst, int *src, int scale, int offset, int len, void *log_context)
#define AV_CH_TOP_FRONT_RIGHT
const uint16_t *const ff_aac_codebook_vector_idx[]
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
This structure describes decoded (raw) audio or video data.
static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
Skip data_stream_element; reference: table 4.10.
static void apply_dependent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
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.
const uint8_t ff_aac_num_swb_960[]
static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, int ms_present)
Decode Mid/Side data; reference: table 4.54.
static int count_paired_channels(uint8_t(*layout_map)[3], int tags, int pos, int *current)
@ AOT_ER_AAC_LTP
N Error Resilient Long Term Prediction.
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
const uint8_t ff_aac_num_swb_120[]
#define AV_LOG_VERBOSE
Detailed information.
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
#define AV_CH_TOP_FRONT_LEFT
int8_t used[MAX_LTP_LONG_SFB]
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.
static int * DEC_SQUAD(int *dst, unsigned idx)
#define AV_CHANNEL_LAYOUT_STEREO
static AVOnce aac_table_init
static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
Apply AAC-Main style frequency domain prediction.
#define UPDATE_CACHE(name, gb)
enum AVChannelOrder order
Channel order used in this layout.
const uint8_t ff_aac_num_swb_480[]
static void pop_output_configuration(AACContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked.
INTFLOAT * ret
PCM output.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int nb_channels
Number of channels in this layout.
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.
const uint16_t *const ff_swb_offset_128[]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
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.
#define FF_DEBUG_PICT_INFO
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const uint8_t ff_tns_max_bands_1024[]
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AV_CH_BOTTOM_FRONT_LEFT
#define AV_CH_TOP_BACK_LEFT
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
static void reset_all_predictors(PredictorState *ps)
#define GET_CACHE(name, gb)
static int set_default_channel_config(AACContext *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....
static void skip_bits(GetBitContext *s, int n)
Dynamic Range Control - decoded from the bitstream but not processed further.
int num_swb
number of scalefactor window bands
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CH_TOP_BACK_CENTER
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
static SDL_Window * window
const uint8_t ff_aac_num_swb_512[]
@ OC_LOCKED
Output configuration locked in place.
void(* apply_ltp)(AACContext *ac, SingleChannelElement *sce)
INTFLOAT saved[1536]
overlap
static const INTFLOAT ltp_coef[8]
INTFLOAT ret_buf[2048]
PCM output buffer.
AVChannelLayout ch_layout
Audio channel layout.
int id_select[8]
element id
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....
int flags
AV_CODEC_FLAG_*.
#define POW_SF2_ZERO
ff_aac_pow2sf_tab index corresponding to pow(2, 0);
static void decode_gain_control(SingleChannelElement *sce, GetBitContext *gb)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
static av_always_inline float scale(float x, float s)
static void decode_ltp(LongTermPrediction *ltp, GetBitContext *gb, uint8_t max_sfb)
Decode Long Term Prediction data; reference: table 4.xx.
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
Allocate and initialize a fixed DSP context.
static __device__ float fabsf(float a)
uint8_t prediction_used[41]
IndividualChannelStream ics
static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static void spectral_to_sample(AACContext *ac, int samples)
Convert spectral data to samples, applying all supported tools as appropriate.
#define AV_EF_BITSTREAM
detect bitstream specification deviations
@ AOT_ER_AAC_LC
N Error Resilient Low Complexity.
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ ZERO_BT
Scalefactors and spectral data are all zero.
#define FF_ARRAY_ELEMS(a)
#define FF_PROFILE_AAC_HE_V2
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 int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
Decode a channel_pair_element; reference: table 4.4.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
void(* vector_pow43)(int *coefs, int len)
#define AV_CH_LOW_FREQUENCY
#define AV_CH_LAYOUT_22POINT2
#define CLOSE_READER(name, gb)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
@ AOT_ER_AAC_LD
N Error Resilient Low Delay.
static const AVClass aac_decoder_class
@ OC_TRIAL_FRAME
Output configuration under trial specified by a frame header.
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
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.
const uint16_t *const ff_swb_offset_960[]
static int sample_rate_idx(int rate)
static av_always_inline void reset_predict_state(PredictorState *ps)
static const int offsets[]
int num_coupled
number of target elements
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static int decode_dynamic_range(DynamicRangeControl *che_drc, GetBitContext *gb)
Decode dynamic range information; reference: table 4.52.
@ OC_NONE
Output unconfigured.
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
intensity stereo decoding; reference: 4.6.8.2.3
static VLCElem vlc_buf[16716]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_CH_TOP_SIDE_RIGHT
#define SKIP_BITS(name, gb, num)
static int aac_decode_er_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, GetBitContext *gb)
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.
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
Individual Channel Stream.
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
INTFLOAT coef[8][4][TNS_MAX_ORDER]
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
void ff_aac_tableinit(void)
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.
int warned_num_aac_frames
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int decode_pulses(Pulse *pulse, GetBitContext *gb, const uint16_t *swb_offset, int num_swb)
Decode pulse data; reference: table 4.7.
static void flush(AVCodecContext *avctx)
const uint8_t ff_mpeg4audio_channels[14]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
enum AACOutputChannelOrder output_channel_order
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
const float ff_aac_eld_window_480[1800]
static void imdct_and_windowing_960(AACContext *ac, SingleChannelElement *sce)
Conduct IMDCT and windowing.
const uint8_t ff_aac_num_swb_128[]
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.
struct AVCodecInternal * internal
Private context used for internal data.
const char * av_default_item_name(void *ptr)
Return the context name.
static unsigned int get_bits1(GetBitContext *s)
static av_cold int aac_decode_close(AVCodecContext *avctx)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define LAST_SKIP_BITS(name, gb, num)
static __device__ float sqrtf(float a)
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
ChannelElement * che[4][MAX_ELEM_ID]
static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
Apply the long term prediction.
int skip_samples_multiplier
const uint16_t *const ff_swb_offset_480[]
#define AV_CH_FRONT_CENTER
#define AV_EF_EXPLODE
abort decoding on minor error detection
PredictorState predictor_state[MAX_PREDICTORS]
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
#define AV_CH_FRONT_LEFT_OF_CENTER
static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
Decode coupling_channel_element; reference: table 4.8.
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
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int band_type_run_end[120]
band type run end points
#define AV_CH_BOTTOM_FRONT_CENTER
const uint8_t ff_tns_max_bands_512[]
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
uint8_t layout_map[MAX_ELEM_ID *4][3]
void(* apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
const uint8_t ff_aac_scalefactor_bits[121]
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
const uint8_t ff_aac_pred_sfb_max[]
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.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
@ AOT_ER_AAC_SCALABLE
N Error Resilient Scalable.
SingleChannelElement ch[2]
const uint16_t *const ff_swb_offset_1024[]
static void relative_align_get_bits(GetBitContext *gb, int reference_position)
@ AOT_AAC_SCALABLE
N Scalable.
An AVChannelLayout holds information about the channel layout of audio data.
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.
void ff_aac_float_common_init(void)
static INTFLOAT sine_120[120]
int warned_remapping_once
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.
int sample_rate
Sample rate of the audio data.
static const int8_t tags_per_config[16]
static void noise_scale(int *coefs, int scale, int band_energy, int len)
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
static INTFLOAT sine_960[960]
enum AVSampleFormat sample_fmt
audio sample format
uint32_t ff_cbrt_tab[1<< 13]
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
const uint16_t *const ff_aac_spectral_codes[11]
OCStatus
Output configuration status.
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a potentially unaligned GetBitContext to retrieve audio configura...
static int push_output_configuration(AACContext *ac)
Save current output configuration if and only if it has been locked.
const uint8_t ff_tns_max_bands_480[]
#define OPEN_READER(name, gb)
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, uint64_t *layout)
const uint16_t *const ff_swb_offset_512[]
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.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define AV_CH_TOP_BACK_RIGHT
static void skip_bits1(GetBitContext *s)
#define AV_CH_FRONT_RIGHT_OF_CENTER
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.
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
int dyn_rng_ctl[17]
DRC magnitude information.
#define AV_LOG_INFO
Standard information.
void ff_sine_window_init(float *window, int n)
Generate a sine window.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
@ AOT_AAC_SSR
N (code in SoC repo) Scalable Sample Rate.
static INTFLOAT aac_kbd_long_960[960]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
@ AV_PKT_DATA_JP_DUALMONO
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
static av_cold void aac_static_table_init(void)
int nb_samples
number of audio samples (per channel) described by this frame
static void aacdec_init(AACContext *ac)
Single Channel Element - used for both SCE and LFE elements.
#define i(width, name, range_min, range_max)
static av_cold void init_sine_windows_fixed(void)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static const AVOption options[]
SpectralBandReplication sbr
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
const float ff_aac_eld_window_512[1920]
uint8_t ** extended_data
pointers to the data planes/channels.
channel element - generic struct for SCE/CPE/CCE/LFE
@ AOT_ER_AAC_ELD
N Error Resilient Enhanced Low Delay.
static void apply_independent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
#define NOISE_PRE_BITS
length of preamble
#define AV_CH_BACK_CENTER
#define FF_DEBUG_STARTCODE
static VLC vlc_spectral[11]
static av_always_inline float cbrtf(float x)
static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
Decode Individual Channel Stream info; reference: table 4.6.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
OutputConfiguration oc[2]
static const int8_t filt[NUMTAPS *2]
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....
static void reset_predictor_group(PredictorState *ps, int group_num)
@ OC_TRIAL_PCE
Output configuration under trial specified by an inband PCE.
static void subband_scale(int *dst, int *src, int scale, int offset, int len, void *log_context)
DynamicRangeControl che_drc
const uint16_t *const ff_swb_offset_120[]
#define FF_PROFILE_AAC_HE
@ AOT_ER_BSAC
N Error Resilient Bit-Sliced Arithmetic Coding.
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int pce_instance_tag
Indicates with which program the DRC info is associated.
#define INIT_VLC_STATIC_OVERLONG
const uint8_t ff_aac_num_swb_1024[]
#define FFSWAP(type, a, b)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
INTFLOAT sf[120]
scalefactors
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
const uint8_t *const ff_aac_spectral_bits[11]
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
#define AACDEC_FLAGS
AVOptions for Japanese DTV specific extensions (ADTS only)
static const uint8_t * align_get_bits(GetBitContext *s)
void(* update_ltp)(AACContext *ac, SingleChannelElement *sce)
int ch_select[8]
[0] shared list of gains; [1] list of gains for right channel; [2] list of gains for left channel; [3...
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
static ChannelElement * get_che(AACContext *ac, int type, int elem_id)
static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float *in, float *prev, int ch)
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
main external API structure.
int AAC_RENAME() ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int crc, int cnt, int id_aac)
Decode one SBR element.
static VLC vlc_scalefactors
#define SHOW_UBITS(name, gb, num)
int ps
-1 implicit, 1 presence
float ff_aac_pow2sf_tab[428]
void ff_aacdec_init_mips(AACContext *c)
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
#define AV_CH_BOTTOM_FRONT_RIGHT
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
enum WindowSequence window_sequence[2]
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
void AAC_RENAME() ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
Close one SBR context.
int sbr
-1 implicit, 1 presence
Filter the word “frame” indicates either a video frame or a group of audio samples
int band_incr
Number of DRC bands greater than 1 having DRC info.
#define AV_CH_FRONT_RIGHT
static int * DEC_UQUAD(int *dst, unsigned idx, unsigned sign)
#define FF_DISABLE_DEPRECATION_WARNINGS
AVChannelLayout ch_layout
void(* windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out, INTFLOAT *in, IndividualChannelStream *ics)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static int frame_configure_elements(AVCodecContext *avctx)
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.
#define avpriv_request_sample(...)
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
static int count_channels(uint8_t(*layout)[3], int tags)
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
This structure stores compressed data.
static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
uint8_t max_sfb
number of scalefactor bands per group
INTFLOAT ltp_state[3072]
time signal for LTP
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
static av_always_inline int fixed_sqrt(int x, int bits)
Calculate the square root.
void AAC_RENAME() ff_aac_sbr_init(void)
Initialize SBR.
static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb, const AVPacket *avpkt)
#define PREFIX_FOR_22POINT2
void AAC_RENAME() ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr, int id_aac)
Initialize one SBR context.
static int * DEC_UPAIR(int *dst, unsigned idx, unsigned sign)
static int * DEC_SPAIR(int *dst, unsigned idx)
static const INTFLOAT *const tns_tmp2_map[4]
void(* imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce)
enum BandType band_type[128]
band types
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
@ AOT_AAC_LC
Y Low Complexity.
@ AOT_AAC_LTP
Y Long Term Prediction.
static const float cce_scale[]
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
int predictor_reset_group
const uint32_t ff_aac_scalefactor_code[121]
static uint64_t sniff_channel_order(uint8_t(*layout_map)[3], int tags)
static const uint8_t aac_channel_layout_map[16][16][3]
int predictor_initialized