aac.h
Go to the documentation of this file.
1 /*
2  * AAC 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 Libav.
7  *
8  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
30 #ifndef AVCODEC_AAC_H
31 #define AVCODEC_AAC_H
32 
33 #include "libavutil/float_dsp.h"
34 #include "avcodec.h"
35 #include "dsputil.h"
36 #include "fft.h"
37 #include "mpeg4audio.h"
38 #include "sbr.h"
39 #include "fmtconvert.h"
40 
41 #include <stdint.h>
42 
43 #define MAX_CHANNELS 64
44 #define MAX_ELEM_ID 16
45 
46 #define TNS_MAX_ORDER 20
47 #define MAX_LTP_LONG_SFB 40
48 
58 };
59 
65  EXT_SBR_DATA = 0xd,
67 };
68 
74 };
75 
76 enum BandType {
77  ZERO_BT = 0,
79  ESC_BT = 11,
80  NOISE_BT = 13,
82  INTENSITY_BT = 15,
83 };
84 
85 #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
86 
94 };
95 
103 };
104 
108 enum OCStatus {
114 };
115 
116 typedef struct OutputConfiguration {
120  int channels;
121  uint64_t channel_layout;
124 
128 typedef struct PredictorState {
129  float cor0;
130  float cor1;
131  float var0;
132  float var1;
133  float r0;
134  float r1;
136 
137 #define MAX_PREDICTORS 672
138 
139 #define SCALE_DIV_512 36
140 #define SCALE_ONE_POS 140
141 #define SCALE_MAX_POS 255
142 #define SCALE_MAX_DIFF 60
143 #define SCALE_DIFF_ZERO 60
144 
145 
148 typedef struct LongTermPrediction {
149  int8_t present;
150  int16_t lag;
151  float coef;
154 
158 typedef struct IndividualChannelStream {
165  const uint16_t *swb_offset;
167  int num_swb;
175 
179 typedef struct TemporalNoiseShaping {
180  int present;
181  int n_filt[8];
182  int length[8][4];
183  int direction[8][4];
184  int order[8][4];
185  float coef[8][4][TNS_MAX_ORDER];
187 
191 typedef struct DynamicRangeControl {
193  int dyn_rng_sgn[17];
194  int dyn_rng_ctl[17];
196  int band_incr;
198  int band_top[17];
203 
204 typedef struct Pulse {
206  int start;
207  int pos[4];
208  int amp[4];
209 } Pulse;
210 
214 typedef struct ChannelCoupling {
218  int id_select[8];
219  int ch_select[8];
222  float gain[16][120];
224 
228 typedef struct SingleChannelElement {
232  enum BandType band_type[128];
233  int band_type_run_end[120];
234  float sf[120];
235  int sf_idx[128];
237  DECLARE_ALIGNED(32, float, coeffs)[1024];
238  DECLARE_ALIGNED(32, float, saved)[1024];
239  DECLARE_ALIGNED(32, float, ret_buf)[2048];
240  DECLARE_ALIGNED(16, float, ltp_state)[3072];
242  float *ret;
244 
248 typedef struct ChannelElement {
249  // CPE specific
251  int ms_mode;
253  // shared
255  // CCE specific
259 
263 typedef struct AACContext {
266 
267  int is_saved;
269 
284  DECLARE_ALIGNED(32, float, buf_mdct)[1024];
305 
307  DECLARE_ALIGNED(32, float, temp)[128];
308 
310 } AACContext;
311 
312 #endif /* AVCODEC_AAC_H */
int predictor_initialized
Definition: aac.h:171
struct Pulse Pulse
Definition: aac.h:54
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sinus window.
Definition: aac.h:161
This structure describes decoded (raw) audio or video data.
Definition: avcodec.h:989
AVCodecContext * avctx
Definition: aac.h:264
Definition: aac.h:204
struct LongTermPrediction LongTermPrediction
Long Term Prediction.
Definition: aac.h:57
Definition: aac.h:50
Definition: aac.h:51
ChannelElement * che[4][MAX_ELEM_ID]
Definition: aac.h:274
float cor1
Definition: aac.h:130
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
Definition: aac.h:250
uint64_t channel_layout
Definition: aac.h:121
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
Definition: aac.h:252
#define MAX_LTP_LONG_SFB
Definition: aac.h:47
Dynamic Range Control - decoded from the bitstream but not processed further.
Definition: aac.h:191
float coef[8][4][TNS_MAX_ORDER]
Definition: aac.h:185
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
Definition: aac.h:217
ChannelPosition
Definition: aac.h:87
struct PredictorState PredictorState
Predictor State.
Spectral data are scaled white noise not coded in the bitstream.
Definition: aac.h:80
Definition: aac.h:52
int band_incr
Number of DRC bands greater than 1 having DRC info.
Definition: aac.h:196
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
Definition: aac.h:165
Definition: aac.h:61
BandType
Definition: aac.h:76
uint8_t
uint8_t layout_map[MAX_ELEM_ID *4][3]
Definition: aac.h:118
Output configuration under trial specified by an inband PCE.
Definition: aac.h:110
SingleChannelElement ch[2]
Definition: aac.h:254
Definition: aac.h:53
TemporalNoiseShaping tns
Definition: aac.h:230
CouplingPoint
The point during decoding at which channel coupling is applied.
Definition: aac.h:99
int num_coupled
number of target elements
Definition: aac.h:216
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
Definition: aac.h:195
int n_filt[8]
Definition: aac.h:181
FFTContext mdct_ltp
Definition: aac.h:293
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
Definition: aac.h:304
float saved[1024]
overlap
Definition: aac.h:238
Scalefactor data are intensity stereo positions.
Definition: aac.h:82
DSPContext dsp
Definition: aac.h:294
int id_select[8]
element id
Definition: aac.h:218
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
Definition: aac.h:275
Output configuration set in a global header but not yet locked.
Definition: aac.h:112
int random_state
Definition: aac.h:297
float var1
Definition: aac.h:132
MPEG4AudioConfig m4ac
Definition: aac.h:117
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
Definition: aac.h:193
float coeffs[1024]
coefficients for IMDCT
Definition: aac.h:237
PredictorState predictor_state[MAX_PREDICTORS]
Definition: aac.h:241
SpectralBandReplication sbr
Definition: aac.h:257
FFTContext mdct_small
Definition: aac.h:292
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
Definition: aac.h:215
FmtConvertContext fmt_conv
Definition: aac.h:295
ExtensionPayloadID
Definition: aac.h:60
Spectral Band Replication definitions and structures.
int amp[4]
Definition: aac.h:208
float temp[128]
Definition: aac.h:307
uint8_t max_sfb
number of scalefactor bands per group
Definition: aac.h:159
Definition: aac.h:56
WindowSequence
Definition: aac.h:69
int num_swb
number of scalefactor window bands
Definition: aac.h:167
struct DynamicRangeControl DynamicRangeControl
Dynamic Range Control - decoded from the bitstream but not processed further.
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
Definition: aac.h:199
Output configuration locked in place.
Definition: aac.h:113
Predictor State.
Definition: aac.h:128
AVFloatDSPContext fdsp
Definition: aac.h:296
Definition: fft.h:62
enum WindowSequence window_sequence[2]
Definition: aac.h:160
int predictor_reset_group
Definition: aac.h:172
int dyn_rng_ctl[17]
DRC magnitude information.
Definition: aac.h:194
int pos[4]
Definition: aac.h:207
float var0
Definition: aac.h:131
int length[8][4]
Definition: aac.h:182
int pce_instance_tag
Indicates with which program the DRC info is associated.
Definition: aac.h:192
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
Definition: aac.h:197
coupling parameters
Definition: aac.h:214
int tags_mapped
Definition: aac.h:276
int ch_select[8]
[0] shared list of gains; [1] list of gains for right channel; [2] list of gains for left channel; [3...
Definition: aac.h:219
float coef
Definition: aac.h:151
int is_saved
Set if elements have stored overlap from previous frame.
Definition: aac.h:267
int order[8][4]
Definition: aac.h:184
external API header
Temporal Noise Shaping.
Definition: aac.h:179
struct TemporalNoiseShaping TemporalNoiseShaping
Temporal Noise Shaping.
Long Term Prediction.
Definition: aac.h:148
main external API structure.
Definition: avcodec.h:1339
IndividualChannelStream ics
Definition: aac.h:229
#define MAX_PREDICTORS
Definition: aac.h:137
uint8_t group_len[8]
Definition: aac.h:163
#define MAX_ELEM_ID
Definition: aac.h:44
Spectral data are coded with an escape sequence.
Definition: aac.h:79
struct OutputConfiguration OutputConfiguration
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
Definition: aac.h:166
OCStatus
Output configuration status.
Definition: aac.h:108
#define MAX_CHANNELS
Definition: aac.h:43
float * ret
PCM output.
Definition: aac.h:242
#define TNS_MAX_ORDER
Definition: aac.h:46
main AAC context
Definition: aac.h:263
struct AACContext AACContext
main AAC context
LongTermPrediction ltp
Definition: aac.h:164
ChannelCoupling coup
Definition: aac.h:256
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
Definition: aac.h:251
float gain[16][120]
Definition: aac.h:222
Output configuration under trial specified by a frame header.
Definition: aac.h:111
float ltp_state[3072]
time signal for LTP
Definition: aac.h:240
uint8_t zeroes[128]
band is not coded (used by encoder)
Definition: aac.h:236
int band_type_run_end[120]
band type run end points
Definition: aac.h:233
float sf[120]
scalefactors
Definition: aac.h:234
int sf_idx[128]
scalefactor indices (used by encoder)
Definition: aac.h:235
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
Definition: aac.h:198
enum OCStatus status
Definition: aac.h:122
Scalefactor data are intensity stereo positions.
Definition: aac.h:81
int16_t lag
Definition: aac.h:150
DynamicRangeControl che_drc
Definition: aac.h:268
OutputConfiguration oc[2]
Definition: aac.h:309
int direction[8][4]
Definition: aac.h:183
uint8_t prediction_used[41]
Definition: aac.h:173
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:228
struct SingleChannelElement SingleChannelElement
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:55
Individual Channel Stream.
Definition: aac.h:158
DSP utils.
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:248
int start
Definition: aac.h:206
struct ChannelCoupling ChannelCoupling
coupling parameters
float r1
Definition: aac.h:134
Scalefactors and spectral data are all zero.
Definition: aac.h:77
int num_pulse
Definition: aac.h:205
float cor0
Definition: aac.h:129
enum BandType band_type[128]
band types
Definition: aac.h:232
AVFrame frame
Definition: aac.h:265
float ret_buf[2048]
PCM output buffer.
Definition: aac.h:239
FFTContext mdct
Definition: aac.h:291
float r0
Definition: aac.h:133
int8_t used[MAX_LTP_LONG_SFB]
Definition: aac.h:152
int8_t present
Definition: aac.h:149
struct ChannelElement ChannelElement
channel element - generic struct for SCE/CPE/CCE/LFE
Spectral Band Replication.
Definition: sbr.h:114
int layout_map_tags
Definition: aac.h:119
struct IndividualChannelStream IndividualChannelStream
Individual Channel Stream.
DSPContext.
Definition: dsputil.h:194
float buf_mdct[1024]
Definition: aac.h:284
Output unconfigured.
Definition: aac.h:109
This and later band types encode two values (rather than four) with one code word.
Definition: aac.h:78
RawDataBlockType
Definition: aac.h:49