• 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 Libav.
00007  *
00008  * Libav 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  * Libav 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 Libav; 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_OFF   = 0,
00088     AAC_CHANNEL_FRONT = 1,
00089     AAC_CHANNEL_SIDE  = 2,
00090     AAC_CHANNEL_BACK  = 3,
00091     AAC_CHANNEL_LFE   = 4,
00092     AAC_CHANNEL_CC    = 5,
00093 };
00094 
00098 enum CouplingPoint {
00099     BEFORE_TNS,
00100     BETWEEN_TNS_AND_IMDCT,
00101     AFTER_IMDCT = 3,
00102 };
00103 
00107 enum OCStatus {
00108     OC_NONE,        
00109     OC_TRIAL_PCE,   
00110     OC_TRIAL_FRAME, 
00111     OC_GLOBAL_HDR,  
00112     OC_LOCKED,      
00113 };
00114 
00118 typedef struct {
00119     float cor0;
00120     float cor1;
00121     float var0;
00122     float var1;
00123     float r0;
00124     float r1;
00125 } PredictorState;
00126 
00127 #define MAX_PREDICTORS 672
00128 
00129 #define SCALE_DIV_512    36    ///< scalefactor difference that corresponds to scale difference in 512 times
00130 #define SCALE_ONE_POS   140    ///< scalefactor index that corresponds to scale=1.0
00131 #define SCALE_MAX_POS   255    ///< scalefactor index maximum value
00132 #define SCALE_MAX_DIFF   60    ///< maximum scalefactor difference allowed by standard
00133 #define SCALE_DIFF_ZERO  60    ///< codebook index corresponding to zero scalefactor indices difference
00134 #define POW_SF2_ZERO    200    ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);
00135 
00139 typedef struct {
00140     int8_t present;
00141     int16_t lag;
00142     float coef;
00143     int8_t used[MAX_LTP_LONG_SFB];
00144 } LongTermPrediction;
00145 
00149 typedef struct {
00150     uint8_t max_sfb;            
00151     enum WindowSequence window_sequence[2];
00152     uint8_t use_kb_window[2];   
00153     int num_window_groups;
00154     uint8_t group_len[8];
00155     LongTermPrediction ltp;
00156     const uint16_t *swb_offset; 
00157     const uint8_t *swb_sizes;   
00158     int num_swb;                
00159     int num_windows;
00160     int tns_max_bands;
00161     int predictor_present;
00162     int predictor_initialized;
00163     int predictor_reset_group;
00164     uint8_t prediction_used[41];
00165 } IndividualChannelStream;
00166 
00170 typedef struct {
00171     int present;
00172     int n_filt[8];
00173     int length[8][4];
00174     int direction[8][4];
00175     int order[8][4];
00176     float coef[8][4][TNS_MAX_ORDER];
00177 } TemporalNoiseShaping;
00178 
00182 typedef struct {
00183     int pce_instance_tag;                           
00184     int dyn_rng_sgn[17];                            
00185     int dyn_rng_ctl[17];                            
00186     int exclude_mask[MAX_CHANNELS];                 
00187     int band_incr;                                  
00188     int interpolation_scheme;                       
00189     int band_top[17];                               
00190     int prog_ref_level;                             
00193 } DynamicRangeControl;
00194 
00195 typedef struct {
00196     int num_pulse;
00197     int start;
00198     int pos[4];
00199     int amp[4];
00200 } Pulse;
00201 
00205 typedef struct {
00206     enum CouplingPoint coupling_point;  
00207     int num_coupled;       
00208     enum RawDataBlockType type[8];   
00209     int id_select[8];      
00210     int ch_select[8];      
00213     float gain[16][120];
00214 } ChannelCoupling;
00215 
00219 typedef struct {
00220     IndividualChannelStream ics;
00221     TemporalNoiseShaping tns;
00222     Pulse pulse;
00223     enum BandType band_type[128];                   
00224     int band_type_run_end[120];                     
00225     float sf[120];                                  
00226     int sf_idx[128];                                
00227     uint8_t zeroes[128];                            
00228     DECLARE_ALIGNED(32, float,   coeffs)[1024];     
00229     DECLARE_ALIGNED(32, float,   saved)[1024];      
00230     DECLARE_ALIGNED(32, float,   ret)[2048];        
00231     DECLARE_ALIGNED(16, float,   ltp_state)[3072];  
00232     PredictorState predictor_state[MAX_PREDICTORS];
00233 } SingleChannelElement;
00234 
00238 typedef struct {
00239     // CPE specific
00240     int common_window;        
00241     int     ms_mode;          
00242     uint8_t ms_mask[128];     
00243     // shared
00244     SingleChannelElement ch[2];
00245     // CCE specific
00246     ChannelCoupling coup;
00247     SpectralBandReplication sbr;
00248 } ChannelElement;
00249 
00253 typedef struct {
00254     AVCodecContext *avctx;
00255     AVFrame frame;
00256 
00257     MPEG4AudioConfig m4ac;
00258 
00259     int is_saved;                 
00260     DynamicRangeControl che_drc;
00261 
00266     enum ChannelPosition che_pos[4][MAX_ELEM_ID]; 
00269     ChannelElement          *che[4][MAX_ELEM_ID];
00270     ChannelElement  *tag_che_map[4][MAX_ELEM_ID];
00271     int tags_mapped;
00279     DECLARE_ALIGNED(32, float, buf_mdct)[1024];
00286     FFTContext mdct;
00287     FFTContext mdct_small;
00288     FFTContext mdct_ltp;
00289     DSPContext dsp;
00290     FmtConvertContext fmt_conv;
00291     int random_state;
00298     float *output_data[MAX_CHANNELS];                 
00299 
00301     DECLARE_ALIGNED(32, float, temp)[128];
00302 
00303     enum OCStatus output_configured;
00304 } AACContext;
00305 
00306 #endif /* AVCODEC_AAC_H */
Generated on Sun Apr 22 2012 21:53:58 for Libav by doxygen 1.7.1