• 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 "bitstream.h"
00026 #include "dsputil.h"
00027 
00028 /* size of blocks */
00029 #define BLOCK_MIN_BITS 7
00030 #define BLOCK_MAX_BITS 11
00031 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
00032 
00033 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
00034 
00035 /* XXX: find exact max size */
00036 #define HIGH_BAND_MAX_SIZE 16
00037 
00038 #define NB_LSP_COEFS 10
00039 
00040 /* XXX: is it a suitable value ? */
00041 #define MAX_CODED_SUPERFRAME_SIZE 16384
00042 
00043 #define MAX_CHANNELS 2
00044 
00045 #define NOISE_TAB_SIZE 8192
00046 
00047 #define LSP_POW_BITS 7
00048 
00049 //FIXME should be in wmadec
00050 #define VLCBITS 9
00051 #define VLCMAX ((22+VLCBITS-1)/VLCBITS)
00052 
00053 typedef struct CoefVLCTable {
00054     int n;                      
00055     int max_level;
00056     const uint32_t *huffcodes;  
00057     const uint8_t *huffbits;    
00058     const uint16_t *levels;     
00059 } CoefVLCTable;
00060 
00061 typedef struct WMACodecContext {
00062     AVCodecContext* avctx;
00063     GetBitContext gb;
00064     PutBitContext pb;
00065     int sample_rate;
00066     int nb_channels;
00067     int bit_rate;
00068     int version;                            
00069     int block_align;
00070     int use_bit_reservoir;
00071     int use_variable_block_len;
00072     int use_exp_vlc;                        
00073     int use_noise_coding;                   
00074     int byte_offset_bits;
00075     VLC exp_vlc;
00076     int exponent_sizes[BLOCK_NB_SIZES];
00077     uint16_t exponent_bands[BLOCK_NB_SIZES][25];
00078     int high_band_start[BLOCK_NB_SIZES];    
00079     int coefs_start;                        
00080     int coefs_end[BLOCK_NB_SIZES];          
00081     int exponent_high_sizes[BLOCK_NB_SIZES];
00082     int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
00083     VLC hgain_vlc;
00084 
00085     /* coded values in high bands */
00086     int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00087     int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
00088 
00089     /* there are two possible tables for spectral coefficients */
00090 //FIXME the following 3 tables should be shared between decoders
00091     VLC coef_vlc[2];
00092     uint16_t *run_table[2];
00093     uint16_t *level_table[2];
00094     uint16_t *int_table[2];
00095     const CoefVLCTable *coef_vlcs[2];
00096     /* frame info */
00097     int frame_len;                          
00098     int frame_len_bits;                     
00099     int nb_block_sizes;                     
00100     /* block info */
00101     int reset_block_lengths;
00102     int block_len_bits;                     
00103     int next_block_len_bits;                
00104     int prev_block_len_bits;                
00105     int block_len;                          
00106     int block_num;                          
00107     int block_pos;                          
00108     uint8_t ms_stereo;                      
00109     uint8_t channel_coded[MAX_CHANNELS];    
00110     int exponents_bsize[MAX_CHANNELS];      
00111     DECLARE_ALIGNED_16(float, exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]);
00112     float max_exponent[MAX_CHANNELS];
00113     int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
00114     DECLARE_ALIGNED_16(float, coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]);
00115     DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
00116     MDCTContext mdct_ctx[BLOCK_NB_SIZES];
00117     float *windows[BLOCK_NB_SIZES];
00118     /* output buffer for one frame and the last for IMDCT windowing */
00119     DECLARE_ALIGNED_16(float, frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]);
00120     /* last frame info */
00121     uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
00122     int last_bitoffset;
00123     int last_superframe_len;
00124     float noise_table[NOISE_TAB_SIZE];
00125     int noise_index;
00126     float noise_mult; /* XXX: suppress that and integrate it in the noise array */
00127     /* lsp_to_curve tables */
00128     float lsp_cos_table[BLOCK_MAX_SIZE];
00129     float lsp_pow_e_table[256];
00130     float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
00131     float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
00132     DSPContext dsp;
00133 
00134 #ifdef TRACE
00135     int frame_count;
00136 #endif
00137 } WMACodecContext;
00138 
00139 extern const uint16_t ff_wma_hgain_huffcodes[37];
00140 extern const uint8_t ff_wma_hgain_huffbits[37];
00141 extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
00142 extern const uint32_t ff_wma_scale_huffcodes[121];
00143 extern const uint8_t ff_wma_scale_huffbits[121];
00144 
00145 int ff_wma_init(AVCodecContext * avctx, int flags2);
00146 int ff_wma_total_gain_to_bits(int total_gain);
00147 int ff_wma_end(AVCodecContext *avctx);
00148 
00149 #endif /* AVCODEC_WMA_H */

Generated on Tue Nov 4 2014 12:59:23 for ffmpeg by  doxygen 1.7.1