• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavcodec/aac.h

Go to the documentation of this file.
00001 /*
00002  * AAC definitions and structures
00003  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
00004  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
00005  *
00006  * This file is part of FFmpeg.
00007  *
00008  * FFmpeg is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * FFmpeg is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with FFmpeg; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00030 #ifndef AVCODEC_AAC_H
00031 #define AVCODEC_AAC_H
00032 
00033 #include "avcodec.h"
00034 #include "dsputil.h"
00035 #include "fft.h"
00036 #include "mpeg4audio.h"
00037 #include "sbr.h"
00038 #include "fmtconvert.h"
00039 
00040 #include <stdint.h>
00041 
00042 #define MAX_CHANNELS 64
00043 #define MAX_ELEM_ID 16
00044 
00045 #define TNS_MAX_ORDER 20
00046 #define MAX_LTP_LONG_SFB 40
00047 
00048 enum RawDataBlockType {
00049     TYPE_SCE,
00050     TYPE_CPE,
00051     TYPE_CCE,
00052     TYPE_LFE,
00053     TYPE_DSE,
00054     TYPE_PCE,
00055     TYPE_FIL,
00056     TYPE_END,
00057 };
00058 
00059 enum ExtensionPayloadID {
00060     EXT_FILL,
00061     EXT_FILL_DATA,
00062     EXT_DATA_ELEMENT,
00063     EXT_DYNAMIC_RANGE = 0xb,
00064     EXT_SBR_DATA      = 0xd,
00065     EXT_SBR_DATA_CRC  = 0xe,
00066 };
00067 
00068 enum WindowSequence {
00069     ONLY_LONG_SEQUENCE,
00070     LONG_START_SEQUENCE,
00071     EIGHT_SHORT_SEQUENCE,
00072     LONG_STOP_SEQUENCE,
00073 };
00074 
00075 enum BandType {
00076     ZERO_BT        = 0,     
00077     FIRST_PAIR_BT  = 5,     
00078     ESC_BT         = 11,    
00079     NOISE_BT       = 13,    
00080     INTENSITY_BT2  = 14,    
00081     INTENSITY_BT   = 15,    
00082 };
00083 
00084 #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
00085 
00086 enum ChannelPosition {
00087     AAC_CHANNEL_FRONT = 1,
00088     AAC_CHANNEL_SIDE  = 2,
00089     AAC_CHANNEL_BACK  = 3,
00090     AAC_CHANNEL_LFE   = 4,
00091     AAC_CHANNEL_CC    = 5,
00092 };
00093 
00097 enum CouplingPoint {
00098     BEFORE_TNS,
00099     BETWEEN_TNS_AND_IMDCT,
00100     AFTER_IMDCT = 3,
00101 };
00102 
00106 enum OCStatus {
00107     OC_NONE,        //< Output unconfigured
00108     OC_TRIAL_PCE,   //< Output configuration under trial specified by an inband PCE
00109     OC_TRIAL_FRAME, //< Output configuration under trial specified by a frame header
00110     OC_GLOBAL_HDR,  //< Output configuration set in a global header but not yet locked
00111     OC_LOCKED,      //< Output configuration locked in place
00112 };
00113 
00117 typedef struct {
00118     float cor0;
00119     float cor1;
00120     float var0;
00121     float var1;
00122     float r0;
00123     float r1;
00124 } PredictorState;
00125 
00126 #define MAX_PREDICTORS 672
00127 
00128 #define SCALE_DIV_512    36    ///< scalefactor difference that corresponds to scale difference in 512 times
00129 #define SCALE_ONE_POS   140    ///< scalefactor index that corresponds to scale=1.0
00130 #define SCALE_MAX_POS   255    ///< scalefactor index maximum value
00131 #define SCALE_MAX_DIFF   60    ///< maximum scalefactor difference allowed by standard
00132 #define SCALE_DIFF_ZERO  60    ///< codebook index corresponding to zero scalefactor indices difference
00133 #define POW_SF2_ZERO    200    ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);
00134 
00138 typedef struct {
00139     int8_t present;
00140     int16_t lag;
00141     float coef;
00142     int8_t used[MAX_LTP_LONG_SFB];
00143 } LongTermPrediction;
00144 
00148 typedef struct {
00149     uint8_t max_sfb;            
00150     enum WindowSequence window_sequence[2];
00151     uint8_t use_kb_window[2];   
00152     int num_window_groups;
00153     uint8_t group_len[8];
00154     LongTermPrediction ltp;
00155     const uint16_t *swb_offset; 
00156     const uint8_t *swb_sizes;   
00157     int num_swb;                
00158     int num_windows;
00159     int tns_max_bands;
00160     int predictor_present;
00161     int predictor_initialized;
00162     int predictor_reset_group;
00163     uint8_t prediction_used[41];
00164 } IndividualChannelStream;
00165 
00169 typedef struct {
00170     int present;
00171     int n_filt[8];
00172     int length[8][4];
00173     int direction[8][4];
00174     int order[8][4];
00175     float coef[8][4][TNS_MAX_ORDER];
00176 } TemporalNoiseShaping;
00177 
00181 typedef struct {
00182     int pce_instance_tag;                           
00183     int dyn_rng_sgn[17];                            
00184     int dyn_rng_ctl[17];                            
00185     int exclude_mask[MAX_CHANNELS];                 
00186     int band_incr;                                  
00187     int interpolation_scheme;                       
00188     int band_top[17];                               
00189     int prog_ref_level;                             
00192 } DynamicRangeControl;
00193 
00194 typedef struct {
00195     int num_pulse;
00196     int start;
00197     int pos[4];
00198     int amp[4];
00199 } Pulse;
00200 
00204 typedef struct {
00205     enum CouplingPoint coupling_point;  
00206     int num_coupled;       
00207     enum RawDataBlockType type[8];   
00208     int id_select[8];      
00209     int ch_select[8];      
00212     float gain[16][120];
00213 } ChannelCoupling;
00214 
00218 typedef struct {
00219     IndividualChannelStream ics;
00220     TemporalNoiseShaping tns;
00221     Pulse pulse;
00222     enum BandType band_type[128];                   
00223     int band_type_run_end[120];                     
00224     float sf[120];                                  
00225     int sf_idx[128];                                
00226     uint8_t zeroes[128];                            
00227     DECLARE_ALIGNED(32, float,   coeffs)[1024];     
00228     DECLARE_ALIGNED(32, float,   saved)[1024];      
00229     DECLARE_ALIGNED(32, float,   ret)[2048];        
00230     DECLARE_ALIGNED(16, float,   ltp_state)[3072];  
00231     PredictorState predictor_state[MAX_PREDICTORS];
00232 } SingleChannelElement;
00233 
00237 typedef struct {
00238     // CPE specific
00239     int common_window;        
00240     int     ms_mode;          
00241     uint8_t ms_mask[128];     
00242     // shared
00243     SingleChannelElement ch[2];
00244     // CCE specific
00245     ChannelCoupling coup;
00246     SpectralBandReplication sbr;
00247 } ChannelElement;
00248 
00252 typedef struct {
00253     AVCodecContext *avctx;
00254 
00255     MPEG4AudioConfig m4ac;
00256 
00257     int is_saved;                 
00258     DynamicRangeControl che_drc;
00259 
00264     enum ChannelPosition che_pos[4][MAX_ELEM_ID]; 
00267     ChannelElement          *che[4][MAX_ELEM_ID];
00268     ChannelElement  *tag_che_map[4][MAX_ELEM_ID];
00269     int tags_mapped;
00277     DECLARE_ALIGNED(32, float, buf_mdct)[1024];
00284     FFTContext mdct;
00285     FFTContext mdct_small;
00286     FFTContext mdct_ltp;
00287     DSPContext dsp;
00288     FmtConvertContext fmt_conv;
00289     int random_state;
00296     float *output_data[MAX_CHANNELS];                 
00297 
00299     DECLARE_ALIGNED(32, float, temp)[128];
00300 
00301     enum OCStatus output_configured;
00302 } AACContext;
00303 
00304 #endif /* AVCODEC_AAC_H */

Generated on Wed Apr 11 2012 07:31:32 for FFmpeg by  doxygen 1.7.1