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