10725
|
1 /*
|
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
|
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
|
|
4 **
|
|
5 ** This program is free software; you can redistribute it and/or modify
|
|
6 ** it under the terms of the GNU General Public License as published by
|
|
7 ** the Free Software Foundation; either version 2 of the License, or
|
|
8 ** (at your option) any later version.
|
|
9 **
|
|
10 ** This program is distributed in the hope that it will be useful,
|
|
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ** GNU General Public License for more details.
|
|
14 **
|
|
15 ** You should have received a copy of the GNU General Public License
|
|
16 ** along with this program; if not, write to the Free Software
|
|
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
18 **
|
|
19 ** Any non-GPL usage of this software or parts of this software is strictly
|
|
20 ** forbidden.
|
|
21 **
|
|
22 ** Commercial non-GPL licensing of this software is possible.
|
|
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
|
|
24 **
|
10989
|
25 ** $Id: structs.h,v 1.16 2003/09/23 08:12:29 menno Exp $
|
10725
|
26 **/
|
|
27
|
|
28 #ifndef __STRUCTS_H__
|
|
29 #define __STRUCTS_H__
|
|
30
|
|
31 #ifdef __cplusplus
|
|
32 extern "C" {
|
|
33 #endif
|
|
34
|
|
35 #ifdef SBR_DEC
|
|
36 #include "sbr_dec.h"
|
|
37 #endif
|
|
38
|
|
39 #define MAX_CHANNELS 64
|
|
40 #define MAX_SYNTAX_ELEMENTS 48
|
|
41 #define MAX_WINDOW_GROUPS 8
|
|
42 #define MAX_SFB 51
|
|
43 #define MAX_LTP_SFB 40
|
|
44 #define MAX_LTP_SFB_S 8
|
|
45
|
|
46 /* used to save the prediction state */
|
|
47 typedef struct {
|
|
48 real_t r[2];
|
|
49 real_t KOR[2];
|
|
50 real_t VAR[2];
|
|
51 } pred_state;
|
|
52
|
|
53 typedef struct
|
|
54 {
|
|
55 uint16_t n;
|
|
56 uint16_t ifac[15];
|
|
57 complex_t *work;
|
|
58 complex_t *tab;
|
|
59 } cfft_info;
|
|
60
|
|
61 typedef struct {
|
|
62 uint16_t N;
|
|
63 cfft_info *cfft;
|
|
64 complex_t *sincos;
|
|
65 complex_t *Z1;
|
|
66 } mdct_info;
|
|
67
|
|
68 typedef struct
|
|
69 {
|
|
70 real_t *long_window[2];
|
|
71 real_t *short_window[2];
|
|
72 #ifdef LD_DEC
|
|
73 real_t *ld_window[2];
|
|
74 #endif
|
|
75
|
|
76 mdct_info *mdct256;
|
|
77 #ifdef LD_DEC
|
|
78 mdct_info *mdct1024;
|
|
79 #endif
|
|
80 mdct_info *mdct2048;
|
|
81 } fb_info;
|
|
82
|
|
83 typedef struct
|
|
84 {
|
|
85 uint8_t present;
|
|
86
|
|
87 uint8_t num_bands;
|
|
88 uint8_t pce_instance_tag;
|
|
89 uint8_t excluded_chns_present;
|
|
90 uint8_t band_top[17];
|
|
91 uint8_t prog_ref_level;
|
|
92 uint8_t dyn_rng_sgn[17];
|
|
93 uint8_t dyn_rng_ctl[17];
|
|
94 uint8_t exclude_mask[MAX_CHANNELS];
|
|
95 uint8_t additional_excluded_chns[MAX_CHANNELS];
|
|
96
|
|
97 real_t ctrl1;
|
|
98 real_t ctrl2;
|
|
99 } drc_info;
|
|
100
|
|
101 typedef struct
|
|
102 {
|
|
103 uint8_t element_instance_tag;
|
|
104 uint8_t object_type;
|
|
105 uint8_t sf_index;
|
|
106 uint8_t num_front_channel_elements;
|
|
107 uint8_t num_side_channel_elements;
|
|
108 uint8_t num_back_channel_elements;
|
|
109 uint8_t num_lfe_channel_elements;
|
|
110 uint8_t num_assoc_data_elements;
|
|
111 uint8_t num_valid_cc_elements;
|
|
112 uint8_t mono_mixdown_present;
|
|
113 uint8_t mono_mixdown_element_number;
|
|
114 uint8_t stereo_mixdown_present;
|
|
115 uint8_t stereo_mixdown_element_number;
|
|
116 uint8_t matrix_mixdown_idx_present;
|
|
117 uint8_t pseudo_surround_enable;
|
|
118 uint8_t matrix_mixdown_idx;
|
|
119 uint8_t front_element_is_cpe[16];
|
|
120 uint8_t front_element_tag_select[16];
|
|
121 uint8_t side_element_is_cpe[16];
|
|
122 uint8_t side_element_tag_select[16];
|
|
123 uint8_t back_element_is_cpe[16];
|
|
124 uint8_t back_element_tag_select[16];
|
|
125 uint8_t lfe_element_tag_select[16];
|
|
126 uint8_t assoc_data_element_tag_select[16];
|
|
127 uint8_t cc_element_is_ind_sw[16];
|
|
128 uint8_t valid_cc_element_tag_select[16];
|
|
129
|
|
130 uint8_t channels;
|
|
131
|
|
132 uint8_t comment_field_bytes;
|
|
133 uint8_t comment_field_data[257];
|
|
134
|
|
135 /* extra added values */
|
|
136 uint8_t num_front_channels;
|
|
137 uint8_t num_side_channels;
|
|
138 uint8_t num_back_channels;
|
|
139 uint8_t num_lfe_channels;
|
|
140 uint8_t sce_channel[16];
|
|
141 uint8_t cpe_channel[16];
|
|
142 } program_config;
|
|
143
|
|
144 typedef struct
|
|
145 {
|
|
146 uint16_t syncword;
|
|
147 uint8_t id;
|
|
148 uint8_t layer;
|
|
149 uint8_t protection_absent;
|
|
150 uint8_t profile;
|
|
151 uint8_t sf_index;
|
|
152 uint8_t private_bit;
|
|
153 uint8_t channel_configuration;
|
|
154 uint8_t original;
|
|
155 uint8_t home;
|
|
156 uint8_t emphasis;
|
|
157 uint8_t copyright_identification_bit;
|
|
158 uint8_t copyright_identification_start;
|
|
159 uint16_t aac_frame_length;
|
|
160 uint16_t adts_buffer_fullness;
|
|
161 uint8_t no_raw_data_blocks_in_frame;
|
|
162 uint16_t crc_check;
|
10989
|
163
|
|
164 /* control param */
|
|
165 uint8_t old_format;
|
10725
|
166 } adts_header;
|
|
167
|
|
168 typedef struct
|
|
169 {
|
|
170 uint8_t copyright_id_present;
|
|
171 int8_t copyright_id[10];
|
|
172 uint8_t original_copy;
|
|
173 uint8_t home;
|
|
174 uint8_t bitstream_type;
|
|
175 uint32_t bitrate;
|
|
176 uint8_t num_program_config_elements;
|
|
177 uint32_t adif_buffer_fullness;
|
|
178
|
|
179 /* maximum of 16 PCEs */
|
|
180 program_config pce[16];
|
|
181 } adif_header;
|
|
182
|
|
183 typedef struct
|
|
184 {
|
|
185 uint8_t last_band;
|
|
186 uint8_t data_present;
|
|
187 uint16_t lag;
|
|
188 uint8_t lag_update;
|
|
189 uint8_t coef;
|
|
190 uint8_t long_used[MAX_SFB];
|
|
191 uint8_t short_used[8];
|
|
192 uint8_t short_lag_present[8];
|
|
193 uint8_t short_lag[8];
|
|
194 } ltp_info;
|
|
195
|
|
196 typedef struct
|
|
197 {
|
|
198 uint8_t limit;
|
|
199 uint8_t predictor_reset;
|
|
200 uint8_t predictor_reset_group_number;
|
|
201 uint8_t prediction_used[MAX_SFB];
|
|
202 } pred_info;
|
|
203
|
|
204 typedef struct
|
|
205 {
|
|
206 uint8_t number_pulse;
|
|
207 uint8_t pulse_start_sfb;
|
|
208 uint8_t pulse_offset[4];
|
|
209 uint8_t pulse_amp[4];
|
|
210 } pulse_info;
|
|
211
|
|
212 typedef struct
|
|
213 {
|
|
214 uint8_t n_filt[8];
|
|
215 uint8_t coef_res[8];
|
|
216 uint8_t length[8][4];
|
|
217 uint8_t order[8][4];
|
|
218 uint8_t direction[8][4];
|
|
219 uint8_t coef_compress[8][4];
|
|
220 uint8_t coef[8][4][32];
|
|
221 } tns_info;
|
|
222
|
|
223 #ifdef SSR_DEC
|
|
224 typedef struct
|
|
225 {
|
|
226 uint8_t max_band;
|
|
227
|
|
228 uint8_t adjust_num[4][8];
|
|
229 uint8_t alevcode[4][8][8];
|
|
230 uint8_t aloccode[4][8][8];
|
|
231 } ssr_info;
|
|
232 #endif
|
|
233
|
|
234 typedef struct
|
|
235 {
|
|
236 uint8_t max_sfb;
|
|
237
|
|
238 uint8_t num_swb;
|
|
239 uint8_t num_window_groups;
|
|
240 uint8_t num_windows;
|
|
241 uint8_t window_sequence;
|
|
242 uint8_t window_group_length[8];
|
|
243 uint8_t window_shape;
|
|
244 uint8_t scale_factor_grouping;
|
|
245 uint16_t sect_sfb_offset[8][15*8];
|
|
246 uint16_t swb_offset[52];
|
|
247
|
|
248 uint8_t sect_cb[8][15*8];
|
|
249 uint16_t sect_start[8][15*8];
|
|
250 uint16_t sect_end[8][15*8];
|
|
251 uint8_t sfb_cb[8][8*15];
|
|
252 uint8_t num_sec[8]; /* number of sections in a group */
|
|
253
|
|
254 uint8_t global_gain;
|
|
255 int16_t scale_factors[8][51];
|
|
256
|
|
257 uint8_t ms_mask_present;
|
|
258 uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
|
|
259
|
|
260 uint8_t noise_used;
|
|
261
|
|
262 uint8_t pulse_data_present;
|
|
263 uint8_t tns_data_present;
|
|
264 uint8_t gain_control_data_present;
|
|
265 uint8_t predictor_data_present;
|
|
266
|
|
267 pulse_info pul;
|
|
268 tns_info tns;
|
|
269 pred_info pred;
|
|
270 ltp_info ltp;
|
|
271 ltp_info ltp2;
|
|
272 #ifdef SSR_DEC
|
|
273 ssr_info ssr;
|
|
274 #endif
|
|
275
|
|
276 #ifdef ERROR_RESILIENCE
|
|
277 /* ER HCR data */
|
|
278 uint16_t length_of_reordered_spectral_data;
|
|
279 uint8_t length_of_longest_codeword;
|
|
280 /* ER RLVC data */
|
|
281 uint8_t sf_concealment;
|
|
282 uint8_t rev_global_gain;
|
|
283 uint16_t length_of_rvlc_sf;
|
|
284 uint16_t dpcm_noise_nrg;
|
|
285 uint8_t sf_escapes_present;
|
|
286 uint8_t length_of_rvlc_escapes;
|
|
287 uint16_t dpcm_noise_last_position;
|
|
288 #endif
|
|
289 } ic_stream; /* individual channel stream */
|
|
290
|
|
291 typedef struct
|
|
292 {
|
|
293 uint8_t ele_id;
|
|
294
|
|
295 uint8_t channel;
|
|
296 int16_t paired_channel;
|
|
297
|
|
298 uint8_t element_instance_tag;
|
|
299 uint8_t common_window;
|
|
300
|
|
301 ic_stream ics1;
|
|
302 ic_stream ics2;
|
|
303 } element; /* syntax element (SCE, CPE, LFE) */
|
|
304
|
|
305 typedef struct mp4AudioSpecificConfig
|
|
306 {
|
|
307 /* Audio Specific Info */
|
|
308 uint8_t objectTypeIndex;
|
|
309 uint8_t samplingFrequencyIndex;
|
|
310 uint32_t samplingFrequency;
|
|
311 uint8_t channelsConfiguration;
|
|
312
|
|
313 /* GA Specific Info */
|
|
314 uint8_t frameLengthFlag;
|
|
315 uint8_t dependsOnCoreCoder;
|
|
316 uint16_t coreCoderDelay;
|
|
317 uint8_t extensionFlag;
|
|
318 uint8_t aacSectionDataResilienceFlag;
|
|
319 uint8_t aacScalefactorDataResilienceFlag;
|
|
320 uint8_t aacSpectralDataResilienceFlag;
|
|
321 uint8_t epConfig;
|
|
322
|
|
323 int8_t sbr_present_flag;
|
10989
|
324 int8_t forceUpSampling;
|
10725
|
325 } mp4AudioSpecificConfig;
|
|
326
|
|
327 typedef struct faacDecConfiguration
|
|
328 {
|
|
329 uint8_t defObjectType;
|
|
330 uint32_t defSampleRate;
|
|
331 uint8_t outputFormat;
|
|
332 uint8_t downMatrix;
|
10989
|
333 uint8_t useOldADTSFormat;
|
10725
|
334 } faacDecConfiguration, *faacDecConfigurationPtr;
|
|
335
|
|
336 typedef struct faacDecFrameInfo
|
|
337 {
|
|
338 uint32_t bytesconsumed;
|
|
339 uint32_t samples;
|
|
340 uint8_t channels;
|
|
341 uint8_t error;
|
|
342 uint32_t samplerate;
|
|
343
|
10989
|
344 /* SBR: 0: off, 1: on; normal, 2: on; downsampled */
|
|
345 uint8_t sbr;
|
|
346
|
|
347 /* MPEG-4 ObjectType */
|
|
348 uint8_t object_type;
|
|
349
|
|
350 /* AAC header type; MP4 will be signalled as RAW also */
|
|
351 uint8_t header_type;
|
|
352
|
10725
|
353 /* multichannel configuration */
|
|
354 uint8_t num_front_channels;
|
|
355 uint8_t num_side_channels;
|
|
356 uint8_t num_back_channels;
|
|
357 uint8_t num_lfe_channels;
|
|
358 uint8_t channel_position[MAX_CHANNELS];
|
|
359 } faacDecFrameInfo;
|
|
360
|
|
361 typedef struct
|
|
362 {
|
|
363 uint8_t adts_header_present;
|
|
364 uint8_t adif_header_present;
|
|
365 uint8_t sf_index;
|
|
366 uint8_t object_type;
|
|
367 uint8_t channelConfiguration;
|
|
368 #ifdef ERROR_RESILIENCE
|
|
369 uint8_t aacSectionDataResilienceFlag;
|
|
370 uint8_t aacScalefactorDataResilienceFlag;
|
|
371 uint8_t aacSpectralDataResilienceFlag;
|
|
372 #endif
|
|
373 uint16_t frameLength;
|
|
374 uint8_t postSeekResetFlag;
|
|
375
|
|
376 uint32_t frame;
|
|
377
|
|
378 uint8_t downMatrix;
|
|
379 uint8_t first_syn_ele;
|
|
380 uint8_t last_syn_ele;
|
|
381 uint8_t has_lfe;
|
|
382 uint8_t fr_channels;
|
|
383 uint8_t fr_ch_ele;
|
|
384
|
|
385 void *sample_buffer;
|
|
386
|
|
387 uint8_t window_shape_prev[MAX_CHANNELS];
|
|
388 #ifdef LTP_DEC
|
|
389 uint16_t ltp_lag[MAX_CHANNELS];
|
|
390 #endif
|
|
391 fb_info *fb;
|
|
392 drc_info *drc;
|
|
393
|
|
394 real_t *time_out[MAX_CHANNELS];
|
|
395
|
|
396 #ifdef SBR_DEC
|
|
397 int8_t sbr_present_flag;
|
10989
|
398 int8_t forceUpSampling;
|
10725
|
399
|
|
400 real_t *time_out2[MAX_CHANNELS];
|
|
401
|
|
402 uint8_t sbr_used[32];
|
|
403
|
|
404 sbr_info *sbr[32];
|
10989
|
405 #ifdef DRM
|
|
406 int8_t lcstereo_flag;
|
|
407 #endif
|
10725
|
408 #endif
|
|
409
|
|
410 #ifdef SSR_DEC
|
|
411 real_t *ssr_overlap[MAX_CHANNELS];
|
|
412 real_t *prev_fmd[MAX_CHANNELS];
|
|
413 real_t ipqf_buffer[MAX_CHANNELS][4][96/4];
|
|
414 #endif
|
|
415
|
|
416 #ifdef MAIN_DEC
|
|
417 pred_state *pred_stat[MAX_CHANNELS];
|
|
418 #endif
|
|
419 #ifdef LTP_DEC
|
|
420 real_t *lt_pred_stat[MAX_CHANNELS];
|
|
421 #endif
|
|
422
|
|
423 #ifndef FIXED_POINT
|
|
424 #if POW_TABLE_SIZE
|
|
425 real_t *pow2_table;
|
|
426 #endif
|
|
427 #endif
|
|
428
|
|
429 /* Program Config Element */
|
|
430 uint8_t pce_set;
|
|
431 program_config pce;
|
|
432 uint8_t channel_element[MAX_CHANNELS];
|
|
433 uint8_t internal_channel[MAX_CHANNELS];
|
|
434
|
|
435 /* Configuration data */
|
|
436 faacDecConfiguration config;
|
|
437 } faacDecStruct, *faacDecHandle;
|
|
438
|
|
439
|
|
440
|
|
441 #ifdef __cplusplus
|
|
442 }
|
|
443 #endif
|
|
444 #endif
|