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

libavcodec/wma.h

Go to the documentation of this file.
00001 /*
00002  * WMA compatible codec
00003  * Copyright (c) 2002-2007 The FFmpeg Project
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #ifndef AVCODEC_WMA_H
00023 #define AVCODEC_WMA_H
00024 
00025 #include "get_bits.h"
00026 #include "put_bits.h"
00027 #include "dsputil.h"
00028 #include "fft.h"
00029 
00030 /* size of blocks */
00031 #define BLOCK_MIN_BITS 7
00032 #define BLOCK_MAX_BITS 11
00033 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
00034 
00035 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
00036 
00037 /* XXX: find exact max size */
00038 #define HIGH_BAND_MAX_SIZE 16
00039 
00040 #define NB_LSP_COEFS 10
00041 
00042 /* XXX: is it a suitable value ? */
00043 #define MAX_CODED_SUPERFRAME_SIZE 16384
00044 
00045 #define MAX_CHANNELS 2
00046 
00047 #define NOISE_TAB_SIZE 8192
00048 
00049 #define LSP_POW_BITS 7
00050 
00051 //FIXME should be in wmadec
00052 #define VLCBITS 9
00053 #define VLCMAX ((22+VLCBITS-1)/VLCBITS)
00054 
00055 typedef float WMACoef;          
00056 
00057 typedef struct CoefVLCTable {
00058     int n;                      
00059     int max_level;
00060     const uint32_t *huffcodes;  
00061     const uint8_t *huffbits;    
00062     const uint16_t *levels;     
00063 } CoefVLCTable;
00064 
00065 typedef struct WMACodecContext {
00066     AVCodecContext* avctx;
00067     GetBitContext gb;
00068     PutBitContext pb;
00069     int sample_rate;
00070     int nb_channels;
00071     int bit_rate;
00072     int version;                            
00073     int block_align;
00074     int use_bit_reservoir;
00075     int use_variable_block_len;
00076     int use_exp_vlc;                        
00077     int use_noise_coding;                   
00078     int byte_offset_bits;
00079     VLC exp_vlc;
00080     int exponent_sizes[BLOCK_NB_SIZES];
00081     uint16_t exponent_bands[BLOCK_NB_SIZES][25];
00082     int high_band_start[BLOCK_NB_SIZES];    
00083     int coefs_start;                        
00084     int coefs_end[BLOCK_NB_SIZES];          
00085     int exponent_high_sizes[BLOCK_NB_SIZES];
00086     int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
00087     VLC hgain_vlc;
00088 
00089     /* coded values in high bands */
00090     int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00091     int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00092 
00093     /* there are two possible tables for spectral coefficients */
00094 //FIXME the following 3 tables should be shared between decoders
00095     VLC coef_vlc[2];
00096     uint16_t *run_table[2];
00097     float *level_table[2];
00098     uint16_t *int_table[2];
00099     const CoefVLCTable *coef_vlcs[2];
00100     /* frame info */
00101     int frame_len;                          
00102     int frame_len_bits;                     
00103     int nb_block_sizes;                     
00104     /* block info */
00105     int reset_block_lengths;
00106     int block_len_bits;                     
00107     int next_block_len_bits;                
00108     int prev_block_len_bits;                
00109     int block_len;                          
00110     int block_num;                          
00111     int block_pos;                          
00112     uint8_t ms_stereo;                      
00113     uint8_t channel_coded[MAX_CHANNELS];    
00114     int exponents_bsize[MAX_CHANNELS];      
00115     DECLARE_ALIGNED(16, float, exponents)[MAX_CHANNELS][BLOCK_MAX_SIZE];
00116     float max_exponent[MAX_CHANNELS];
00117     WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
00118     DECLARE_ALIGNED(16, float, coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE];
00119     DECLARE_ALIGNED(16, FFTSample, output)[BLOCK_MAX_SIZE * 2];
00120     FFTContext mdct_ctx[BLOCK_NB_SIZES];
00121     float *windows[BLOCK_NB_SIZES];
00122     /* output buffer for one frame and the last for IMDCT windowing */
00123     DECLARE_ALIGNED(16, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
00124     /* last frame info */
00125     uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
00126     int last_bitoffset;
00127     int last_superframe_len;
00128     float noise_table[NOISE_TAB_SIZE];
00129     int noise_index;
00130     float noise_mult; /* XXX: suppress that and integrate it in the noise array */
00131     /* lsp_to_curve tables */
00132     float lsp_cos_table[BLOCK_MAX_SIZE];
00133     float lsp_pow_e_table[256];
00134     float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
00135     float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
00136     DSPContext dsp;
00137 
00138 #ifdef TRACE
00139     int frame_count;
00140 #endif
00141 } WMACodecContext;
00142 
00143 extern const uint16_t ff_wma_critical_freqs[25];
00144 extern const uint16_t ff_wma_hgain_huffcodes[37];
00145 extern const uint8_t ff_wma_hgain_huffbits[37];
00146 extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
00147 extern const uint32_t ff_aac_scalefactor_code[121];
00148 extern const uint8_t  ff_aac_scalefactor_bits[121];
00149 
00150 int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
00151                                       unsigned int decode_flags);
00152 int ff_wma_init(AVCodecContext * avctx, int flags2);
00153 int ff_wma_total_gain_to_bits(int total_gain);
00154 int ff_wma_end(AVCodecContext *avctx);
00155 unsigned int ff_wma_get_large_val(GetBitContext* gb);
00156 int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb,
00157                             VLC *vlc,
00158                             const float *level_table, const uint16_t *run_table,
00159                             int version, WMACoef *ptr, int offset,
00160                             int num_coefs, int block_len, int frame_len_bits,
00161                             int coef_nb_bits);
00162 
00163 #endif /* AVCODEC_WMA_H */

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