Mercurial > libavcodec.hg
annotate wma.h @ 11913:80916e795581 libavcodec
Bump micro version, add changelog entry for DTS-ES extension decoding support
author | mstorsjo |
---|---|
date | Tue, 22 Jun 2010 09:22:21 +0000 |
parents | 4b3da727d832 |
children |
rev | line source |
---|---|
4490 | 1 /* |
2 * WMA compatible codec | |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
7760
diff
changeset
|
3 * Copyright (c) 2002-2007 The FFmpeg Project |
4490 | 4 * |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
7760 | 22 #ifndef AVCODEC_WMA_H |
23 #define AVCODEC_WMA_H | |
4490 | 24 |
9428 | 25 #include "get_bits.h" |
9411
4cb7c65fc775
Split bitstream.h, put the bitstream writer stuff in the new file
stefano
parents:
8629
diff
changeset
|
26 #include "put_bits.h" |
4490 | 27 #include "dsputil.h" |
11370 | 28 #include "fft.h" |
4490 | 29 |
30 /* size of blocks */ | |
31 #define BLOCK_MIN_BITS 7 | |
32 #define BLOCK_MAX_BITS 11 | |
33 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS) | |
34 | |
35 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) | |
36 | |
37 /* XXX: find exact max size */ | |
38 #define HIGH_BAND_MAX_SIZE 16 | |
39 | |
40 #define NB_LSP_COEFS 10 | |
41 | |
42 /* XXX: is it a suitable value ? */ | |
43 #define MAX_CODED_SUPERFRAME_SIZE 16384 | |
44 | |
45 #define MAX_CHANNELS 2 | |
46 | |
47 #define NOISE_TAB_SIZE 8192 | |
48 | |
49 #define LSP_POW_BITS 7 | |
50 | |
51 //FIXME should be in wmadec | |
52 #define VLCBITS 9 | |
53 #define VLCMAX ((22+VLCBITS-1)/VLCBITS) | |
54 | |
9868 | 55 typedef float WMACoef; ///< type for decoded coefficients, int16_t would be enough for wma 1/2 |
56 | |
4490 | 57 typedef struct CoefVLCTable { |
4497 | 58 int n; ///< total number of codes |
4490 | 59 int max_level; |
4497 | 60 const uint32_t *huffcodes; ///< VLC bit values |
61 const uint8_t *huffbits; ///< VLC bit size | |
62 const uint16_t *levels; ///< table to build run/level tables | |
4490 | 63 } CoefVLCTable; |
64 | |
4601 | 65 typedef struct WMACodecContext { |
4600 | 66 AVCodecContext* avctx; |
4490 | 67 GetBitContext gb; |
68 PutBitContext pb; | |
69 int sample_rate; | |
70 int nb_channels; | |
71 int bit_rate; | |
4497 | 72 int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) |
4490 | 73 int block_align; |
74 int use_bit_reservoir; | |
75 int use_variable_block_len; | |
4497 | 76 int use_exp_vlc; ///< exponent coding: 0 = lsp, 1 = vlc + delta |
77 int use_noise_coding; ///< true if perceptual noise is added | |
4490 | 78 int byte_offset_bits; |
79 VLC exp_vlc; | |
80 int exponent_sizes[BLOCK_NB_SIZES]; | |
81 uint16_t exponent_bands[BLOCK_NB_SIZES][25]; | |
4497 | 82 int high_band_start[BLOCK_NB_SIZES]; ///< index of first coef in high band |
83 int coefs_start; ///< first coded coef | |
84 int coefs_end[BLOCK_NB_SIZES]; ///< max number of coded coefficients | |
4490 | 85 int exponent_high_sizes[BLOCK_NB_SIZES]; |
86 int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]; | |
87 VLC hgain_vlc; | |
88 | |
89 /* coded values in high bands */ | |
90 int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; | |
91 int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; | |
92 | |
93 /* there are two possible tables for spectral coefficients */ | |
94 //FIXME the following 3 tables should be shared between decoders | |
95 VLC coef_vlc[2]; | |
96 uint16_t *run_table[2]; | |
10314
ab687351bfef
WMA: store level_table as floats, use type punning for sign flip in decode
mru
parents:
10199
diff
changeset
|
97 float *level_table[2]; |
4490 | 98 uint16_t *int_table[2]; |
5258 | 99 const CoefVLCTable *coef_vlcs[2]; |
4490 | 100 /* frame info */ |
4497 | 101 int frame_len; ///< frame length in samples |
102 int frame_len_bits; ///< frame_len = 1 << frame_len_bits | |
103 int nb_block_sizes; ///< number of block sizes | |
4490 | 104 /* block info */ |
105 int reset_block_lengths; | |
4497 | 106 int block_len_bits; ///< log2 of current block length |
107 int next_block_len_bits; ///< log2 of next block length | |
108 int prev_block_len_bits; ///< log2 of prev block length | |
109 int block_len; ///< block length in samples | |
110 int block_num; ///< block number in current frame | |
111 int block_pos; ///< current position in frame | |
112 uint8_t ms_stereo; ///< true if mid/side stereo mode | |
113 uint8_t channel_coded[MAX_CHANNELS]; ///< true if channel is coded | |
4785
4ae9ab738aec
WMA decoder improvement, output closer to the dmo binary.
banan
parents:
4737
diff
changeset
|
114 int exponents_bsize[MAX_CHANNELS]; ///< log2 ratio frame/exp. length |
11369 | 115 DECLARE_ALIGNED(16, float, exponents)[MAX_CHANNELS][BLOCK_MAX_SIZE]; |
4490 | 116 float max_exponent[MAX_CHANNELS]; |
9868 | 117 WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]; |
11369 | 118 DECLARE_ALIGNED(16, float, coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE]; |
119 DECLARE_ALIGNED(16, FFTSample, output)[BLOCK_MAX_SIZE * 2]; | |
10199 | 120 FFTContext mdct_ctx[BLOCK_NB_SIZES]; |
4490 | 121 float *windows[BLOCK_NB_SIZES]; |
122 /* output buffer for one frame and the last for IMDCT windowing */ | |
11369 | 123 DECLARE_ALIGNED(16, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; |
4490 | 124 /* last frame info */ |
125 uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */ | |
126 int last_bitoffset; | |
127 int last_superframe_len; | |
128 float noise_table[NOISE_TAB_SIZE]; | |
129 int noise_index; | |
130 float noise_mult; /* XXX: suppress that and integrate it in the noise array */ | |
131 /* lsp_to_curve tables */ | |
132 float lsp_cos_table[BLOCK_MAX_SIZE]; | |
133 float lsp_pow_e_table[256]; | |
134 float lsp_pow_m_table1[(1 << LSP_POW_BITS)]; | |
135 float lsp_pow_m_table2[(1 << LSP_POW_BITS)]; | |
136 DSPContext dsp; | |
137 | |
138 #ifdef TRACE | |
139 int frame_count; | |
140 #endif | |
4601 | 141 } WMACodecContext; |
4490 | 142 |
10966
c29ee479e359
Export wma_critical_freqs as ff_wma_critical_freqs
daniel
parents:
10961
diff
changeset
|
143 extern const uint16_t ff_wma_critical_freqs[25]; |
4490 | 144 extern const uint16_t ff_wma_hgain_huffcodes[37]; |
145 extern const uint8_t ff_wma_hgain_huffbits[37]; | |
146 extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]; | |
11215
964d01b50f17
remove a Huffman table from WMA which also exists in AAC
stefang
parents:
10966
diff
changeset
|
147 extern const uint32_t ff_aac_scalefactor_code[121]; |
964d01b50f17
remove a Huffman table from WMA which also exists in AAC
stefang
parents:
10966
diff
changeset
|
148 extern const uint8_t ff_aac_scalefactor_bits[121]; |
4490 | 149 |
9841
39bb2646fe00
Move frame len bits calculation to ff_wma_get_frame_len_bits
faust3
parents:
9428
diff
changeset
|
150 int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, |
39bb2646fe00
Move frame len bits calculation to ff_wma_get_frame_len_bits
faust3
parents:
9428
diff
changeset
|
151 unsigned int decode_flags); |
4490 | 152 int ff_wma_init(AVCodecContext * avctx, int flags2); |
153 int ff_wma_total_gain_to_bits(int total_gain); | |
154 int ff_wma_end(AVCodecContext *avctx); | |
9869
1f6b569bf958
Add support for escape coded wmapro run level coefficients
faust3
parents:
9868
diff
changeset
|
155 unsigned int ff_wma_get_large_val(GetBitContext* gb); |
9844
eb5916527064
Move run level decode functionality to ff_wma_run_level_decode
faust3
parents:
9841
diff
changeset
|
156 int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, |
eb5916527064
Move run level decode functionality to ff_wma_run_level_decode
faust3
parents:
9841
diff
changeset
|
157 VLC *vlc, |
10314
ab687351bfef
WMA: store level_table as floats, use type punning for sign flip in decode
mru
parents:
10199
diff
changeset
|
158 const float *level_table, const uint16_t *run_table, |
9868 | 159 int version, WMACoef *ptr, int offset, |
9844
eb5916527064
Move run level decode functionality to ff_wma_run_level_decode
faust3
parents:
9841
diff
changeset
|
160 int num_coefs, int block_len, int frame_len_bits, |
eb5916527064
Move run level decode functionality to ff_wma_run_level_decode
faust3
parents:
9841
diff
changeset
|
161 int coef_nb_bits); |
4490 | 162 |
7760 | 163 #endif /* AVCODEC_WMA_H */ |