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

libavcodec/wma.h

Go to the documentation of this file.
00001 /*
00002  * WMA compatible codec
00003  * Copyright (c) 2002-2007 The Libav Project
00004  *
00005  * This file is part of Libav.
00006  *
00007  * Libav 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  * Libav 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 Libav; 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 #include "fmtconvert.h"
00030 
00031 /* size of blocks */
00032 #define BLOCK_MIN_BITS 7
00033 #define BLOCK_MAX_BITS 11
00034 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
00035 
00036 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
00037 
00038 /* XXX: find exact max size */
00039 #define HIGH_BAND_MAX_SIZE 16
00040 
00041 #define NB_LSP_COEFS 10
00042 
00043 /* XXX: is it a suitable value ? */
00044 #define MAX_CODED_SUPERFRAME_SIZE 16384
00045 
00046 #define MAX_CHANNELS 2
00047 
00048 #define NOISE_TAB_SIZE 8192
00049 
00050 #define LSP_POW_BITS 7
00051 
00052 //FIXME should be in wmadec
00053 #define VLCBITS 9
00054 #define VLCMAX ((22+VLCBITS-1)/VLCBITS)
00055 
00056 typedef float WMACoef;          
00057 
00058 typedef struct CoefVLCTable {
00059     int n;                      
00060     int max_level;
00061     const uint32_t *huffcodes;  
00062     const uint8_t *huffbits;    
00063     const uint16_t *levels;     
00064 } CoefVLCTable;
00065 
00066 typedef struct WMACodecContext {
00067     AVCodecContext* avctx;
00068     AVFrame frame;
00069     GetBitContext gb;
00070     PutBitContext pb;
00071     int sample_rate;
00072     int nb_channels;
00073     int bit_rate;
00074     int version;                            
00075     int block_align;
00076     int use_bit_reservoir;
00077     int use_variable_block_len;
00078     int use_exp_vlc;                        
00079     int use_noise_coding;                   
00080     int byte_offset_bits;
00081     VLC exp_vlc;
00082     int exponent_sizes[BLOCK_NB_SIZES];
00083     uint16_t exponent_bands[BLOCK_NB_SIZES][25];
00084     int high_band_start[BLOCK_NB_SIZES];    
00085     int coefs_start;                        
00086     int coefs_end[BLOCK_NB_SIZES];          
00087     int exponent_high_sizes[BLOCK_NB_SIZES];
00088     int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
00089     VLC hgain_vlc;
00090 
00091     /* coded values in high bands */
00092     int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00093     int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00094 
00095     /* there are two possible tables for spectral coefficients */
00096 //FIXME the following 3 tables should be shared between decoders
00097     VLC coef_vlc[2];
00098     uint16_t *run_table[2];
00099     float *level_table[2];
00100     uint16_t *int_table[2];
00101     const CoefVLCTable *coef_vlcs[2];
00102     /* frame info */
00103     int frame_len;                          
00104     int frame_len_bits;                     
00105     int nb_block_sizes;                     
00106     /* block info */
00107     int reset_block_lengths;
00108     int block_len_bits;                     
00109     int next_block_len_bits;                
00110     int prev_block_len_bits;                
00111     int block_len;                          
00112     int block_num;                          
00113     int block_pos;                          
00114     uint8_t ms_stereo;                      
00115     uint8_t channel_coded[MAX_CHANNELS];    
00116     int exponents_bsize[MAX_CHANNELS];      
00117     DECLARE_ALIGNED(32, float, exponents)[MAX_CHANNELS][BLOCK_MAX_SIZE];
00118     float max_exponent[MAX_CHANNELS];
00119     WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
00120     DECLARE_ALIGNED(32, float, coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE];
00121     DECLARE_ALIGNED(32, FFTSample, output)[BLOCK_MAX_SIZE * 2];
00122     FFTContext mdct_ctx[BLOCK_NB_SIZES];
00123     float *windows[BLOCK_NB_SIZES];
00124     /* output buffer for one frame and the last for IMDCT windowing */
00125     DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
00126     /* last frame info */
00127     uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; /* padding added */
00128     int last_bitoffset;
00129     int last_superframe_len;
00130     float noise_table[NOISE_TAB_SIZE];
00131     int noise_index;
00132     float noise_mult; /* XXX: suppress that and integrate it in the noise array */
00133     /* lsp_to_curve tables */
00134     float lsp_cos_table[BLOCK_MAX_SIZE];
00135     float lsp_pow_e_table[256];
00136     float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
00137     float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
00138     DSPContext dsp;
00139     FmtConvertContext fmt_conv;
00140 
00141 #ifdef TRACE
00142     int frame_count;
00143 #endif
00144 } WMACodecContext;
00145 
00146 extern const uint16_t ff_wma_critical_freqs[25];
00147 extern const uint16_t ff_wma_hgain_huffcodes[37];
00148 extern const uint8_t ff_wma_hgain_huffbits[37];
00149 extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
00150 extern const uint32_t ff_aac_scalefactor_code[121];
00151 extern const uint8_t  ff_aac_scalefactor_bits[121];
00152 
00153 int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
00154                                       unsigned int decode_flags);
00155 int ff_wma_init(AVCodecContext * avctx, int flags2);
00156 int ff_wma_total_gain_to_bits(int total_gain);
00157 int ff_wma_end(AVCodecContext *avctx);
00158 unsigned int ff_wma_get_large_val(GetBitContext* gb);
00159 int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb,
00160                             VLC *vlc,
00161                             const float *level_table, const uint16_t *run_table,
00162                             int version, WMACoef *ptr, int offset,
00163                             int num_coefs, int block_len, int frame_len_bits,
00164                             int coef_nb_bits);
00165 
00166 #endif /* AVCODEC_WMA_H */
Generated on Thu Jan 24 2013 17:08:54 for Libav by doxygen 1.7.1