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