annotate wma.h @ 8739:037e54d6c9c3 libavcodec

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