annotate wma.h @ 9435:adbd43ffeada libavcodec

fix indentation
author bcoudurier
date Tue, 14 Apr 2009 00:12:54 +0000
parents 0dce4fe6e6f3
children 39bb2646fe00
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"
0efc832d9102 wma encoder
michael
parents:
diff changeset
28
0efc832d9102 wma encoder
michael
parents:
diff changeset
29 /* size of blocks */
0efc832d9102 wma encoder
michael
parents:
diff changeset
30 #define BLOCK_MIN_BITS 7
0efc832d9102 wma encoder
michael
parents:
diff changeset
31 #define BLOCK_MAX_BITS 11
0efc832d9102 wma encoder
michael
parents:
diff changeset
32 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
0efc832d9102 wma encoder
michael
parents:
diff changeset
33
0efc832d9102 wma encoder
michael
parents:
diff changeset
34 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
0efc832d9102 wma encoder
michael
parents:
diff changeset
35
0efc832d9102 wma encoder
michael
parents:
diff changeset
36 /* XXX: find exact max size */
0efc832d9102 wma encoder
michael
parents:
diff changeset
37 #define HIGH_BAND_MAX_SIZE 16
0efc832d9102 wma encoder
michael
parents:
diff changeset
38
0efc832d9102 wma encoder
michael
parents:
diff changeset
39 #define NB_LSP_COEFS 10
0efc832d9102 wma encoder
michael
parents:
diff changeset
40
0efc832d9102 wma encoder
michael
parents:
diff changeset
41 /* XXX: is it a suitable value ? */
0efc832d9102 wma encoder
michael
parents:
diff changeset
42 #define MAX_CODED_SUPERFRAME_SIZE 16384
0efc832d9102 wma encoder
michael
parents:
diff changeset
43
0efc832d9102 wma encoder
michael
parents:
diff changeset
44 #define MAX_CHANNELS 2
0efc832d9102 wma encoder
michael
parents:
diff changeset
45
0efc832d9102 wma encoder
michael
parents:
diff changeset
46 #define NOISE_TAB_SIZE 8192
0efc832d9102 wma encoder
michael
parents:
diff changeset
47
0efc832d9102 wma encoder
michael
parents:
diff changeset
48 #define LSP_POW_BITS 7
0efc832d9102 wma encoder
michael
parents:
diff changeset
49
0efc832d9102 wma encoder
michael
parents:
diff changeset
50 //FIXME should be in wmadec
0efc832d9102 wma encoder
michael
parents:
diff changeset
51 #define VLCBITS 9
0efc832d9102 wma encoder
michael
parents:
diff changeset
52 #define VLCMAX ((22+VLCBITS-1)/VLCBITS)
0efc832d9102 wma encoder
michael
parents:
diff changeset
53
0efc832d9102 wma encoder
michael
parents:
diff changeset
54 typedef struct CoefVLCTable {
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
55 int n; ///< total number of codes
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
56 int max_level;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
57 const uint32_t *huffcodes; ///< VLC bit values
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
58 const uint8_t *huffbits; ///< VLC bit size
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
59 const uint16_t *levels; ///< table to build run/level tables
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
60 } CoefVLCTable;
0efc832d9102 wma encoder
michael
parents:
diff changeset
61
4601
7b9ce6f729ae Rename WMADecodeContext to WMACodecContext
mbardiaux
parents: 4600
diff changeset
62 typedef struct WMACodecContext {
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4497
diff changeset
63 AVCodecContext* avctx;
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
64 GetBitContext gb;
0efc832d9102 wma encoder
michael
parents:
diff changeset
65 PutBitContext pb;
0efc832d9102 wma encoder
michael
parents:
diff changeset
66 int sample_rate;
0efc832d9102 wma encoder
michael
parents:
diff changeset
67 int nb_channels;
0efc832d9102 wma encoder
michael
parents:
diff changeset
68 int bit_rate;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
69 int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
70 int block_align;
0efc832d9102 wma encoder
michael
parents:
diff changeset
71 int use_bit_reservoir;
0efc832d9102 wma encoder
michael
parents:
diff changeset
72 int use_variable_block_len;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
73 int use_exp_vlc; ///< exponent coding: 0 = lsp, 1 = vlc + delta
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
74 int use_noise_coding; ///< true if perceptual noise is added
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
75 int byte_offset_bits;
0efc832d9102 wma encoder
michael
parents:
diff changeset
76 VLC exp_vlc;
0efc832d9102 wma encoder
michael
parents:
diff changeset
77 int exponent_sizes[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
78 uint16_t exponent_bands[BLOCK_NB_SIZES][25];
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
79 int high_band_start[BLOCK_NB_SIZES]; ///< index of first coef in high band
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
80 int coefs_start; ///< first coded coef
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
81 int coefs_end[BLOCK_NB_SIZES]; ///< max number of coded coefficients
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
82 int exponent_high_sizes[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
83 int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
84 VLC hgain_vlc;
0efc832d9102 wma encoder
michael
parents:
diff changeset
85
0efc832d9102 wma encoder
michael
parents:
diff changeset
86 /* coded values in high bands */
0efc832d9102 wma encoder
michael
parents:
diff changeset
87 int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
88 int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
89
0efc832d9102 wma encoder
michael
parents:
diff changeset
90 /* there are two possible tables for spectral coefficients */
0efc832d9102 wma encoder
michael
parents:
diff changeset
91 //FIXME the following 3 tables should be shared between decoders
0efc832d9102 wma encoder
michael
parents:
diff changeset
92 VLC coef_vlc[2];
0efc832d9102 wma encoder
michael
parents:
diff changeset
93 uint16_t *run_table[2];
0efc832d9102 wma encoder
michael
parents:
diff changeset
94 uint16_t *level_table[2];
0efc832d9102 wma encoder
michael
parents:
diff changeset
95 uint16_t *int_table[2];
5258
4372aeade5dc trivial warning fixes
mru
parents: 4785
diff changeset
96 const CoefVLCTable *coef_vlcs[2];
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
97 /* frame info */
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
98 int frame_len; ///< frame length in samples
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
99 int frame_len_bits; ///< frame_len = 1 << frame_len_bits
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
100 int nb_block_sizes; ///< number of block sizes
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
101 /* block info */
0efc832d9102 wma encoder
michael
parents:
diff changeset
102 int reset_block_lengths;
4497
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
103 int block_len_bits; ///< log2 of current block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
104 int next_block_len_bits; ///< log2 of next block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
105 int prev_block_len_bits; ///< log2 of prev block length
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
106 int block_len; ///< block length in samples
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
107 int block_num; ///< block number in current frame
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
108 int block_pos; ///< current position in frame
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
109 uint8_t ms_stereo; ///< true if mid/side stereo mode
3975e734e07e doxygenize
michael
parents: 4490
diff changeset
110 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
111 int exponents_bsize[MAX_CHANNELS]; ///< log2 ratio frame/exp. length
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
112 DECLARE_ALIGNED_16(float, exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]);
0efc832d9102 wma encoder
michael
parents:
diff changeset
113 float max_exponent[MAX_CHANNELS];
0efc832d9102 wma encoder
michael
parents:
diff changeset
114 int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
115 DECLARE_ALIGNED_16(float, coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]);
0efc832d9102 wma encoder
michael
parents:
diff changeset
116 DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
0efc832d9102 wma encoder
michael
parents:
diff changeset
117 MDCTContext mdct_ctx[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
118 float *windows[BLOCK_NB_SIZES];
0efc832d9102 wma encoder
michael
parents:
diff changeset
119 /* output buffer for one frame and the last for IMDCT windowing */
0efc832d9102 wma encoder
michael
parents:
diff changeset
120 DECLARE_ALIGNED_16(float, frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]);
0efc832d9102 wma encoder
michael
parents:
diff changeset
121 /* last frame info */
0efc832d9102 wma encoder
michael
parents:
diff changeset
122 uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
0efc832d9102 wma encoder
michael
parents:
diff changeset
123 int last_bitoffset;
0efc832d9102 wma encoder
michael
parents:
diff changeset
124 int last_superframe_len;
0efc832d9102 wma encoder
michael
parents:
diff changeset
125 float noise_table[NOISE_TAB_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
126 int noise_index;
0efc832d9102 wma encoder
michael
parents:
diff changeset
127 float noise_mult; /* XXX: suppress that and integrate it in the noise array */
0efc832d9102 wma encoder
michael
parents:
diff changeset
128 /* lsp_to_curve tables */
0efc832d9102 wma encoder
michael
parents:
diff changeset
129 float lsp_cos_table[BLOCK_MAX_SIZE];
0efc832d9102 wma encoder
michael
parents:
diff changeset
130 float lsp_pow_e_table[256];
0efc832d9102 wma encoder
michael
parents:
diff changeset
131 float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
0efc832d9102 wma encoder
michael
parents:
diff changeset
132 float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
0efc832d9102 wma encoder
michael
parents:
diff changeset
133 DSPContext dsp;
0efc832d9102 wma encoder
michael
parents:
diff changeset
134
0efc832d9102 wma encoder
michael
parents:
diff changeset
135 #ifdef TRACE
0efc832d9102 wma encoder
michael
parents:
diff changeset
136 int frame_count;
0efc832d9102 wma encoder
michael
parents:
diff changeset
137 #endif
4601
7b9ce6f729ae Rename WMADecodeContext to WMACodecContext
mbardiaux
parents: 4600
diff changeset
138 } WMACodecContext;
4490
0efc832d9102 wma encoder
michael
parents:
diff changeset
139
0efc832d9102 wma encoder
michael
parents:
diff changeset
140 extern const uint16_t ff_wma_hgain_huffcodes[37];
0efc832d9102 wma encoder
michael
parents:
diff changeset
141 extern const uint8_t ff_wma_hgain_huffbits[37];
0efc832d9102 wma encoder
michael
parents:
diff changeset
142 extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
0efc832d9102 wma encoder
michael
parents:
diff changeset
143 extern const uint32_t ff_wma_scale_huffcodes[121];
0efc832d9102 wma encoder
michael
parents:
diff changeset
144 extern const uint8_t ff_wma_scale_huffbits[121];
0efc832d9102 wma encoder
michael
parents:
diff changeset
145
0efc832d9102 wma encoder
michael
parents:
diff changeset
146 int ff_wma_init(AVCodecContext * avctx, int flags2);
0efc832d9102 wma encoder
michael
parents:
diff changeset
147 int ff_wma_total_gain_to_bits(int total_gain);
0efc832d9102 wma encoder
michael
parents:
diff changeset
148 int ff_wma_end(AVCodecContext *avctx);
0efc832d9102 wma encoder
michael
parents:
diff changeset
149
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7546
diff changeset
150 #endif /* AVCODEC_WMA_H */