36#include "config_components.h"
116#define overread_err "Input buffer exhausted before END element found\n"
121 for (
i = 0;
i < tags;
i++) {
124 sum += (1 + (syn_ele ==
TYPE_CPE)) *
223 uint8_t (*layout_map)[3],
int offset, uint64_t
left,
224 uint64_t right,
int pos, uint64_t *
layout)
228 .av_position =
left | right,
230 .elem_id = layout_map[
offset][1],
233 if (e2c_vec[
offset].av_position != UINT64_MAX)
241 .elem_id = layout_map[
offset][1],
245 .av_position = right,
247 .elem_id = layout_map[
offset + 1][1],
250 if (
left != UINT64_MAX)
253 if (right != UINT64_MAX)
263 int num_pos_channels = 0;
268 if (layout_map[
i][2] !=
pos)
278 num_pos_channels += 2;
289 return num_pos_channels;
298 if (nb_channels < 0 || nb_channels > 5)
302 while (nb_channels) {
307 .syn_ele = layout_map[
i][0],
308 .elem_id = layout_map[
i][1],
311 *
layout |= e2c_vec[
i].av_position;
321 while (nb_channels & 1) {
328 .syn_ele = layout_map[
i][0],
329 .elem_id = layout_map[
i][1],
332 *
layout |= e2c_vec[
i].av_position;
338 while (nb_channels >= 2) {
349 while (nb_channels & 1) {
354 .syn_ele = layout_map[
i][0],
355 .elem_id = layout_map[
i][1],
358 *
layout |= e2c_vec[
i].av_position;
372 int i, n, total_non_cc_elements;
379 for (n = 0,
i = 0; n < 3 &&
i < tags; n++) {
394 total_non_cc_elements = n =
i;
412 for (
i = 1;
i < n;
i++)
422 for (
i = 0;
i < total_non_cc_elements;
i++) {
435 for (
i = 0;
i <
src->usac.nb_elems;
i++) {
444 for (;
i <
dst->usac.nb_elems;
i++)
489 enum OCStatus oc_type,
int get_new_frame)
495 uint8_t type_counts[
TYPE_END] = { 0 };
497 if (get_new_frame && !ac->
frame)
501 memcpy(ac->
oc[1].
layout_map, layout_map, tags *
sizeof(layout_map[0]));
504 for (
i = 0;
i < tags;
i++) {
505 int type = layout_map[
i][0];
506 int id = layout_map[
i][1];
517 for (
i = 0;
i < tags;
i++) {
518 int type = layout_map[
i][0];
519 int id = layout_map[
i][1];
520 int iid = id_map[
type][
id];
521 int position = layout_map[
i][2];
565 for (j = 0; j <= 1; j++) {
566 memset(che->
ch[j].saved, 0,
sizeof(che->
ch[j].saved));
572#if CONFIG_AAC_DECODER
584 uint8_t (*layout_map)[3],
588 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
589 channel_config > 14) {
591 "invalid default channel configuration (%d)\n",
597 *tags *
sizeof(*layout_map));
615 " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
640 &layout_map_tags, 2) < 0)
659 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
661 layout_map[0][1] = 0;
662 layout_map[1][1] = 1;
711 "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n",
735 "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n",
803 layout_map[0][2] =
type;
809 int reference_position) {
821 uint8_t (*layout_map)[3],
824 int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc;
834 "Sample rate index (%d) in program config element does not "
835 "match the sample rate index (%d) configured by the container.\n", sampling_index, m4ac->
sampling_index);
852 if (
get_bits_left(gb) < 5 * (num_front + num_side + num_back + num_cc) + 4 *(num_lfe + num_assoc_data + num_cc)) {
881 if (comment_len >= 16 + (num_front * 2 + num_side * 2 + num_back * 2))
884 uint8_t height_map[4 ][16 ];
885 uint8_t
tag[6 ][16 ][3];
886 int i, invalid = 0, height_tags = 0;
892 for (
i = 0;
i < num_front;
i++) {
899 for (
i = 0;
i < num_side;
i++) {
906 for (
i = 0;
i < num_back;
i++) {
913 for (
i = 0;
i < num_lfe;
i++) {
917 for (
i = 0;
i < num_cc;
i++) {
927 for (
i = 0;
i < 3;
i++) {
928 for (
int j = 0; j < num_front; j++) {
934 for (
int j = 0; j < num_side; j++) {
940 for (
int j = 0; j < num_back; j++) {
947 for (
int j = 0; j < num_lfe; j++) {
951 for (
int j = 0; j < num_cc; j++) {
960 comment_len -= 8 + (num_front * 2 + num_side * 2 + num_back * 2);
977 int get_bit_alignment,
981 int extension_flag, ret, ep_config, res_flags;
995 if (channel_config == 0) {
997 tags =
decode_pce(avctx, m4ac, layout_map, gb, get_bit_alignment);
1002 &tags, channel_config)))
1008 }
else if (m4ac->
sbr == 1 && m4ac->
ps == -1)
1014 if (extension_flag) {
1027 "AAC data resilience (flags %x)",
1043 "epConfig %d", ep_config);
1055 int ret, ep_config, res_flags;
1058 const int ELDEXT_TERM = 0;
1067 "AAC data resilience (flags %x)",
1078 while (
get_bits(gb, 4) != ELDEXT_TERM) {
1082 if (
len == 15 + 255)
1092 &tags, channel_config)))
1101 "epConfig %d", ep_config);
1123 int get_bit_alignment,
1138 "invalid sampling rate index %d\n",
1146 "invalid low delay sampling rate index %d\n",
1170#if CONFIG_AAC_DECODER
1179 "Audio object type %s%d",
1180 m4ac->
sbr == 1 ?
"SBR+" :
"",
1186 "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
1203 if (bit_size < 0 || bit_size > INT_MAX) {
1208 ff_dlog(avctx,
"audio specific config size %d\n", (
int)bit_size >> 3);
1224 for (
int i = 0;
i < 2;
i++) {
1227 for (
int j = 0; j < usac->
nb_elems; j++) {
1267 float scale_fixed, scale_float;
1268 const float *
const scalep = is_fixed ? &scale_fixed : &scale_float;
1271#define MDCT_INIT(s, fn, len, sval) \
1272 scale_fixed = (sval) * 128.0f; \
1273 scale_float = (sval) / 32768.0f; \
1274 ret = av_tx_init(&s, &fn, tx_type, 1, len, scalep, 0); \
1290 scale_float = -32786.0*2 + 36;
1320 int layout_map_tags;
1387 "Invalid Predictor Reset Group.\n");
1406 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
1408 else if (CONFIG_AAC_DECODER)
1437 "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
1451 for (
i = 0;
i < 7;
i++) {
1508 "Prediction is not allowed in AAC-LC.\n");
1513 "LTP in ER AAC LD not yet implemented.\n");
1525 "Number of scalefactor bands in group (%d) "
1526 "exceeds limit (%d).\n",
1553 while (k < ics->max_sfb) {
1554 uint8_t sect_end = k;
1556 int sect_band_type =
get_bits(gb, 4);
1557 if (sect_band_type == 12) {
1563 sect_end += sect_len_incr;
1568 if (sect_end > ics->
max_sfb) {
1570 "Number of bands (%d) exceeds limit (%d).\n",
1574 }
while (sect_len_incr == (1 <<
bits) - 1);
1575 for (; k < sect_end; k++)
1601 for (
int sfb = 0; sfb < ics->
max_sfb; sfb++) {
1610 if (
offset[2] != clipped_offset) {
1612 "If you heard an audible artifact, there may be a bug in the decoder. "
1613 "Clipped intensity stereo position (%d -> %d)",
1614 offset[2], clipped_offset);
1616 sce->
sfo[
g*ics->
max_sfb + sfb] = clipped_offset - 100;
1619 if (noise_flag-- > 0)
1624 if (
offset[1] != clipped_offset) {
1626 "If you heard an audible artifact, there may be a bug in the decoder. "
1627 "Clipped noise gain (%d -> %d)",
1628 offset[1], clipped_offset);
1636 "Scalefactor (%d) out of range.\n",
offset[0]);
1652 const uint16_t *swb_offset,
int num_swb)
1657 if (pulse_swb >= num_swb)
1659 pulse->
pos[0] = swb_offset[pulse_swb];
1661 if (pulse->
pos[0] >= swb_offset[num_swb])
1666 if (pulse->
pos[
i] >= swb_offset[num_swb])
1681 int tns_max_order = INT32_MAX;
1683 int w,
filt,
i, coef_len, coef_res, coef_compress;
1705 "TNS filter order %d is greater than maximum %d.\n",
1713 coef_len = coef_res + 3 - coef_compress;
1714 tmp2_idx = 2 * coef_compress + coef_res;
1717 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
1719 else if (CONFIG_AAC_DECODER)
1742 if (ms_present == 1) {
1743 for (idx = 0; idx < max_idx; idx++)
1745 }
else if (ms_present == 2) {
1753 static const uint8_t gain_mode[4][3] = {
1764 uint8_t max_band =
get_bits(gb, 2);
1765 for (bd = 0; bd < max_band; bd++) {
1766 for (wd = 0; wd < gain_mode[
mode][0]; wd++) {
1767 uint8_t adjust_num =
get_bits(gb, 3);
1768 for (ad = 0; ad < adjust_num; ad++) {
1771 : gain_mode[
mode][2]));
1791 int global_gain, eld_syntax, er_syntax, pulse_present = 0;
1807 if (!common_window && !scale_flag) {
1822 if (!eld_syntax && (pulse_present =
get_bits1(gb))) {
1825 "Pulse tool not allowed in eight short sequence.\n");
1831 "Pulse data corrupt or invalid.\n");
1837 if (tns->
present && !er_syntax) {
1851 if (tns->
present && er_syntax) {
1859 pulse_present ? &pulse :
NULL,
1869 memset(sce->
sfo, 0,
sizeof(sce->
sfo));
1881 int i, ret, common_window, ms_present = 0;
1884 common_window = eld_syntax ||
get_bits1(gb);
1885 if (common_window) {
1896 if (ms_present == 3) {
1899 }
else if (ms_present)
1907 if (common_window) {
1929 int num_excl_chan = 0;
1932 for (
i = 0;
i < 7;
i++)
1936 return num_excl_chan / 7;
1948 int drc_num_bands = 1;
1969 for (
i = 0;
i < drc_num_bands;
i++) {
1982 for (
i = 0;
i < drc_num_bands;
i++) {
1993 int i, major, minor;
2000 for(
i=0;
i+1<
sizeof(buf) &&
len>=8;
i++,
len-=8)
2007 if (sscanf(buf,
"libfaac %d.%d", &major, &minor) == 2){
2107 apply_coupling_method(ac, &cc->
ch[0], cce,
index);
2112 apply_coupling_method(ac, &cc->
ch[1], cce,
index++);
2194 int layout_map_tags, ret;
2202 "More than one AAC RDB per ADTS frame");
2225 layout_map_tags = 2;
2226 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
2228 layout_map[0][1] = 0;
2229 layout_map[1][1] = 1;
2276 if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
2286 "channel element %d.%d is not allocated\n",
2293 switch (elem_type) {
2333 int samples = 0, multiplier, audio_found = 0, pce_found = 0, sce_count = 0;
2348 if (che_presence[elem_type][
elem_id]) {
2355 che_presence[elem_type][
elem_id]++;
2366 switch (elem_type) {
2397 if (pce_found && !pushed)
2408 "Not evaluating a further program_config_element as this construct is dubious at best.\n");
2444 che_prev_type = elem_type;
2460 samples <<= multiplier;
2464 if (ac->
oc[1].
status && audio_found) {
2472 "Cannot output a frame without a valid sample rate\n");
2492 is_dmono = ac->
dmono_mode && sce_count == 2 &&
2540 "AAC USAC fixed-point decoding");
2543#if CONFIG_AAC_DECODER
2562 int *got_frame_ptr,
AVPacket *avpkt)
2565 const uint8_t *buf = avpkt->
data;
2566 int buf_size = avpkt->
size;
2571 size_t new_extradata_size;
2574 &new_extradata_size);
2575 size_t jp_dualmono_size;
2580 if (new_extradata) {
2585 new_extradata_size * 8LL, 1);
2592 if (jp_dualmono && jp_dualmono_size > 0)
2597 if (INT_MAX / 8 <= buf_size)
2617 for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
2618 if (buf[buf_offset])
2621 return buf_size > buf_offset ? buf_consumed : buf_size;
2624#if CONFIG_AAC_LATM_DECODER
2628#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
2629#define OFF(field) offsetof(AACDecContext, field)
2634 {
"dual_mono_mode",
"Select the channel to decode for dual mono",
2643 {
"channel_order",
"Order in which the channels are to be exported",
2648 {
"coded",
"order in which the channels are coded in the bitstream",
2651 {
"target_level",
"Target output loudness in dBFS for xHE-AAC normalization (0 = disabled)",
2658 .class_name =
"AAC decoder",
2664#if CONFIG_AAC_DECODER
2684#if CONFIG_AAC_FIXED_DECODER
2686 .p.name =
"aac_fixed",
AAC definitions and structures.
static int ff_aac_sample_rate_idx(int rate)
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
@ ZERO_BT
Scalefactors and spectral data are all zero.
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
#define NOISE_PRE_BITS
length of preamble
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
AAC decoder definitions and structures.
CouplingPoint
The point during decoding at which channel coupling is applied.
int ff_aac_decode_init_fixed(AVCodecContext *avctx)
Dequantization-related.
int ff_aac_decode_init_float(AVCodecContext *avctx)
OCStatus
Output configuration status.
@ OC_TRIAL_FRAME
Output configuration under trial specified by a frame header.
@ OC_TRIAL_PCE
Output configuration under trial specified by an inband PCE.
@ OC_LOCKED
Output configuration locked in place.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
@ OC_NONE
Output unconfigured.
const int16_t ff_aac_channel_map[3][4][6]
av_cold void ff_aacdec_common_init_once(void)
const uint8_t ff_aac_channel_layout_map[16][16][3]
const int8_t ff_tags_per_config[16]
VLCElem ff_vlc_scalefactors[352]
const AVChannelLayout ff_aac_ch_layout[]
int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, GetBitContext *gb, int *got_frame_ptr)
int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc)
int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, OutputConfiguration *oc, int channel_config)
AAC Spectral Band Replication function declarations.
const float ff_ltp_coef[8]
const uint8_t ff_aac_num_swb_960[]
const uint8_t ff_tns_max_bands_512[]
const uint8_t ff_tns_max_bands_1024[]
const uint16_t *const ff_swb_offset_128[]
const uint16_t *const ff_swb_offset_120[]
const uint8_t ff_aac_num_swb_480[]
const uint8_t ff_aac_pred_sfb_max[]
const uint16_t *const ff_swb_offset_1024[]
const uint16_t *const ff_swb_offset_960[]
const uint16_t *const ff_swb_offset_480[]
const uint8_t ff_aac_num_swb_1024[]
const uint8_t ff_aac_num_swb_128[]
const uint8_t ff_tns_max_bands_480[]
const uint8_t ff_aac_num_swb_512[]
const uint8_t ff_tns_max_bands_128[]
const float *const ff_tns_tmp2_map[4]
const uint16_t *const ff_swb_offset_512[]
#define ff_aac_num_swb_120
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const int8_t filt[NUMTAPS *2]
const FFCodec ff_aac_fixed_decoder
const FFCodec ff_aac_decoder
static av_cold void close(AVCodecParserContext *s)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_DEBUG_STARTCODE
#define FF_DEBUG_PICT_INFO
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define CODEC_SAMPLEFMTS(...)
#define CODEC_CH_LAYOUTS_ARRAY(array)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_PROFILE_AAC_HE
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_PROFILE_AAC_HE_V2
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
static struct @111144215057303131116103221376075045141373005341 current
static const uint8_t bits[8]
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CH_LAYOUT_22POINT2
#define AV_CH_FRONT_RIGHT
#define AV_CH_FRONT_CENTER
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
@ AV_PKT_DATA_JP_DUALMONO
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
@ 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...
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define AV_CHANNEL_LAYOUT_STEREO
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_NONE
Invalid channel index.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
#define LIBAVUTIL_VERSION_INT
static int decode_audio_specific_config(AACDecContext *ac, AVCodecContext *avctx, OutputConfiguration *oc, const uint8_t *data, int64_t bit_size, int sync_extension)
static void spectral_to_sample(AACDecContext *ac, int samples)
Convert spectral data to samples, applying all supported tools as appropriate.
static void relative_align_get_bits(GetBitContext *gb, int reference_position)
static int skip_data_stream_element(AACDecContext *ac, GetBitContext *gb)
Skip data_stream_element; reference: table 4.10.
int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID *4][3], int tags, enum OCStatus oc_type, int get_new_frame)
Configure output channel order based on the current program configuration element.
static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cnt, ChannelElement *che, enum RawDataBlockType elem_type)
Decode extension data (incomplete); reference: table 4.51.
static uint64_t sniff_channel_order(uint8_t(*layout_map)[3], int tags)
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 av_cold int init_dsp(AVCodecContext *avctx)
static int aac_decode_er_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb)
static int count_paired_channels(uint8_t(*layout_map)[3], int tags, int pos, int current)
static av_cold int che_configure(AACDecContext *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_audio_specific_config_gb(AACDecContext *ac, AVCodecContext *avctx, OutputConfiguration *oc, GetBitContext *gb, int get_bit_alignment, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, int ms_present)
Decode Mid/Side data; reference: table 4.54.
static av_cold int decode_close(AVCodecContext *avctx)
static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, MPEG4AudioConfig *m4ac, int channel_config)
int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, int common_window, int scale_flag)
Decode an individual_channel_stream payload; reference: table 4.44.
ChannelElement * ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
static int decode_band_types(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb)
Decode band types (section_data payload); reference: table 4.46.
static int frame_configure_elements(AVCodecContext *avctx)
static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, int get_bit_alignment, MPEG4AudioConfig *m4ac, int channel_config)
Decode GA "General Audio" specific configuration; reference: table 4.1.
static int decode_frame_ga(AVCodecContext *avctx, AACDecContext *ac, GetBitContext *gb, int *got_frame_ptr)
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 const AVClass decoder_class
int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
static void copy_oc(OutputConfiguration *dst, OutputConfiguration *src)
static int decode_pulses(Pulse *pulse, GetBitContext *gb, const uint16_t *swb_offset, int num_swb)
Decode pulse data; reference: table 4.7.
static int assign_channels(struct elem_to_channel e2c_vec[MAX_ELEM_ID], uint8_t(*layout_map)[3], uint64_t *layout, int tags, int layer, int pos, int *current)
static int decode_dynamic_range(DynamicRangeControl *che_drc, GetBitContext *gb)
Decode dynamic range information; reference: table 4.52.
static void decode_gain_control(SingleChannelElement *sce, GetBitContext *gb)
static int push_output_configuration(AACDecContext *ac)
Save current output configuration if and only if it has been locked.
av_cold int ff_aac_decode_init(AVCodecContext *avctx)
static int count_channels(uint8_t(*layout)[3], int tags)
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 decode_prediction(AACDecContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t(*layout_map)[3], int *tags, int channel_config)
Set up channel positions based on a default channel configuration as specified in table 1....
static void apply_channel_coupling(AACDecContext *ac, ChannelElement *cc, enum RawDataBlockType type, int elem_id, enum CouplingPoint coupling_point, void(*apply_coupling_method)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
channel coupling transformation interface
static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb, const AVPacket *avpkt)
static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
Decode Individual Channel Stream info; reference: table 4.6.
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)
static int parse_adts_frame_header(AACDecContext *ac, GetBitContext *gb)
static int decode_scalefactors(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, unsigned int global_gain)
Decode scalefactors; reference: table 4.47.
static int decode_fill(AACDecContext *ac, GetBitContext *gb, int len)
static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp, GetBitContext *gb, uint8_t max_sfb)
Decode Long Term Prediction data; reference: table 4.xx.
static int decode_cpe(AACDecContext *ac, GetBitContext *gb, ChannelElement *cpe)
Decode a channel_pair_element; reference: table 4.4.
#define MDCT_INIT(s, fn, len, sval)
static void pop_output_configuration(AACDecContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked.
common internal api header.
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
Libavutil version macros.
Utility Preprocessor macros.
#define FFSWAP(type, a, b)
Memory handling functions.
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...
const uint8_t ff_mpeg4audio_channels[15]
@ AOT_AAC_LTP
Y Long Term Prediction.
@ AOT_ER_AAC_LD
N Error Resilient Low Delay.
@ AOT_ER_AAC_ELD
N Error Resilient Enhanced Low Delay.
@ AOT_ER_AAC_LC
N Error Resilient Low Complexity.
@ AOT_USAC
Y Unified Speech and Audio Coding.
@ AOT_AAC_SCALABLE
N Scalable.
@ AOT_ER_BSAC
N Error Resilient Bit-Sliced Arithmetic Coding.
@ AOT_AAC_SSR
N (code in SoC repo) Scalable Sample Rate.
@ AOT_AAC_LC
Y Low Complexity.
@ AOT_ER_AAC_LTP
N Error Resilient Long Term Prediction.
@ AOT_ER_AAC_SCALABLE
N Error Resilient Scalable.
const AVProfile ff_aac_profiles[]
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
#define FF_ARRAY_ELEMS(a)
main AAC decoding context
struct AVCodecContext * avctx
ChannelElement * che[4][MAX_ELEM_ID]
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
int warned_remapping_once
DynamicRangeControl che_drc
enum AACOutputChannelOrder output_channel_order
int warned_num_aac_frames
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
OutputConfiguration oc[2]
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
void(* apply_intensity_stereo)(AACDecContext *ac, ChannelElement *cpe, int ms_present)
void(* imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce)
void(* imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce)
void(* imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)
void(* apply_independent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
void(* apply_prediction)(AACDecContext *ac, SingleChannelElement *sce)
void(* apply_tns)(void *_coef_param, TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
void(* imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce)
void(* update_ltp)(AACDecContext *ac, SingleChannelElement *sce)
void(* apply_dependent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
void(* apply_ltp)(AACDecContext *ac, SingleChannelElement *sce)
void(* clip_output)(AACDecContext *ac, ChannelElement *che, int type, int samples)
void(* apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe)
void(* dequant_scalefactors)(SingleChannelElement *sce)
void(* sbr_ctx_close)(ChannelElement *che)
void(* sbr_apply)(AACDecContext *ac, ChannelElement *che, int id_aac, int fl960, void *L, void *R)
int(* decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement *che)
int(* sbr_ctx_alloc_init)(AACDecContext *ac, ChannelElement **che, int id_aac)
int(* sbr_decode_extension)(AACDecContext *ac, ChannelElement *che, GetBitContext *gb, int crc, int cnt, int id_aac, int fl960)
int(* decode_spectrum_and_dequant)(AACDecContext *ac, GetBitContext *gb, const Pulse *pulse, SingleChannelElement *sce)
AACUsacElemConfig elems[MAX_ELEM_ID]
struct AACUsacElemConfig::@253167335173233142055027357074223104054112322124 ext
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int frame_size
Number of samples per channel in an audio frame.
struct AVCodecInternal * internal
Private context used for internal data.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int sample_rate
Sample rate of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
int id_select[8]
element id
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
int num_coupled
number of target elements
int ch_select[8]
[0] shared list of gains; [1] list of gains for right channel; [2] list of gains for left channel; [3...
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
channel element - generic struct for SCE/CPE/CCE/LFE
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
SingleChannelElement ch[2]
uint8_t max_sfb_ste
(USAC) Maximum of both max_sfb values
Dynamic Range Control - decoded from the bitstream but not processed further.
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
int band_incr
Number of DRC bands greater than 1 having DRC info.
int dyn_rng_ctl[17]
DRC magnitude information.
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
int pce_instance_tag
Indicates with which program the DRC info is associated.
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
Individual Channel Stream.
uint8_t max_sfb
number of scalefactor bands per group
int prev_num_window_groups
Previous frame's number of window groups.
int num_swb
number of scalefactor window bands
int predictor_reset_group
uint8_t prediction_used[41]
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
enum WindowSequence window_sequence[2]
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
int8_t used[MAX_LTP_LONG_SFB]
int sbr
-1 implicit, 1 presence
int ps
-1 implicit, 1 presence
AVChannelLayout ch_layout
uint8_t layout_map[MAX_ELEM_ID *4][3]
Single Channel Element - used for both SCE and LFE elements.
float coeffs[1024]
coefficients for IMDCT, maybe processed
int sfo[128]
scalefactor offsets
float ret_buf[2048]
PCM output buffer.
float * output
PCM output.
enum BandType band_type[128]
band types
IndividualChannelStream ics
float coef[8][4][TNS_MAX_ORDER]
#define avpriv_request_sample(...)
static void error(const char *err)
static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float *in, float *prev, int ch)
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respectively.