Fix vf_tcdump's compilation
[mplayer/kovensky.git] / libfaad2 / structs.h
blob8f25298e7027378100e8746bc4ff72f80f540fe7
1 /*
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2004 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.
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.
19 ** Any non-GPL usage of this software or parts of this software is strictly
20 ** forbidden.
22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
25 ** $Id: structs.h,v 1.42 2004/09/08 09:43:11 gcp Exp $
26 **/
28 #ifndef __STRUCTS_H__
29 #define __STRUCTS_H__
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #include "cfft.h"
36 #ifdef SBR_DEC
37 #include "sbr_dec.h"
38 #endif
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
47 /* used to save the prediction state */
48 typedef struct {
49 int16_t r[2];
50 int16_t COR[2];
51 int16_t VAR[2];
52 } pred_state;
54 typedef struct {
55 uint16_t N;
56 cfft_info *cfft;
57 complex_t *sincos;
58 #ifdef PROFILE
59 int64_t cycles;
60 int64_t fft_cycles;
61 #endif
62 } mdct_info;
64 typedef struct
66 const real_t *long_window[2];
67 const real_t *short_window[2];
68 #ifdef LD_DEC
69 const real_t *ld_window[2];
70 #endif
72 mdct_info *mdct256;
73 #ifdef LD_DEC
74 mdct_info *mdct1024;
75 #endif
76 mdct_info *mdct2048;
77 #ifdef PROFILE
78 int64_t cycles;
79 #endif
80 } fb_info;
82 typedef struct
84 uint8_t present;
86 uint8_t num_bands;
87 uint8_t pce_instance_tag;
88 uint8_t excluded_chns_present;
89 uint8_t band_top[17];
90 uint8_t prog_ref_level;
91 uint8_t dyn_rng_sgn[17];
92 uint8_t dyn_rng_ctl[17];
93 uint8_t exclude_mask[MAX_CHANNELS];
94 uint8_t additional_excluded_chns[MAX_CHANNELS];
96 real_t ctrl1;
97 real_t ctrl2;
98 } drc_info;
100 typedef struct
102 uint8_t element_instance_tag;
103 uint8_t object_type;
104 uint8_t sf_index;
105 uint8_t num_front_channel_elements;
106 uint8_t num_side_channel_elements;
107 uint8_t num_back_channel_elements;
108 uint8_t num_lfe_channel_elements;
109 uint8_t num_assoc_data_elements;
110 uint8_t num_valid_cc_elements;
111 uint8_t mono_mixdown_present;
112 uint8_t mono_mixdown_element_number;
113 uint8_t stereo_mixdown_present;
114 uint8_t stereo_mixdown_element_number;
115 uint8_t matrix_mixdown_idx_present;
116 uint8_t pseudo_surround_enable;
117 uint8_t matrix_mixdown_idx;
118 uint8_t front_element_is_cpe[16];
119 uint8_t front_element_tag_select[16];
120 uint8_t side_element_is_cpe[16];
121 uint8_t side_element_tag_select[16];
122 uint8_t back_element_is_cpe[16];
123 uint8_t back_element_tag_select[16];
124 uint8_t lfe_element_tag_select[16];
125 uint8_t assoc_data_element_tag_select[16];
126 uint8_t cc_element_is_ind_sw[16];
127 uint8_t valid_cc_element_tag_select[16];
129 uint8_t channels;
131 uint8_t comment_field_bytes;
132 uint8_t comment_field_data[257];
134 /* extra added values */
135 uint8_t num_front_channels;
136 uint8_t num_side_channels;
137 uint8_t num_back_channels;
138 uint8_t num_lfe_channels;
139 uint8_t sce_channel[16];
140 uint8_t cpe_channel[16];
141 } program_config;
143 typedef struct
145 uint16_t syncword;
146 uint8_t id;
147 uint8_t layer;
148 uint8_t protection_absent;
149 uint8_t profile;
150 uint8_t sf_index;
151 uint8_t private_bit;
152 uint8_t channel_configuration;
153 uint8_t original;
154 uint8_t home;
155 uint8_t emphasis;
156 uint8_t copyright_identification_bit;
157 uint8_t copyright_identification_start;
158 uint16_t aac_frame_length;
159 uint16_t adts_buffer_fullness;
160 uint8_t no_raw_data_blocks_in_frame;
161 uint16_t crc_check;
163 /* control param */
164 uint8_t old_format;
165 } adts_header;
167 typedef struct
169 uint8_t copyright_id_present;
170 int8_t copyright_id[10];
171 uint8_t original_copy;
172 uint8_t home;
173 uint8_t bitstream_type;
174 uint32_t bitrate;
175 uint8_t num_program_config_elements;
176 uint32_t adif_buffer_fullness;
178 /* maximum of 16 PCEs */
179 program_config pce[16];
180 } adif_header;
182 #ifdef LTP_DEC
183 typedef struct
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 #endif
197 #ifdef MAIN_DEC
198 typedef struct
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 #endif
207 typedef struct
209 uint8_t number_pulse;
210 uint8_t pulse_start_sfb;
211 uint8_t pulse_offset[4];
212 uint8_t pulse_amp[4];
213 } pulse_info;
215 typedef struct
217 uint8_t n_filt[8];
218 uint8_t coef_res[8];
219 uint8_t length[8][4];
220 uint8_t order[8][4];
221 uint8_t direction[8][4];
222 uint8_t coef_compress[8][4];
223 uint8_t coef[8][4][32];
224 } tns_info;
226 #ifdef SSR_DEC
227 typedef struct
229 uint8_t max_band;
231 uint8_t adjust_num[4][8];
232 uint8_t alevcode[4][8][8];
233 uint8_t aloccode[4][8][8];
234 } ssr_info;
235 #endif
237 typedef struct
239 uint8_t max_sfb;
241 uint8_t num_swb;
242 uint8_t num_window_groups;
243 uint8_t num_windows;
244 uint8_t window_sequence;
245 uint8_t window_group_length[8];
246 uint8_t window_shape;
247 uint8_t scale_factor_grouping;
248 uint16_t sect_sfb_offset[8][15*8];
249 uint16_t swb_offset[52];
251 uint8_t sect_cb[8][15*8];
252 uint16_t sect_start[8][15*8];
253 uint16_t sect_end[8][15*8];
254 uint8_t sfb_cb[8][8*15];
255 uint8_t num_sec[8]; /* number of sections in a group */
257 uint8_t global_gain;
258 int16_t scale_factors[8][51]; /* [0..255] */
260 uint8_t ms_mask_present;
261 uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
263 uint8_t noise_used;
265 uint8_t pulse_data_present;
266 uint8_t tns_data_present;
267 uint8_t gain_control_data_present;
268 uint8_t predictor_data_present;
270 pulse_info pul;
271 tns_info tns;
272 #ifdef MAIN_DEC
273 pred_info pred;
274 #endif
275 #ifdef LTP_DEC
276 ltp_info ltp;
277 ltp_info ltp2;
278 #endif
279 #ifdef SSR_DEC
280 ssr_info ssr;
281 #endif
283 #ifdef ERROR_RESILIENCE
284 /* ER HCR data */
285 uint16_t length_of_reordered_spectral_data;
286 uint8_t length_of_longest_codeword;
287 /* ER RLVC data */
288 uint8_t sf_concealment;
289 uint8_t rev_global_gain;
290 uint16_t length_of_rvlc_sf;
291 uint16_t dpcm_noise_nrg;
292 uint8_t sf_escapes_present;
293 uint8_t length_of_rvlc_escapes;
294 uint16_t dpcm_noise_last_position;
295 #endif
296 } ic_stream; /* individual channel stream */
298 typedef struct
300 uint8_t channel;
301 int16_t paired_channel;
303 uint8_t element_instance_tag;
304 uint8_t common_window;
306 ic_stream ics1;
307 ic_stream ics2;
308 } element; /* syntax element (SCE, CPE, LFE) */
310 typedef struct mp4AudioSpecificConfig
312 /* Audio Specific Info */
313 /*uint8_t*/ unsigned char objectTypeIndex;
314 /*uint8_t*/ unsigned char samplingFrequencyIndex;
315 /*uint32_t*/ unsigned long samplingFrequency;
316 /*uint8_t*/ unsigned char channelsConfiguration;
318 /* GA Specific Info */
319 /*uint8_t*/ unsigned char frameLengthFlag;
320 /*uint8_t*/ unsigned char dependsOnCoreCoder;
321 /*uint16_t*/ unsigned short coreCoderDelay;
322 /*uint8_t*/ unsigned char extensionFlag;
323 /*uint8_t*/ unsigned char aacSectionDataResilienceFlag;
324 /*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag;
325 /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag;
326 /*uint8_t*/ unsigned char epConfig;
328 /*uint8_t*/ char sbr_present_flag;
329 /*uint8_t*/ char forceUpSampling;
330 /*uint8_t*/ char downSampledSBR;
331 } mp4AudioSpecificConfig;
333 #define MAX_ASC_BYTES 64
334 typedef struct {
335 int inited;
336 int version, versionA;
337 int framelen_type;
338 int useSameStreamMux;
339 int allStreamsSameTimeFraming;
340 int numSubFrames;
341 int numPrograms;
342 int numLayers;
343 int otherDataPresent;
344 uint32_t otherDataLenBits;
345 uint32_t frameLength;
346 uint8_t ASC[MAX_ASC_BYTES];
347 uint32_t ASCbits;
348 } latm_header;
350 typedef struct NeAACDecConfiguration
352 /*uint8_t*/ unsigned char defObjectType;
353 /*uint32_t*/ unsigned long defSampleRate;
354 /*uint8_t*/ unsigned char outputFormat;
355 /*uint8_t*/ unsigned char downMatrix;
356 /*uint8_t*/ unsigned char useOldADTSFormat;
357 /*uint8_t*/ unsigned char dontUpSampleImplicitSBR;
358 } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
360 typedef struct NeAACDecFrameInfo
362 /*uint32_t*/ unsigned long bytesconsumed;
363 /*uint32_t*/ unsigned long samples;
364 /*uint8_t*/ unsigned char channels;
365 /*uint8_t*/ unsigned char error;
366 /*uint32_t*/ unsigned long samplerate;
368 /* SBR: 0: off, 1: on; normal, 2: on; downsampled */
369 /*uint8_t*/ unsigned char sbr;
371 /* MPEG-4 ObjectType */
372 /*uint8_t*/ unsigned char object_type;
374 /* AAC header type; MP4 will be signalled as RAW also */
375 /*uint8_t*/ unsigned char header_type;
377 /* multichannel configuration */
378 /*uint8_t*/ unsigned char num_front_channels;
379 /*uint8_t*/ unsigned char num_side_channels;
380 /*uint8_t*/ unsigned char num_back_channels;
381 /*uint8_t*/ unsigned char num_lfe_channels;
382 /*uint8_t*/ unsigned char channel_position[MAX_CHANNELS];
384 /* PS: 0: off, 1: on */
385 /*uint8_t*/ unsigned char ps;
386 } NeAACDecFrameInfo;
388 typedef struct
390 uint8_t adts_header_present;
391 uint8_t adif_header_present;
392 uint8_t latm_header_present;
393 uint8_t sf_index;
394 uint8_t object_type;
395 uint8_t channelConfiguration;
396 #ifdef ERROR_RESILIENCE
397 uint8_t aacSectionDataResilienceFlag;
398 uint8_t aacScalefactorDataResilienceFlag;
399 uint8_t aacSpectralDataResilienceFlag;
400 #endif
401 uint16_t frameLength;
402 uint8_t postSeekResetFlag;
404 uint32_t frame;
406 uint8_t downMatrix;
407 uint8_t upMatrix;
408 uint8_t first_syn_ele;
409 uint8_t has_lfe;
410 /* number of channels in current frame */
411 uint8_t fr_channels;
412 /* number of elements in current frame */
413 uint8_t fr_ch_ele;
415 /* element_output_channels:
416 determines the number of channels the element will output
418 uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS];
419 /* element_alloced:
420 determines whether the data needed for the element is allocated or not
422 uint8_t element_alloced[MAX_SYNTAX_ELEMENTS];
423 /* alloced_channels:
424 determines the number of channels where output data is allocated for
426 uint8_t alloced_channels;
428 /* output data buffer */
429 void *sample_buffer;
431 uint8_t window_shape_prev[MAX_CHANNELS];
432 #ifdef LTP_DEC
433 uint16_t ltp_lag[MAX_CHANNELS];
434 #endif
435 fb_info *fb;
436 drc_info *drc;
438 real_t *time_out[MAX_CHANNELS];
439 real_t *fb_intermed[MAX_CHANNELS];
441 #ifdef SBR_DEC
442 int8_t sbr_present_flag;
443 int8_t forceUpSampling;
444 int8_t downSampledSBR;
445 /* determines whether SBR data is allocated for the gives element */
446 uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
448 sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
449 #endif
450 #if (defined(PS_DEC) || defined(DRM_PS))
451 uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
452 uint8_t ps_used_global;
453 #endif
455 #ifdef SSR_DEC
456 real_t *ssr_overlap[MAX_CHANNELS];
457 real_t *prev_fmd[MAX_CHANNELS];
458 real_t ipqf_buffer[MAX_CHANNELS][4][96/4];
459 #endif
461 #ifdef MAIN_DEC
462 pred_state *pred_stat[MAX_CHANNELS];
463 #endif
464 #ifdef LTP_DEC
465 int16_t *lt_pred_stat[MAX_CHANNELS];
466 #endif
468 /* Program Config Element */
469 uint8_t pce_set;
470 program_config pce;
471 uint8_t element_id[MAX_CHANNELS];
472 uint8_t internal_channel[MAX_CHANNELS];
474 /* Configuration data */
475 NeAACDecConfiguration config;
477 #ifdef PROFILE
478 int64_t cycles;
479 int64_t spectral_cycles;
480 int64_t output_cycles;
481 int64_t scalefac_cycles;
482 int64_t requant_cycles;
483 #endif
484 latm_header latm_config;
485 } NeAACDecStruct, *NeAACDecHandle;
489 #ifdef __cplusplus
491 #endif
492 #endif