structs.h

00001 /*
00002 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
00003 ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
00004 **  
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 ** 
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 ** 
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software 
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 **
00019 ** Any non-GPL usage of this software or parts of this software is strictly
00020 ** forbidden.
00021 **
00022 ** Software using this code must display the following message visibly in the
00023 ** software:
00024 ** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
00025 ** in, for example, the about-box or help/startup screen.
00026 **
00027 ** Commercial non-GPL licensing of this software is possible.
00028 ** For more info contact Ahead Software through [email protected].
00029 **
00030 ** $Id: structs.h,v 1.3 2005/11/01 21:41:43 gabest Exp $
00031 **/
00032 
00033 #ifndef __STRUCTS_H__
00034 #define __STRUCTS_H__
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #include "cfft.h"
00041 #ifdef SBR_DEC
00042 #include "sbr_dec.h"
00043 #endif
00044 
00045 #define MAX_CHANNELS        64
00046 #define MAX_SYNTAX_ELEMENTS 48
00047 #define MAX_WINDOW_GROUPS    8
00048 #define MAX_SFB             51
00049 #define MAX_LTP_SFB         40
00050 #define MAX_LTP_SFB_S        8
00051 
00052 /* used to save the prediction state */
00053 typedef struct {
00054     int16_t r[2];
00055     int16_t COR[2];
00056     int16_t VAR[2];
00057 } pred_state;
00058 
00059 typedef struct {
00060     uint16_t N;
00061     cfft_info *cfft;
00062     complex_t *sincos;
00063 #ifdef PROFILE
00064     int64_t cycles;
00065     int64_t fft_cycles;
00066 #endif
00067 } mdct_info;
00068 
00069 typedef struct
00070 {
00071     const real_t *long_window[2];
00072     const real_t *short_window[2];
00073 #ifdef LD_DEC
00074     const real_t *ld_window[2];
00075 #endif
00076 
00077     mdct_info *mdct256;
00078 #ifdef LD_DEC
00079     mdct_info *mdct1024;
00080 #endif
00081     mdct_info *mdct2048;
00082 #ifdef PROFILE
00083     int64_t cycles;
00084 #endif
00085 } fb_info;
00086 
00087 typedef struct
00088 {
00089     uint8_t present;
00090 
00091     uint8_t num_bands;
00092     uint8_t pce_instance_tag;
00093     uint8_t excluded_chns_present;
00094     uint8_t band_top[17];
00095     uint8_t prog_ref_level;
00096     uint8_t dyn_rng_sgn[17];
00097     uint8_t dyn_rng_ctl[17];
00098     uint8_t exclude_mask[MAX_CHANNELS];
00099     uint8_t additional_excluded_chns[MAX_CHANNELS];
00100 
00101     real_t ctrl1;
00102     real_t ctrl2;
00103 } drc_info;
00104 
00105 typedef struct
00106 {
00107     uint8_t element_instance_tag;
00108     uint8_t object_type;
00109     uint8_t sf_index;
00110     uint8_t num_front_channel_elements;
00111     uint8_t num_side_channel_elements;
00112     uint8_t num_back_channel_elements;
00113     uint8_t num_lfe_channel_elements;
00114     uint8_t num_assoc_data_elements;
00115     uint8_t num_valid_cc_elements;
00116     uint8_t mono_mixdown_present;
00117     uint8_t mono_mixdown_element_number;
00118     uint8_t stereo_mixdown_present;
00119     uint8_t stereo_mixdown_element_number;
00120     uint8_t matrix_mixdown_idx_present;
00121     uint8_t pseudo_surround_enable;
00122     uint8_t matrix_mixdown_idx;
00123     uint8_t front_element_is_cpe[16];
00124     uint8_t front_element_tag_select[16];
00125     uint8_t side_element_is_cpe[16];
00126     uint8_t side_element_tag_select[16];
00127     uint8_t back_element_is_cpe[16];
00128     uint8_t back_element_tag_select[16];
00129     uint8_t lfe_element_tag_select[16];
00130     uint8_t assoc_data_element_tag_select[16];
00131     uint8_t cc_element_is_ind_sw[16];
00132     uint8_t valid_cc_element_tag_select[16];
00133 
00134     uint8_t channels;
00135 
00136     uint8_t comment_field_bytes;
00137     uint8_t comment_field_data[257];
00138 
00139     /* extra added values */
00140     uint8_t num_front_channels;
00141     uint8_t num_side_channels;
00142     uint8_t num_back_channels;
00143     uint8_t num_lfe_channels;
00144     uint8_t sce_channel[16];
00145     uint8_t cpe_channel[16];
00146 } program_config;
00147 
00148 typedef struct
00149 {
00150     uint16_t syncword;
00151     uint8_t id;
00152     uint8_t layer;
00153     uint8_t protection_absent;
00154     uint8_t profile;
00155     uint8_t sf_index;
00156     uint8_t private_bit;
00157     uint8_t channel_configuration;
00158     uint8_t original;
00159     uint8_t home;
00160     uint8_t emphasis;
00161     uint8_t copyright_identification_bit;
00162     uint8_t copyright_identification_start;
00163     uint16_t aac_frame_length;
00164     uint16_t adts_buffer_fullness;
00165     uint8_t no_raw_data_blocks_in_frame;
00166     uint16_t crc_check;
00167 
00168     /* control param */
00169     uint8_t old_format;
00170 } adts_header;
00171 
00172 typedef struct
00173 {
00174     uint8_t copyright_id_present;
00175     int8_t copyright_id[10];
00176     uint8_t original_copy;
00177     uint8_t home;
00178     uint8_t bitstream_type;
00179     uint32_t bitrate;
00180     uint8_t num_program_config_elements;
00181     uint32_t adif_buffer_fullness;
00182 
00183     /* maximum of 16 PCEs */
00184     program_config pce[16];
00185 } adif_header;
00186 
00187 #ifdef LTP_DEC
00188 typedef struct
00189 {
00190     uint8_t last_band;
00191     uint8_t data_present;
00192     uint16_t lag;
00193     uint8_t lag_update;
00194     uint8_t coef;
00195     uint8_t long_used[MAX_SFB];
00196     uint8_t short_used[8];
00197     uint8_t short_lag_present[8];
00198     uint8_t short_lag[8];
00199 } ltp_info;
00200 #endif
00201 
00202 #ifdef MAIN_DEC
00203 typedef struct
00204 {
00205     uint8_t limit;
00206     uint8_t predictor_reset;
00207     uint8_t predictor_reset_group_number;
00208     uint8_t prediction_used[MAX_SFB];
00209 } pred_info;
00210 #endif
00211 
00212 typedef struct
00213 {
00214     uint8_t number_pulse;
00215     uint8_t pulse_start_sfb;
00216     uint8_t pulse_offset[4];
00217     uint8_t pulse_amp[4];
00218 } pulse_info;
00219 
00220 typedef struct
00221 {
00222     uint8_t n_filt[8];
00223     uint8_t coef_res[8];
00224     uint8_t length[8][4];
00225     uint8_t order[8][4];
00226     uint8_t direction[8][4];
00227     uint8_t coef_compress[8][4];
00228     uint8_t coef[8][4][32];
00229 } tns_info;
00230 
00231 #ifdef SSR_DEC
00232 typedef struct
00233 {
00234     uint8_t max_band;
00235 
00236     uint8_t adjust_num[4][8];
00237     uint8_t alevcode[4][8][8];
00238     uint8_t aloccode[4][8][8];
00239 } ssr_info;
00240 #endif
00241 
00242 typedef struct
00243 {
00244     uint8_t max_sfb;
00245 
00246     uint8_t num_swb;
00247     uint8_t num_window_groups;
00248     uint8_t num_windows;
00249     uint8_t window_sequence;
00250     uint8_t window_group_length[8];
00251     uint8_t window_shape;
00252     uint8_t scale_factor_grouping;
00253     uint16_t sect_sfb_offset[8][15*8];
00254     uint16_t swb_offset[52];
00255 
00256     uint8_t sect_cb[8][15*8];
00257     uint16_t sect_start[8][15*8];
00258     uint16_t sect_end[8][15*8];
00259     uint8_t sfb_cb[8][8*15];
00260     uint8_t num_sec[8]; /* number of sections in a group */
00261 
00262     uint8_t global_gain;
00263     int16_t scale_factors[8][51]; /* [0..255] */
00264 
00265     uint8_t ms_mask_present;
00266     uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
00267 
00268     uint8_t noise_used;
00269     uint8_t is_used;
00270 
00271     uint8_t pulse_data_present;
00272     uint8_t tns_data_present;
00273     uint8_t gain_control_data_present;
00274     uint8_t predictor_data_present;
00275 
00276     pulse_info pul;
00277     tns_info tns;
00278 #ifdef MAIN_DEC
00279     pred_info pred;
00280 #endif
00281 #ifdef LTP_DEC
00282     ltp_info ltp;
00283     ltp_info ltp2;
00284 #endif
00285 #ifdef SSR_DEC
00286     ssr_info ssr;
00287 #endif
00288 
00289 #ifdef ERROR_RESILIENCE
00290     /* ER HCR data */
00291     uint16_t length_of_reordered_spectral_data;
00292     uint8_t length_of_longest_codeword;
00293     /* ER RLVC data */
00294     uint8_t sf_concealment;
00295     uint8_t rev_global_gain;
00296     uint16_t length_of_rvlc_sf;
00297     uint16_t dpcm_noise_nrg;
00298     uint8_t sf_escapes_present;
00299     uint8_t length_of_rvlc_escapes;
00300     uint16_t dpcm_noise_last_position;
00301 #endif
00302 } ic_stream; /* individual channel stream */
00303 
00304 typedef struct
00305 {
00306     uint8_t channel;
00307     int16_t paired_channel;
00308 
00309     uint8_t element_instance_tag;
00310     uint8_t common_window;
00311 
00312     ic_stream ics1;
00313     ic_stream ics2;
00314 } element; /* syntax element (SCE, CPE, LFE) */
00315 
00316 typedef struct mp4AudioSpecificConfig
00317 {
00318     /* Audio Specific Info */
00319     /*uint8_t*/ unsigned char objectTypeIndex;
00320     /*uint8_t*/ unsigned char samplingFrequencyIndex;
00321     /*uint32_t*/ unsigned long samplingFrequency;
00322     /*uint8_t*/ unsigned char channelsConfiguration;
00323 
00324     /* GA Specific Info */
00325     /*uint8_t*/ unsigned char frameLengthFlag;
00326     /*uint8_t*/ unsigned char dependsOnCoreCoder;
00327     /*uint16_t*/ unsigned short coreCoderDelay;
00328     /*uint8_t*/ unsigned char extensionFlag;
00329     /*uint8_t*/ unsigned char aacSectionDataResilienceFlag;
00330     /*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag;
00331     /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag;
00332     /*uint8_t*/ unsigned char epConfig;
00333 
00334     /*uint8_t*/ char sbr_present_flag;
00335     /*uint8_t*/ char forceUpSampling;
00336     /*uint8_t*/ char downSampledSBR;
00337 } mp4AudioSpecificConfig;
00338 
00339 typedef struct NeAACDecConfiguration
00340 {
00341     /*uint8_t*/ unsigned char defObjectType;
00342     /*uint32_t*/ unsigned long defSampleRate;
00343     /*uint8_t*/ unsigned char outputFormat;
00344     /*uint8_t*/ unsigned char downMatrix;
00345     /*uint8_t*/ unsigned char useOldADTSFormat;
00346     /*uint8_t*/ unsigned char dontUpSampleImplicitSBR;
00347 } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
00348 
00349 typedef struct NeAACDecFrameInfo
00350 {
00351     /*uint32_t*/ unsigned long bytesconsumed;
00352     /*uint32_t*/ unsigned long samples;
00353     /*uint8_t*/ unsigned char channels;
00354     /*uint8_t*/ unsigned char error;
00355     /*uint32_t*/ unsigned long samplerate;
00356 
00357     /* SBR: 0: off, 1: on; normal, 2: on; downsampled */
00358     /*uint8_t*/ unsigned char sbr;
00359 
00360     /* MPEG-4 ObjectType */
00361     /*uint8_t*/ unsigned char object_type;
00362 
00363     /* AAC header type; MP4 will be signalled as RAW also */
00364     /*uint8_t*/ unsigned char header_type;
00365 
00366     /* multichannel configuration */
00367     /*uint8_t*/ unsigned char num_front_channels;
00368     /*uint8_t*/ unsigned char num_side_channels;
00369     /*uint8_t*/ unsigned char num_back_channels;
00370     /*uint8_t*/ unsigned char num_lfe_channels;
00371     /*uint8_t*/ unsigned char channel_position[MAX_CHANNELS];
00372 
00373     /* PS: 0: off, 1: on */
00374     /*uint8_t*/ unsigned char ps;
00375 } NeAACDecFrameInfo;
00376 
00377 typedef struct
00378 {
00379     uint8_t adts_header_present;
00380     uint8_t adif_header_present;
00381     uint8_t sf_index;
00382     uint8_t object_type;
00383     uint8_t channelConfiguration;
00384 #ifdef ERROR_RESILIENCE
00385     uint8_t aacSectionDataResilienceFlag;
00386     uint8_t aacScalefactorDataResilienceFlag;
00387     uint8_t aacSpectralDataResilienceFlag;
00388 #endif
00389     uint16_t frameLength;
00390     uint8_t postSeekResetFlag;
00391 
00392     uint32_t frame;
00393 
00394     uint8_t downMatrix;
00395     uint8_t upMatrix;
00396     uint8_t first_syn_ele;
00397     uint8_t has_lfe;
00398     /* number of channels in current frame */
00399     uint8_t fr_channels;
00400     /* number of elements in current frame */
00401     uint8_t fr_ch_ele;
00402 
00403     /* element_output_channels:
00404        determines the number of channels the element will output
00405     */
00406     uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS];
00407     /* element_alloced:
00408        determines whether the data needed for the element is allocated or not
00409     */
00410     uint8_t element_alloced[MAX_SYNTAX_ELEMENTS];
00411     /* alloced_channels:
00412        determines the number of channels where output data is allocated for
00413     */
00414     uint8_t alloced_channels;
00415 
00416     /* output data buffer */
00417     void *sample_buffer;
00418 
00419     uint8_t window_shape_prev[MAX_CHANNELS];
00420 #ifdef LTP_DEC
00421     uint16_t ltp_lag[MAX_CHANNELS];
00422 #endif
00423     fb_info *fb;
00424     drc_info *drc;
00425 
00426     real_t *time_out[MAX_CHANNELS];
00427     real_t *fb_intermed[MAX_CHANNELS];
00428 
00429 #ifdef SBR_DEC
00430     int8_t sbr_present_flag;
00431     int8_t forceUpSampling;
00432     int8_t downSampledSBR;
00433     /* determines whether SBR data is allocated for the gives element */
00434     uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
00435 
00436     sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
00437 #endif
00438 #if (defined(PS_DEC) || defined(DRM_PS))
00439     uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
00440     uint8_t ps_used_global;
00441 #endif
00442 
00443 #ifdef SSR_DEC
00444     real_t *ssr_overlap[MAX_CHANNELS];
00445     real_t *prev_fmd[MAX_CHANNELS];
00446     real_t ipqf_buffer[MAX_CHANNELS][4][96/4];
00447 #endif
00448 
00449 #ifdef MAIN_DEC
00450     pred_state *pred_stat[MAX_CHANNELS];
00451 #endif
00452 #ifdef LTP_DEC
00453     int16_t *lt_pred_stat[MAX_CHANNELS];
00454 #endif
00455 
00456 #ifdef DRM
00457     uint8_t error_state;
00458 #endif
00459 
00460     /* Program Config Element */
00461     uint8_t pce_set;
00462     program_config pce;
00463     uint8_t element_id[MAX_CHANNELS];
00464     uint8_t internal_channel[MAX_CHANNELS];
00465 
00466     /* Configuration data */
00467     NeAACDecConfiguration config;
00468 
00469 #ifdef PROFILE
00470     int64_t cycles;
00471     int64_t spectral_cycles;
00472     int64_t output_cycles;
00473     int64_t scalefac_cycles;
00474     int64_t requant_cycles;
00475 #endif
00476 } NeAACDecStruct, *NeAACDecHandle;
00477 
00478 
00479 
00480 #ifdef __cplusplus
00481 }
00482 #endif
00483 #endif

Generated on Tue Dec 13 14:47:47 2005 for guliverkli by  doxygen 1.4.5