annotate wma.h @ 11520:a791382fd782 libavcodec

Reindent after r22618.
author vitor
date Sun, 21 Mar 2010 11:36:17 +0000
parents 4b3da727d832
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
1 /*
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
4 *
0efc832d9102 wma encoder
michael
parents:
diff changeset
5 * This file is part of FFmpeg.
0efc832d9102 wma encoder
michael
parents:
diff changeset
6 *
0efc832d9102 wma encoder
michael
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0efc832d9102 wma encoder
michael
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
0efc832d9102 wma encoder
michael
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
0efc832d9102 wma encoder
michael
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0efc832d9102 wma encoder
michael
parents:
diff changeset
11 *
0efc832d9102 wma encoder
michael
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0efc832d9102 wma encoder
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0efc832d9102 wma encoder
michael
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0efc832d9102 wma encoder
michael
parents:
diff changeset
15 * Lesser General Public License for more details.
0efc832d9102 wma encoder
michael
parents:
diff changeset
16 *
0efc832d9102 wma encoder
michael
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
0efc832d9102 wma encoder
michael
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
0efc832d9102 wma encoder
michael
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0efc832d9102 wma encoder
michael
parents:
diff changeset
20 */
0efc832d9102 wma encoder
michael
parents:
diff changeset
21
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7546
diff changeset
22 #ifndef AVCODEC_WMA_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7546
diff changeset
23 #define AVCODEC_WMA_H
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
24
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents: 9411
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
27 #include "dsputil.h"
11370
4b3da727d832 Move FFT parts from dsputil.h to fft.h
mru
parents: 11369
diff changeset
28 #include "fft.h"
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
29
0efc832d9102 wma encoder
michael
parents:
diff changeset
30 /* size of blocks */
0efc832d9102 wma encoder
michael
parents:
diff changeset
31 #define BLOCK_MIN_BITS 7
0efc832d9102 wma encoder
michael
parents:
diff changeset
32 #define BLOCK_MAX_BITS 11
0efc832d9102 wma encoder
michael
parents:
diff changeset
33 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
0efc832d9102 wma encoder
michael
parents:
diff changeset
34
0efc832d9102 wma encoder
michael
parents:
diff changeset
35 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
0efc832d9102 wma encoder
michael
parents:
diff changeset
36
0efc832d9102 wma encoder
michael
parents:
diff changeset
37 /* XXX: find exact max size */
0efc832d9102 wma encoder
michael
parents:
diff changeset
38 #define HIGH_BAND_MAX_SIZE 16
0efc832d9102 wma encoder
michael
parents:
diff changeset
39
0efc832d9102 wma encoder
michael
parents:
diff changeset
40 #define NB_LSP_COEFS 10
0efc832d9102 wma encoder
michael
parents:
diff changeset
41
0efc832d9102 wma encoder
michael
parents:
diff changeset
42 /* XXX: is it a suitable value ? */
0efc832d9102 wma encoder
michael
parents:
diff changeset
43 #define MAX_CODED_SUPERFRAME_SIZE 16384
0efc832d9102 wma encoder
michael
parents:
diff changeset
44
0efc832d9102 wma encoder
michael
parents:
diff changeset
45 #define MAX_CHANNELS 2
0efc832d9102 wma encoder
michael
parents:
diff changeset
46
0efc832d9102 wma encoder
michael
parents:
diff changeset
47 #define NOISE_TAB_SIZE 8192
0efc832d9102 wma encoder
michael
parents:
diff changeset
48
0efc832d9102 wma encoder
michael
parents:
diff changeset
49 #define LSP_POW_BITS 7
0efc832d9102 wma encoder
michael
parents:
diff changeset
50
0efc832d9102 wma encoder
michael
parents:
diff changeset
51 //FIXME should be in wmadec
0efc832d9102 wma encoder
michael
parents:
diff changeset
52 #define VLCBITS 9
0efc832d9102 wma encoder
michael
parents:
diff changeset
53 #define VLCMAX ((22+VLCBITS-1)/VLCBITS)
0efc832d9102 wma encoder
michael
parents:
diff changeset
54
9868
5cc32c474caf Introduce WMACoef typedef for decoded coefficients
faust3
parents: 9844
diff changeset
55 typedef float WMACoef; ///< type for decoded coefficients, int16_t would be enough for wma 1/2
5cc32c474caf Introduce WMACoef typedef for decoded coefficients
faust3
parents: 9844
diff changeset
56
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
57 typedef struct CoefVLCTable {
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
58 int n; ///< total number of codes
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
59 int max_level;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
60 const uint32_t *huffcodes; ///< VLC bit values
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
61 const uint8_t *huffbits; ///< VLC bit size
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
62 const uint16_t *levels; ///< table to build run/level tables
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
63 } CoefVLCTable;
0efc832d9102 wma encoder
michael
parents:
diff changeset
64
4601
7b9ce6f729ae Rename WMADecodeContext to WMACodecContext
mbardiaux
parents: 4600
diff changeset
65 typedef struct WMACodecContext {
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4497
diff changeset
66 AVCodecContext* avctx;
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
67 GetBitContext gb;
0efc832d9102 wma encoder
michael
parents:
diff changeset
68 PutBitContext pb;
0efc832d9102 wma encoder
michael
parents:
diff changeset
69 int sample_rate;
0efc832d9102 wma encoder
michael
parents:
diff changeset
70 int nb_channels;
0efc832d9102 wma encoder
michael
parents:
diff changeset
71 int bit_rate;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
72 int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
73 int block_align;
0efc832d9102 wma encoder
michael
parents:
diff changeset
74 int use_bit_reservoir;
0efc832d9102 wma encoder
michael
parents:
diff changeset
75 int use_variable_block_len;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
76 int use_exp_vlc; ///< exponent coding: 0 = lsp, 1 = vlc + delta
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
77 int use_noise_coding; ///< true if perceptual noise is added
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
78 int byte_offset_bits;
0efc832d9102 wma encoder
michael
parents:
diff changeset
79 VLC exp_vlc;
0efc832d9102 wma encoder
michael
parents:
diff changeset
80 int exponent_sizes[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
81 uint16_t exponent_bands[BLOCK_NB_SIZES][25];
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
82 int high_band_start[BLOCK_NB_SIZES]; ///< index of first coef in high band
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
83 int coefs_start; ///< first coded coef
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
84 int coefs_end[BLOCK_NB_SIZES]; ///< max number of coded coefficients
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
85 int exponent_high_sizes[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
86 int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
87 VLC hgain_vlc;
0efc832d9102 wma encoder
michael
parents:
diff changeset
88
0efc832d9102 wma encoder
michael
parents:
diff changeset
89 /* coded values in high bands */
0efc832d9102 wma encoder
michael
parents:
diff changeset
90 int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
91 int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
92
0efc832d9102 wma encoder
michael
parents:
diff changeset
93 /* there are two possible tables for spectral coefficients */
0efc832d9102 wma encoder
michael
parents:
diff changeset
94 //FIXME the following 3 tables should be shared between decoders
0efc832d9102 wma encoder
michael
parents:
diff changeset
95 VLC coef_vlc[2];
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
98 uint16_t *int_table[2];
5258
4372aeade5dc trivial warning fixes
mru
parents: 4785
diff changeset
99 const CoefVLCTable *coef_vlcs[2];
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
100 /* frame info */
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
101 int frame_len; ///< frame length in samples
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
102 int frame_len_bits; ///< frame_len = 1 << frame_len_bits
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
103 int nb_block_sizes; ///< number of block sizes
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
104 /* block info */
0efc832d9102 wma encoder
michael
parents:
diff changeset
105 int reset_block_lengths;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
106 int block_len_bits; ///< log2 of current block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
107 int next_block_len_bits; ///< log2 of next block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
108 int prev_block_len_bits; ///< log2 of prev block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
109 int block_len; ///< block length in samples
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
110 int block_num; ///< block number in current frame
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
111 int block_pos; ///< current position in frame
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
112 uint8_t ms_stereo; ///< true if mid/side stereo mode
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
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
98970e51365a Remove DECLARE_ALIGNED_{8,16} macros
mru
parents: 11215
diff changeset
115 DECLARE_ALIGNED(16, float, exponents)[MAX_CHANNELS][BLOCK_MAX_SIZE];
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
116 float max_exponent[MAX_CHANNELS];
9868
5cc32c474caf Introduce WMACoef typedef for decoded coefficients
faust3
parents: 9844
diff changeset
117 WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
11369
98970e51365a Remove DECLARE_ALIGNED_{8,16} macros
mru
parents: 11215
diff changeset
118 DECLARE_ALIGNED(16, float, coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE];
98970e51365a Remove DECLARE_ALIGNED_{8,16} macros
mru
parents: 11215
diff changeset
119 DECLARE_ALIGNED(16, FFTSample, output)[BLOCK_MAX_SIZE * 2];
10199
38ab367d4231 Merge FFTContext and MDCTContext
mru
parents: 9869
diff changeset
120 FFTContext mdct_ctx[BLOCK_NB_SIZES];
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
121 float *windows[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
122 /* output buffer for one frame and the last for IMDCT windowing */
11369
98970e51365a Remove DECLARE_ALIGNED_{8,16} macros
mru
parents: 11215
diff changeset
123 DECLARE_ALIGNED(16, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
124 /* last frame info */
0efc832d9102 wma encoder
michael
parents:
diff changeset
125 uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
0efc832d9102 wma encoder
michael
parents:
diff changeset
126 int last_bitoffset;
0efc832d9102 wma encoder
michael
parents:
diff changeset
127 int last_superframe_len;
0efc832d9102 wma encoder
michael
parents:
diff changeset
128 float noise_table[NOISE_TAB_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
129 int noise_index;
0efc832d9102 wma encoder
michael
parents:
diff changeset
130 float noise_mult; /* XXX: suppress that and integrate it in the noise array */
0efc832d9102 wma encoder
michael
parents:
diff changeset
131 /* lsp_to_curve tables */
0efc832d9102 wma encoder
michael
parents:
diff changeset
132 float lsp_cos_table[BLOCK_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
133 float lsp_pow_e_table[256];
0efc832d9102 wma encoder
michael
parents:
diff changeset
134 float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
0efc832d9102 wma encoder
michael
parents:
diff changeset
135 float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
0efc832d9102 wma encoder
michael
parents:
diff changeset
136 DSPContext dsp;
0efc832d9102 wma encoder
michael
parents:
diff changeset
137
0efc832d9102 wma encoder
michael
parents:
diff changeset
138 #ifdef TRACE
0efc832d9102 wma encoder
michael
parents:
diff changeset
139 int frame_count;
0efc832d9102 wma encoder
michael
parents:
diff changeset
140 #endif
4601
7b9ce6f729ae Rename WMADecodeContext to WMACodecContext
mbardiaux
parents: 4600
diff changeset
141 } WMACodecContext;
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
144 extern const uint16_t ff_wma_hgain_huffcodes[37];
0efc832d9102 wma encoder
michael
parents:
diff changeset
145 extern const uint8_t ff_wma_hgain_huffbits[37];
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
152 int ff_wma_init(AVCodecContext * avctx, int flags2);
0efc832d9102 wma encoder
michael
parents:
diff changeset
153 int ff_wma_total_gain_to_bits(int total_gain);
0efc832d9102 wma encoder
michael
parents:
diff changeset
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
5cc32c474caf Introduce WMACoef typedef for decoded coefficients
faust3
parents: 9844
diff changeset
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
0efc832d9102 wma encoder
michael
parents:
diff changeset
162
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7546
diff changeset
163 #endif /* AVCODEC_WMA_H */