• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • 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 
00039 #include <stdint.h>
00040 
00041 #define MAX_CHANNELS 64
00042 #define MAX_ELEM_ID 16
00043 
00044 #define TNS_MAX_ORDER 20
00045 
00046 enum RawDataBlockType {
00047     TYPE_SCE,
00048     TYPE_CPE,
00049     TYPE_CCE,
00050     TYPE_LFE,
00051     TYPE_DSE,
00052     TYPE_PCE,
00053     TYPE_FIL,
00054     TYPE_END,
00055 };
00056 
00057 enum ExtensionPayloadID {
00058     EXT_FILL,
00059     EXT_FILL_DATA,
00060     EXT_DATA_ELEMENT,
00061     EXT_DYNAMIC_RANGE = 0xb,
00062     EXT_SBR_DATA      = 0xd,
00063     EXT_SBR_DATA_CRC  = 0xe,
00064 };
00065 
00066 enum WindowSequence {
00067     ONLY_LONG_SEQUENCE,
00068     LONG_START_SEQUENCE,
00069     EIGHT_SHORT_SEQUENCE,
00070     LONG_STOP_SEQUENCE,
00071 };
00072 
00073 enum BandType {
00074     ZERO_BT        = 0,     
00075     FIRST_PAIR_BT  = 5,     
00076     ESC_BT         = 11,    
00077     NOISE_BT       = 13,    
00078     INTENSITY_BT2  = 14,    
00079     INTENSITY_BT   = 15,    
00080 };
00081 
00082 #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
00083 
00084 enum ChannelPosition {
00085     AAC_CHANNEL_FRONT = 1,
00086     AAC_CHANNEL_SIDE  = 2,
00087     AAC_CHANNEL_BACK  = 3,
00088     AAC_CHANNEL_LFE   = 4,
00089     AAC_CHANNEL_CC    = 5,
00090 };
00091 
00095 enum CouplingPoint {
00096     BEFORE_TNS,
00097     BETWEEN_TNS_AND_IMDCT,
00098     AFTER_IMDCT = 3,
00099 };
00100 
00104 enum OCStatus {
00105     OC_NONE,        //< Output unconfigured
00106     OC_TRIAL_PCE,   //< Output configuration under trial specified by an inband PCE
00107     OC_TRIAL_FRAME, //< Output configuration under trial specified by a frame header
00108     OC_GLOBAL_HDR,  //< Output configuration set in a global header but not yet locked
00109     OC_LOCKED,      //< Output configuration locked in place
00110 };
00111 
00115 typedef struct {
00116     float cor0;
00117     float cor1;
00118     float var0;
00119     float var1;
00120     float r0;
00121     float r1;
00122 } PredictorState;
00123 
00124 #define MAX_PREDICTORS 672
00125 
00126 #define SCALE_DIV_512    36    ///< scalefactor difference that corresponds to scale difference in 512 times
00127 #define SCALE_ONE_POS   140    ///< scalefactor index that corresponds to scale=1.0
00128 #define SCALE_MAX_POS   255    ///< scalefactor index maximum value
00129 #define SCALE_MAX_DIFF   60    ///< maximum scalefactor difference allowed by standard
00130 #define SCALE_DIFF_ZERO  60    ///< codebook index corresponding to zero scalefactor indices difference
00131 
00135 typedef struct {
00136     uint8_t max_sfb;            
00137     enum WindowSequence window_sequence[2];
00138     uint8_t use_kb_window[2];   
00139     int num_window_groups;
00140     uint8_t group_len[8];
00141     const uint16_t *swb_offset; 
00142     const uint8_t *swb_sizes;   
00143     int num_swb;                
00144     int num_windows;
00145     int tns_max_bands;
00146     int predictor_present;
00147     int predictor_initialized;
00148     int predictor_reset_group;
00149     uint8_t prediction_used[41];
00150 } IndividualChannelStream;
00151 
00155 typedef struct {
00156     int present;
00157     int n_filt[8];
00158     int length[8][4];
00159     int direction[8][4];
00160     int order[8][4];
00161     float coef[8][4][TNS_MAX_ORDER];
00162 } TemporalNoiseShaping;
00163 
00167 typedef struct {
00168     int pce_instance_tag;                           
00169     int dyn_rng_sgn[17];                            
00170     int dyn_rng_ctl[17];                            
00171     int exclude_mask[MAX_CHANNELS];                 
00172     int band_incr;                                  
00173     int interpolation_scheme;                       
00174     int band_top[17];                               
00175     int prog_ref_level;                             
00178 } DynamicRangeControl;
00179 
00180 typedef struct {
00181     int num_pulse;
00182     int start;
00183     int pos[4];
00184     int amp[4];
00185 } Pulse;
00186 
00190 typedef struct {
00191     enum CouplingPoint coupling_point;  
00192     int num_coupled;       
00193     enum RawDataBlockType type[8];   
00194     int id_select[8];      
00195     int ch_select[8];      
00198     float gain[16][120];
00199 } ChannelCoupling;
00200 
00204 typedef struct {
00205     IndividualChannelStream ics;
00206     TemporalNoiseShaping tns;
00207     Pulse pulse;
00208     enum BandType band_type[128];             
00209     int band_type_run_end[120];               
00210     float sf[120];                            
00211     int sf_idx[128];                          
00212     uint8_t zeroes[128];                      
00213     DECLARE_ALIGNED(16, float, coeffs)[1024]; 
00214     DECLARE_ALIGNED(16, float, saved)[1024];  
00215     DECLARE_ALIGNED(16, float, ret)[2048];    
00216     PredictorState predictor_state[MAX_PREDICTORS];
00217 } SingleChannelElement;
00218 
00222 typedef struct {
00223     // CPE specific
00224     int common_window;        
00225     int     ms_mode;          
00226     uint8_t ms_mask[128];     
00227     // shared
00228     SingleChannelElement ch[2];
00229     // CCE specific
00230     ChannelCoupling coup;
00231     SpectralBandReplication sbr;
00232 } ChannelElement;
00233 
00237 typedef struct {
00238     AVCodecContext *avctx;
00239 
00240     MPEG4AudioConfig m4ac;
00241 
00242     int is_saved;                 
00243     DynamicRangeControl che_drc;
00244 
00249     enum ChannelPosition che_pos[4][MAX_ELEM_ID]; 
00252     ChannelElement          *che[4][MAX_ELEM_ID];
00253     ChannelElement  *tag_che_map[4][MAX_ELEM_ID];
00254     uint8_t tags_seen_this_frame[4][MAX_ELEM_ID];
00255     int tags_mapped;
00262     DECLARE_ALIGNED(16, float, buf_mdct)[1024];
00269     FFTContext mdct;
00270     FFTContext mdct_small;
00271     DSPContext dsp;
00272     int random_state;
00279     float *output_data[MAX_CHANNELS];                 
00280     float add_bias;                                   
00281     float sf_scale;                                   
00282     int sf_offset;                                    
00283 
00285     DECLARE_ALIGNED(16, float, temp)[128];
00286 
00287     enum OCStatus output_configured;
00288 } AACContext;
00289 
00290 #endif /* AVCODEC_AAC_H */

Generated on Fri Sep 16 2011 17:17:32 for FFmpeg by  doxygen 1.7.1