Go to the documentation of this file.
36 #include "config_components.h"
116 enum OCStatus oc_type,
int get_new_frame);
118 #define overread_err "Input buffer exhausted before END element found\n"
123 for (
i = 0;
i < tags;
i++) {
126 sum += (1 + (syn_ele ==
TYPE_CPE)) *
225 uint8_t (*layout_map)[3],
int offset, uint64_t
left,
226 uint64_t right,
int pos, uint64_t *
layout)
230 .av_position =
left | right,
232 .elem_id = layout_map[
offset][1],
235 if (e2c_vec[
offset].av_position != UINT64_MAX)
243 .elem_id = layout_map[
offset][1],
247 .av_position = right,
249 .elem_id = layout_map[
offset + 1][1],
252 if (
left != UINT64_MAX)
255 if (right != UINT64_MAX)
265 int num_pos_channels = 0;
269 for (
i = current;
i < tags;
i++) {
270 if (layout_map[
i][2] !=
pos)
280 num_pos_channels += 2;
291 return num_pos_channels;
295 uint64_t *
layout,
int tags,
int layer,
int pos,
int *current)
297 int i = *current, j = 0;
300 if (nb_channels < 0 || nb_channels > 5)
304 while (nb_channels) {
309 .syn_ele = layout_map[
i][0],
310 .elem_id = layout_map[
i][1],
313 *
layout |= e2c_vec[
i].av_position;
323 while (nb_channels & 1) {
330 .syn_ele = layout_map[
i][0],
331 .elem_id = layout_map[
i][1],
334 *
layout |= e2c_vec[
i].av_position;
340 while (nb_channels >= 2) {
351 while (nb_channels & 1) {
356 .syn_ele = layout_map[
i][0],
357 .elem_id = layout_map[
i][1],
360 *
layout |= e2c_vec[
i].av_position;
374 int i, n, total_non_cc_elements;
381 for (n = 0,
i = 0; n < 3 &&
i < tags; n++) {
396 total_non_cc_elements = n =
i;
414 for (
i = 1;
i < n;
i++)
424 for (
i = 0;
i < total_non_cc_elements;
i++) {
441 ac->
oc[0] = ac->
oc[1];
455 ac->
oc[1] = ac->
oc[0];
470 enum OCStatus oc_type,
int get_new_frame)
476 uint8_t type_counts[
TYPE_END] = { 0 };
479 memcpy(ac->
oc[1].
layout_map, layout_map, tags *
sizeof(layout_map[0]));
482 for (
i = 0;
i < tags;
i++) {
483 int type = layout_map[
i][0];
484 int id = layout_map[
i][1];
495 for (
i = 0;
i < tags;
i++) {
496 int type = layout_map[
i][0];
497 int id = layout_map[
i][1];
498 int iid = id_map[
type][
id];
499 int position = layout_map[
i][2];
543 for (j = 0; j <= 1; j++) {
544 memset(che->
ch[j].saved, 0,
sizeof(che->
ch[j].saved));
558 uint8_t (*layout_map)[3],
562 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
563 channel_config > 14) {
565 "invalid default channel configuration (%d)\n",
571 *tags *
sizeof(*layout_map));
589 " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
614 &layout_map_tags, 2) < 0)
633 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
635 layout_map[0][1] = 0;
636 layout_map[1][1] = 1;
681 "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n",
703 "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n",
768 layout_map[0][2] =
type;
774 int reference_position) {
786 uint8_t (*layout_map)[3],
789 int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc;
799 "Sample rate index in program config element does not "
800 "match the sample rate index configured by the container.\n");
817 if (
get_bits_left(gb) < 5 * (num_front + num_side + num_back + num_cc) + 4 *(num_lfe + num_assoc_data + num_cc)) {
857 int get_bit_alignment,
861 int extension_flag,
ret, ep_config, res_flags;
881 if (channel_config == 0) {
883 tags =
decode_pce(avctx, m4ac, layout_map, gb, get_bit_alignment);
888 &tags, channel_config)))
894 }
else if (m4ac->
sbr == 1 && m4ac->
ps == -1)
900 if (extension_flag) {
913 "AAC data resilience (flags %x)",
929 "epConfig %d", ep_config);
941 int ret, ep_config, res_flags;
944 const int ELDEXT_TERM = 0;
953 "AAC data resilience (flags %x)",
964 while (
get_bits(gb, 4) != ELDEXT_TERM) {
978 &tags, channel_config)))
987 "epConfig %d", ep_config);
1009 int get_bit_alignment,
1023 "invalid sampling rate index %d\n",
1031 "invalid low delay sampling rate index %d\n",
1057 "Audio object type %s%d",
1058 m4ac->
sbr == 1 ?
"SBR+" :
"",
1064 "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
1075 const uint8_t *
data, int64_t bit_size,
1081 if (bit_size < 0 || bit_size > INT_MAX) {
1086 ff_dlog(avctx,
"audio specific config size %d\n", (
int)bit_size >> 3);
1087 for (
i = 0; i < bit_size >> 3;
i++)
1100 if (92017 <= rate)
return 0;
1101 else if (75132 <= rate)
return 1;
1102 else if (55426 <= rate)
return 2;
1103 else if (46009 <= rate)
return 3;
1104 else if (37566 <= rate)
return 4;
1105 else if (27713 <= rate)
return 5;
1106 else if (23004 <= rate)
return 6;
1107 else if (18783 <= rate)
return 7;
1108 else if (13856 <= rate)
return 8;
1109 else if (11502 <= rate)
return 9;
1110 else if (9391 <= rate)
return 10;
1157 float scale_fixed, scale_float;
1158 const float *
const scalep = is_fixed ? &scale_fixed : &scale_float;
1168 #define MDCT_INIT(s, fn, len, sval) \
1169 scale_fixed = (sval) * 128.0f; \
1170 scale_float = (sval) / 32768.0f; \
1171 ret = av_tx_init(&s, &fn, tx_type, 1, len, scalep, 0); \
1185 scale_float = -32786.0*2 + 36;
1225 int layout_map_tags;
1298 "Invalid Predictor Reset Group.\n");
1317 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
1319 else if (CONFIG_AAC_DECODER)
1348 "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
1361 for (
i = 0;
i < 7;
i++) {
1418 "Prediction is not allowed in AAC-LC.\n");
1423 "LTP in ER AAC LD not yet implemented.\n");
1435 "Number of scalefactor bands in group (%d) "
1436 "exceeds limit (%d).\n",
1463 while (k < ics->max_sfb) {
1464 uint8_t sect_end = k;
1466 int sect_band_type =
get_bits(gb, 4);
1467 if (sect_band_type == 12) {
1473 sect_end += sect_len_incr;
1478 if (sect_end > ics->
max_sfb) {
1480 "Number of bands (%d) exceeds limit (%d).\n",
1484 }
while (sect_len_incr == (1 <<
bits) - 1);
1485 for (; k < sect_end; k++) {
1486 band_type [idx] = sect_band_type;
1487 band_type_run_end[idx++] = sect_end;
1506 unsigned int global_gain,
1509 int band_type_run_end[120])
1517 int run_end = band_type_run_end[idx];
1518 switch (band_type[idx]) {
1520 for (;
i < run_end;
i++, idx++)
1525 for (;
i < run_end;
i++, idx++) {
1528 if (
offset[2] != clipped_offset) {
1530 "If you heard an audible artifact, there may be a bug in the decoder. "
1531 "Clipped intensity stereo position (%d -> %d)",
1532 offset[2], clipped_offset);
1534 sfo[idx] = clipped_offset;
1538 for (;
i < run_end;
i++, idx++) {
1539 if (noise_flag-- > 0)
1544 if (
offset[1] != clipped_offset) {
1546 "If you heard an audible artifact, there may be a bug in the decoder. "
1547 "Clipped noise gain (%d -> %d)",
1548 offset[1], clipped_offset);
1550 sfo[idx] = clipped_offset;
1554 for (;
i < run_end;
i++, idx++) {
1558 "Scalefactor (%d) out of range.\n",
offset[0]);
1574 const uint16_t *swb_offset,
int num_swb)
1579 if (pulse_swb >= num_swb)
1581 pulse->
pos[0] = swb_offset[pulse_swb];
1583 if (pulse->
pos[0] >= swb_offset[num_swb])
1588 if (pulse->
pos[
i] >= swb_offset[num_swb])
1603 int w,
filt,
i, coef_len, coef_res, coef_compress;
1616 "TNS filter order %d is greater than maximum %d.\n",
1624 coef_len = coef_res + 3 - coef_compress;
1625 tmp2_idx = 2 * coef_compress + coef_res;
1628 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
1630 else if (CONFIG_AAC_DECODER)
1652 if (ms_present == 1) {
1653 for (idx = 0; idx < max_idx; idx++)
1655 }
else if (ms_present == 2) {
1663 static const uint8_t gain_mode[4][3] = {
1674 uint8_t max_band =
get_bits(gb, 2);
1675 for (bd = 0; bd < max_band; bd++) {
1676 for (wd = 0; wd < gain_mode[
mode][0]; wd++) {
1677 uint8_t adjust_num =
get_bits(gb, 3);
1678 for (ad = 0; ad < adjust_num; ad++) {
1681 : gain_mode[
mode][2]));
1701 int global_gain, eld_syntax, er_syntax, pulse_present = 0;
1717 if (!common_window && !scale_flag) {
1734 if (!eld_syntax && (pulse_present =
get_bits1(gb))) {
1737 "Pulse tool not allowed in eight short sequence.\n");
1743 "Pulse data corrupt or invalid.\n");
1749 if (tns->
present && !er_syntax) {
1763 if (tns->
present && er_syntax) {
1771 pulse_present ? &pulse :
NULL,
1792 int i,
ret, common_window, ms_present = 0;
1795 common_window = eld_syntax ||
get_bits1(gb);
1796 if (common_window) {
1807 if (ms_present == 3) {
1810 }
else if (ms_present)
1818 if (common_window) {
1840 int num_excl_chan = 0;
1843 for (
i = 0;
i < 7;
i++)
1847 return num_excl_chan / 7;
1859 int drc_num_bands = 1;
1880 for (
i = 0;
i < drc_num_bands;
i++) {
1893 for (
i = 0;
i < drc_num_bands;
i++) {
1904 int i, major, minor;
1911 for(
i=0;
i+1<
sizeof(buf) &&
len>=8;
i++,
len-=8)
1918 if (sscanf(buf,
"libfaac %d.%d", &major, &minor) == 2){
1955 "SBR with 960 frame length");
1979 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
1981 else if (CONFIG_AAC_DECODER)
2027 apply_coupling_method(ac, &cc->
ch[0], cce,
index);
2032 apply_coupling_method(ac, &cc->
ch[1], cce,
index++);
2092 if (CONFIG_AAC_FIXED_DECODER && ac->
is_fixed)
2096 else if (CONFIG_AAC_DECODER)
2118 int layout_map_tags,
ret;
2126 "More than one AAC RDB per ADTS frame");
2149 layout_map_tags = 2;
2150 layout_map[0][0] = layout_map[1][0] =
TYPE_SCE;
2152 layout_map[0][1] = 0;
2153 layout_map[1][1] = 1;
2200 if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
2210 "channel element %d.%d is not allocated\n",
2217 switch (elem_type) {
2255 int samples = 0, multiplier, audio_found = 0, pce_found = 0;
2256 int is_dmono, sce_count = 0;
2257 int payload_alignment;
2296 if (che_presence[elem_type][
elem_id]) {
2305 che_presence[elem_type][
elem_id]++;
2317 switch (elem_type) {
2348 if (pce_found && !pushed) {
2361 "Not evaluating a further program_config_element as this construct is dubious at best.\n");
2398 che_prev_type = elem_type;
2421 if (ac->
oc[1].
status && audio_found) {
2441 is_dmono = ac->
dmono_mode && sce_count == 2 &&
2458 int *got_frame_ptr,
AVPacket *avpkt)
2461 const uint8_t *buf = avpkt->
data;
2462 int buf_size = avpkt->
size;
2467 size_t new_extradata_size;
2470 &new_extradata_size);
2471 size_t jp_dualmono_size;
2476 if (new_extradata) {
2481 new_extradata_size * 8LL, 1);
2488 if (jp_dualmono && jp_dualmono_size > 0)
2493 if (INT_MAX / 8 <= buf_size)
2513 for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
2514 if (buf[buf_offset])
2517 return buf_size > buf_offset ? buf_consumed : buf_size;
2522 #define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
2523 #define OFF(field) offsetof(AACDecContext, field)
2528 {
"dual_mono_mode",
"Select the channel to decode for dual mono",
2537 {
"channel_order",
"Order in which the channels are to be exported",
2542 {
"coded",
"order in which the channels are coded in the bitstream",
2555 #if CONFIG_AAC_DECODER
2577 #if CONFIG_AAC_FIXED_DECODER
2579 .
p.
name =
"aac_fixed",
static void error(const char *err)
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
CouplingPoint
The point during decoding at which channel coupling is applied.
int frame_size
Number of samples per channel in an audio frame.
@ AV_SAMPLE_FMT_FLTP
float, planar
static av_cold int decode_close(AVCodecContext *avctx)
int(* decode_spectrum_and_dequant)(AACDecContext *ac, GetBitContext *gb, const Pulse *pulse, SingleChannelElement *sce)
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 void pop_output_configuration(AACDecContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked.
const uint8_t ff_tns_max_bands_128[]
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
void(* apply_intensity_stereo)(AACDecContext *ac, ChannelElement *cpe, int ms_present)
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)
#define AV_CHANNEL_LAYOUT_STEREO
int sample_rate
samples per second
@ 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...
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.
const AACDecProc aac_proc_fixed
static int get_bits_count(const GetBitContext *s)
int8_t used[MAX_LTP_LONG_SFB]
@ OC_TRIAL_PCE
Output configuration under trial specified by an inband PCE.
This structure describes decoded (raw) audio or video data.
static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb, const AVPacket *avpkt)
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....
const uint8_t ff_aac_num_swb_960[]
@ AOT_ER_AAC_LTP
N Error Resilient Long Term Prediction.
const float ff_ltp_coef[8]
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
static int parse_adts_frame_header(AACDecContext *ac, GetBitContext *gb)
const AVProfile ff_aac_profiles[]
const uint8_t ff_aac_num_swb_120[]
#define AV_LOG_VERBOSE
Detailed information.
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
void(* apply_tns)(void *_coef_param, TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
enum AVChannelOrder order
Channel order used in this layout.
const uint8_t ff_aac_num_swb_480[]
int warned_remapping_once
const float *const ff_tns_tmp2_map[4]
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int nb_channels
Number of channels in this layout.
void(* apply_prediction)(AACDecContext *ac, SingleChannelElement *sce)
SingleChannelElement ch[2]
const uint16_t *const ff_swb_offset_128[]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
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...
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.
#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 dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
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
void ff_aac_sbr_ctx_close(ChannelElement *che)
Close the SBR context implicitly contained in a ChannelElement.
static const AVOption options[]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
float coeffs[1024]
coefficients for IMDCT, maybe processed
const uint8_t ff_aac_num_swb_512[]
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
AVCodec p
The public AVCodec.
static int sample_rate_idx(int rate)
AVChannelLayout ch_layout
Audio channel layout.
int id_select[8]
element id
float ret_buf[2048]
PCM output buffer.
int ff_aac_sbr_decode_extension(AACDecContext *ac, ChannelElement *che, GetBitContext *gb, int crc, int cnt, int id_aac)
Decode one SBR element.
#define AV_EF_BITSTREAM
detect bitstream specification deviations
static ChannelElement * get_che(AACDecContext *ac, int type, int elem_id)
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
int ff_aac_sbr_ctx_alloc_init(AACDecContext *ac, ChannelElement **che, int id_aac)
Allocate an ExtChannelElement (if necessary) and initialize the SBR context contained in it.
DynamicRangeControl che_drc
IndividualChannelStream ics
static int decode_cpe(AACDecContext *ac, GetBitContext *gb, ChannelElement *cpe)
Decode a channel_pair_element; reference: table 4.4.
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 decode_audio_specific_config(AACDecContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
@ AOT_ER_AAC_LC
N Error Resilient Low Complexity.
const AACDecDSP aac_dsp_fixed
static int ff_thread_once(char *control, void(*routine)(void))
static int decode_fill(AACDecContext *ac, GetBitContext *gb, int len)
#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)
void(* dequant_scalefactors)(SingleChannelElement *sce)
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.
static av_cold void aac_static_table_init(void)
void ff_aac_sbr_ctx_close_fixed(ChannelElement *che)
#define AV_CH_LAYOUT_22POINT2
static int 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.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
@ AOT_ER_AAC_LD
N Error Resilient Low Delay.
#define FF_CODEC_DECODE_CB(func)
void(* apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe)
const uint16_t *const ff_swb_offset_960[]
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.
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.
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
int(* decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement *che)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void(* imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)
static int decode_scalefactors(AACDecContext *ac, int sfo[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.
Individual Channel Stream.
ChannelElement * che[4][MAX_ELEM_ID]
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
const AACDecProc aac_proc
#define CODEC_LONG_NAME(str)
int warned_num_aac_frames
int(* init)(AACDecContext *ac)
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
static AVOnce aac_table_init
#define LIBAVUTIL_VERSION_INT
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.
Describe the class of an AVClass context structure.
static void spectral_to_sample(AACDecContext *ac, int samples)
Convert spectral data to samples, applying all supported tools as appropriate.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
const uint8_t ff_aac_num_swb_128[]
struct AVCodecInternal * internal
Private context used for internal data.
static int decode_audio_specific_config_gb(AACDecContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, GetBitContext *gb, int get_bit_alignment, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
const char * av_default_item_name(void *ptr)
Return the context name.
static unsigned int get_bits1(GetBitContext *s)
const AVChannelLayout ff_aac_ch_layout[]
const FFCodec ff_aac_fixed_decoder
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
const uint16_t *const ff_swb_offset_480[]
static uint64_t sniff_channel_order(uint8_t(*layout_map)[3], int tags)
static int aac_decode_er_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb)
#define AV_CH_FRONT_CENTER
static int count_channels(uint8_t(*layout)[3], int tags)
static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, int ms_present)
Decode Mid/Side data; reference: table 4.54.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
@ OC_LOCKED
Output configuration locked in place.
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
static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
const uint8_t ff_tns_max_bands_512[]
int ff_aac_sbr_ctx_alloc_init_fixed(AACDecContext *ac, ChannelElement **che, int id_aac)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
uint8_t layout_map[MAX_ELEM_ID *4][3]
void(* update_ltp)(AACDecContext *ac, SingleChannelElement *sce)
static av_cold int aac_decode_init_fixed(AVCodecContext *avctx)
void(* apply_independent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
static int frame_configure_elements(AVCodecContext *avctx)
const uint8_t ff_aac_pred_sfb_max[]
void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che, int id_aac, INTFLOAT *L, INTFLOAT *R)
Apply one SBR element to one AAC element.
enum WindowSequence window_sequence[2]
void(* clip_output)(AACDecContext *ac, ChannelElement *che, int type, int samples)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
@ AOT_ER_AAC_SCALABLE
N Error Resilient Scalable.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ OC_NONE
Output unconfigured.
void(* apply_dependent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
const uint16_t *const ff_swb_offset_1024[]
@ AOT_AAC_SCALABLE
N Scalable.
static int skip_data_stream_element(AACDecContext *ac, GetBitContext *gb)
Skip data_stream_element; reference: table 4.10.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
int sample_rate
Sample rate of the audio data.
void(* imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce)
static int 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 int decode_band_types(AACDecContext *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.
OCStatus
Output configuration status.
enum AVSampleFormat sample_fmt
audio sample format
static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
const int8_t ff_tags_per_config[16]
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.
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
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...
enum AACOutputChannelOrder output_channel_order
int sfo[120]
scalefactor offsets
static int decode_dynamic_range(DynamicRangeControl *che_drc, GetBitContext *gb)
Decode dynamic range information; reference: table 4.52.
const uint8_t ff_tns_max_bands_480[]
const uint16_t *const ff_swb_offset_512[]
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
static const AVClass decoder_class
static void skip_bits1(GetBitContext *s)
enum BandType band_type[128]
band types
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
int dyn_rng_ctl[17]
DRC magnitude information.
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.
void(* apply_ltp)(AACDecContext *ac, SingleChannelElement *sce)
float * output
PCM output.
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, MPEG4AudioConfig *m4ac, int channel_config)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
static int decode_prediction(AACDecContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
#define AV_LOG_INFO
Standard information.
@ AOT_AAC_SSR
N (code in SoC repo) Scalable Sample Rate.
#define MDCT_INIT(s, fn, len, sval)
void(* imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce)
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
int nb_samples
number of audio samples (per channel) described by this frame
Single Channel Element - used for both SCE and LFE elements.
#define i(width, name, range_min, range_max)
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.
const uint8_t ff_aac_channel_layout_map[16][16][3]
static int push_output_configuration(AACDecContext *ac)
Save current output configuration if and only if it has been locked.
static void relative_align_get_bits(GetBitContext *gb, int reference_position)
uint8_t ** extended_data
pointers to the data planes/channels.
channel element - generic struct for SCE/CPE/CCE/LFE
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
@ AOT_ER_AAC_ELD
N Error Resilient Enhanced Low Delay.
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)
AVSampleFormat
Audio sample formats.
#define NOISE_PRE_BITS
length of preamble
int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, ChannelElement *che, GetBitContext *gb, int crc, int cnt, int id_aac)
#define FF_DEBUG_STARTCODE
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const FFCodec ff_aac_decoder
const char * name
Name of the codec implementation.
static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics, GetBitContext *gb)
Decode Individual Channel Stream info; reference: table 4.6.
static const int8_t filt[NUMTAPS *2]
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.
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che, int id_aac, INTFLOAT *L, INTFLOAT *R)
OutputConfiguration oc[2]
void(* imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce)
const uint16_t *const ff_swb_offset_120[]
@ AOT_ER_BSAC
N Error Resilient Bit-Sliced Arithmetic Coding.
int pce_instance_tag
Indicates with which program the DRC info is associated.
static void decode_ltp(AACDecContext *ac, LongTermPrediction *ltp, GetBitContext *gb, uint8_t max_sfb)
Decode Long Term Prediction data; reference: table 4.xx.
@ AV_PKT_DATA_JP_DUALMONO
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
const uint8_t ff_aac_num_swb_1024[]
static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
#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...
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
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
static const uint8_t * align_get_bits(GetBitContext *s)
static int count_paired_channels(uint8_t(*layout_map)[3], int tags, int pos, int current)
float coef[8][4][TNS_MAX_ORDER]
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 void flush(AVCodecContext *avctx)
static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float *in, float *prev, int ch)
main AAC decoding context
@ AV_CHAN_NONE
Invalid channel index.
static av_cold int init_dsp(AVCodecContext *avctx)
main external API structure.
#define AV_PROFILE_AAC_HE_V2
struct AVCodecContext * avctx
int ps
-1 implicit, 1 presence
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
uint8_t prediction_used[41]
const uint8_t ff_mpeg4audio_channels[15]
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
static void decode_gain_control(SingleChannelElement *sce, GetBitContext *gb)
#define AV_CH_FRONT_RIGHT
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
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
AVChannelLayout ch_layout
av_cold void ff_aacdec_common_init_once(void)
#define avpriv_request_sample(...)
#define AV_PROFILE_AAC_HE
const int16_t ff_aac_channel_map[3][4][6]
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
This structure stores compressed data.
VLCElem ff_vlc_scalefactors[352]
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
uint8_t max_sfb
number of scalefactor bands per group
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
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.
@ AOT_AAC_LC
Y Low Complexity.
@ AOT_AAC_LTP
Y Long Term Prediction.
@ OC_TRIAL_FRAME
Output configuration under trial specified by a frame header.
int predictor_reset_group
static av_cold int aac_decode_init(AVCodecContext *avctx)