FFmpeg: libavcodec/aac/aacdec.h Source File
Go to the documentation of this file. 1 /*
2 * AAC decoder definitions and structures
3 * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
4 * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * AAC decoder definitions and structures
26 * @author Oded Shimon ( ods15 ods15 dyndns org )
27 * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
28 */
29
30 #ifndef AVCODEC_AAC_AACDEC_H
31 #define AVCODEC_AAC_AACDEC_H
32
33 #include <stdint.h>
34
40
44
46
48
49 /**
50 * Output configuration status
51 */
54 OC_TRIAL_PCE,
///< Output configuration under trial specified by an inband PCE
55 OC_TRIAL_FRAME,
///< Output configuration under trial specified by a frame header
56 OC_GLOBAL_HDR,
///< Output configuration set in a global header but not yet locked
57 OC_LOCKED,
///< Output configuration locked in place
58 };
59
63 };
64
65 /**
66 * The point during decoding at which channel coupling is applied.
67 */
72 };
73
79 };
80
85 };
86
93 };
94
98 };
99
100 // Supposed to be equal to AAC_RENAME() in case of USE_FIXED.
101 #define RENAME_FIXED(name) name ## _fixed
102
103 #define INTFLOAT_UNION(name, elems) \
104 union { \
105 int RENAME_FIXED(name) elems; \
106 float name elems; \
107 }
108
109 #define INTFLOAT_ALIGNED_UNION(alignment, name, nb_elems) \
110 union { \
111 DECLARE_ALIGNED(alignment, int, RENAME_FIXED(name))[nb_elems]; \
112 DECLARE_ALIGNED(alignment, float, name)[nb_elems]; \
113 }
114 /**
115 * Long Term Prediction
116 */
123
124 /* Per channel core mode */
129
130 /* Timewarping ratio */
131 #define NUM_TW_NODES 16
133
134 struct {
137
141
144
145 struct {
150
151 struct {
153 uint32_t
kv[8
/* (1024 / 16) / 8 */][8];
155
158
159 /**
160 * Individual Channel Stream
161 */
163 uint8_t
max_sfb;
///< number of scalefactor bands per group
165 uint8_t
use_kb_window[2];
///< If set, use Kaiser-Bessel window, otherwise use a sine window.
170 const uint16_t *
swb_offset;
///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
171 int num_swb;
///< number of scalefactor window bands
180
181 /**
182 * Temporal Noise Shaping
183 */
192
193 /**
194 * coupling parameters
195 */
201 int ch_select[8];
/**< [0] shared list of gains; [1] list of gains for right channel;
202 * [2] list of gains for left channel; [3] lists of gains for both channels
203 */
206
207 /**
208 * Single Channel Element - used for both SCE and LFE elements.
209 */
215 int sfo[128];
///< scalefactor offsets
216 INTFLOAT_UNION(sf, [128]);
///< scalefactors (8 windows * 16 sfb max)
222 union {
225 };
226 union {
229 };
231
235 uint8_t
tns_on_lr;
///< Apply TNS before M/S and stereo prediction
236
239
240 /* Complex prediction */
244
246
251
256
257 /**
258 * channel element - generic struct for SCE/CPE/CCE/LFE
259 */
262 // CPE specific
264 uint8_t
ms_mask[128];
///< Set if mid/side stereo is used for each scalefactor window band
265 // shared
267 // CCE specific
269 // USAC stereo coupling data
272
276 struct {
280
281 struct {
287
289 struct {
296
299
302
304
305 struct {
307
311
312 struct {
315
319
326
327 struct {
334
341
342 struct {
350
355
358
359 struct {
366
375
376 /**
377 * Dynamic Range Control - decoded from the bitstream but not processed further.
378 */
381 int dyn_rng_sgn[17];
///< DRC sign information; 0 - positive, 1 - negative
384 int band_incr;
///< Number of DRC bands greater than 1 having DRC info.
386 int band_top[17];
///< Indicates the top of the i-th DRC band in units of 4 spectral lines.
387 int prog_ref_level;
/**< A reference level for the long-term program audio level for all
388 * channels combined.
389 */
391
392 /**
393 * Decode-specific primitives
394 */
400
402
407 int id_aac,
void /* INTFLOAT */ *
L,
void /* INTFLOAT */ *
R);
410
411 /**
412 * DSP-specific primitives
413 */
416
419 int ms_present);
420
423
426
428
435
441
444
445 /**
446 * main AAC decoding context
447 */
451
454
456
457 int is_saved;
///< Set if elements have stored overlap from previous frame.
459
460 /**
461 * @name Channel element related data
462 * @{
463 */
468 /** @} */
469
470 /**
471 * @name temporary aligned temporary buffers
472 * (We do not want to have these on the stack.)
473 * @{
474 */
477 /** @} */
478
479 /**
480 * @name Computed / set up during initialization
481 * @{
482 */
492
502 union {
505 };
507 /** @} */
508
509 /**
510 * @name Members used for output
511 * @{
512 */
514 /** @} */
515
516
517 /**
518 * @name Japanese DTV specific extension
519 * @{
520 */
522 int dmono_mode;
///< 0->not dmono, 1->use first channel, 2->use second channel
523 /** @} */
524
526
533
535 };
536
537 #if defined(USE_FIXED) && USE_FIXED
538 #define fdsp RENAME_FIXED(fdsp)
539 #endif
540
544
547
550
552 uint8_t (*layout_map)[3],
553 int *tags,
554 int channel_config);
555
558 enum OCStatus oc_type,
int get_new_frame);
559
561
562 #endif /* AVCODEC_AAC_AACDEC_H */
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.
uint8_t stereo_config_index
uint8_t tns_on_lr
Apply TNS before M/S and stereo prediction.
int(* decode_spectrum_and_dequant)(AACDecContext *ac, GetBitContext *gb, const Pulse *pulse, SingleChannelElement *sce)
struct PredictorState * predictor_state
void(* apply_intensity_stereo)(AACDecContext *ac, ChannelElement *cpe, int ms_present)
uint16_t stream_identifier
struct AACUsacElemConfig::@24 sbr
int(* sbr_ctx_alloc_init)(AACDecContext *ac, ChannelElement **che, int id_aac)
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.
uint8_t scale_factor_grouping
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
void(* apply_tns)(void *_coef_param, TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
int warned_remapping_once
void(* apply_prediction)(AACDecContext *ac, SingleChannelElement *sce)
SingleChannelElement ch[2]
@ ID_CONFIG_EXT_STREAM_ID
int ff_aac_decode_init_float(AVCodecContext *avctx)
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
Dynamic Range Control - decoded from the bitstream but not processed further.
int num_swb
number of scalefactor window bands
int ff_aac_decode_init_fixed(AVCodecContext *avctx)
Dequantization-related.
INTFLOAT_UNION(gain, [16][120])
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
float coeffs[1024]
coefficients for IMDCT, maybe processed
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
struct AACUsacElemConfig::@24::@27 dflt
int id_select[8]
element id
float ret_buf[2048]
PCM output buffer.
@ ID_EXT_ELE_AUDIOPREROLL
uint8_t window_clipping[8]
set if a certain window is near clipping
void(* sbr_apply)(AACDecContext *ac, ChannelElement *che, int id_aac, void *L, void *R)
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
DynamicRangeControl che_drc
IndividualChannelStream ics
AACUsacElemConfig elems[64]
struct AACUsacElemConfig::@26 ext
void(* dequant_scalefactors)(SingleChannelElement *sce)
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
int ff_aac_decode_init(AVCodecContext *avctx)
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
float ltp_state[3072]
time signal for LTP
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
void(* apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe)
int num_coupled
number of target elements
int(* decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement *che)
void(* imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)
uint8_t core_sbr_frame_len_idx
Individual Channel Stream.
ChannelElement * che[4][MAX_ELEM_ID]
int warned_num_aac_frames
Describe the class of an AVClass context structure.
int(* sbr_decode_extension)(AACDecContext *ac, ChannelElement *che, GetBitContext *gb, int crc, int cnt, int id_aac)
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
struct AACUSACConfig::@28 loudness
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.
INTFLOAT_UNION(sf, [128])
scalefactors (8 windows * 16 sfb max)
struct AACUSACLoudnessInfo::@23 measurements[16]
uint8_t temp_shape_config
@ OC_LOCKED
Output configuration locked in place.
int prev_num_window_groups
Previous frame's number of window groups.
AACUsacElemData ue
USAC element data.
uint8_t layout_map[MAX_ELEM_ID *4][3]
void(* update_ltp)(AACDecContext *ac, SingleChannelElement *sce)
void(* apply_independent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
ChannelElement * ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
enum WindowSequence window_sequence[2]
void(* clip_output)(AACDecContext *ac, ChannelElement *che, int type, int samples)
@ OC_NONE
Output unconfigured.
void(* apply_dependent_coupling)(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
An AVChannelLayout holds information about the channel layout of audio data.
void(* imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce)
uint8_t max_sfb_ste
(USAC) Maximum of both max_sfb values
OCStatus
Output configuration status.
int sfo[128]
scalefactor offsets
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
enum AACOutputChannelOrder output_channel_order
struct AACUsacElemConfig::@25 mps
INTFLOAT_ALIGNED_UNION(32, buf_mdct, 1024)
enum BandType band_type[128]
band types
int dyn_rng_ctl[17]
DRC magnitude information.
@ ID_CONFIG_EXT_LOUDNESS_INFO
void(* apply_ltp)(AACDecContext *ac, SingleChannelElement *sce)
float * output
PCM output.
void(* imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce)
int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics)
Decode Temporal Noise Shaping data; reference: table 4.48.
int ff_aac_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.
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.
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....
Single Channel Element - used for both SCE and LFE elements.
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...
#define RENAME_FIXED(name)
OutputConfiguration oc[2]
void(* imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce)
INTFLOAT_ALIGNED_UNION(32, coeffs, 1024)
coefficients for IMDCT, maybe processed
int pce_instance_tag
Indicates with which program the DRC info is associated.
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...
struct AACUSACLoudnessInfo::@22 true_peak
INTFLOAT_UNION(coef, [8][4][TNS_MAX_ORDER])
main AAC decoding context
AACUSACLoudnessInfo info[64]
main external API structure.
struct AVCodecContext * avctx
uint8_t prediction_used[41]
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.
struct AACUsacElemData::@16 fac
AVChannelLayout ch_layout
void(* imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce)
int is_saved
Set if elements have stored overlap from previous frame.
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
uint8_t tw_ratio[NUM_TW_NODES]
struct AACUsacElemData::@14 ldp
struct AACUsacElemData::@15 noise
INTFLOAT_ALIGNED_UNION(32, alpha_q_re, 1024)
Decode-specific primitives.
uint8_t max_sfb
number of scalefactor bands per group
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
struct AACUSACLoudnessInfo::@21 sample_peak
@ OC_TRIAL_FRAME
Output configuration under trial specified by a frame header.
void(* sbr_ctx_close)(ChannelElement *che)
int predictor_reset_group
AACUSACLoudnessInfo album_info[64]
int predictor_initialized
Generated on Fri Aug 22 2025 13:58:05 for FFmpeg by
doxygen
1.8.17