Mercurial > libavcodec.hg
comparison wmadec.c @ 4601:7b9ce6f729ae libavcodec
Rename WMADecodeContext to WMACodecContext
author | mbardiaux |
---|---|
date | Tue, 27 Feb 2007 09:54:48 +0000 |
parents | 6ac364a4ce2b |
children | 99d9dd34903b |
comparison
equal
deleted
inserted
replaced
4600:6ac364a4ce2b | 4601:7b9ce6f729ae |
---|---|
43 #define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) | 43 #define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) |
44 | 44 |
45 #define HGAINVLCBITS 9 | 45 #define HGAINVLCBITS 9 |
46 #define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS) | 46 #define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS) |
47 | 47 |
48 static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len); | 48 static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len); |
49 | 49 |
50 #ifdef TRACE | 50 #ifdef TRACE |
51 static void dump_shorts(WMADecodeContext *s, const char *name, const short *tab, int n) | 51 static void dump_shorts(WMADecodeContext *s, const char *name, const short *tab, int n) |
52 { | 52 { |
53 int i; | 53 int i; |
79 } | 79 } |
80 #endif | 80 #endif |
81 | 81 |
82 static int wma_decode_init(AVCodecContext * avctx) | 82 static int wma_decode_init(AVCodecContext * avctx) |
83 { | 83 { |
84 WMADecodeContext *s = avctx->priv_data; | 84 WMACodecContext *s = avctx->priv_data; |
85 int i, flags1, flags2; | 85 int i, flags1, flags2; |
86 uint8_t *extradata; | 86 uint8_t *extradata; |
87 | 87 |
88 s->avctx = avctx; | 88 s->avctx = avctx; |
89 | 89 |
162 * compute x^-0.25 with an exponent and mantissa table. We use linear | 162 * compute x^-0.25 with an exponent and mantissa table. We use linear |
163 * interpolation to reduce the mantissa table size at a small speed | 163 * interpolation to reduce the mantissa table size at a small speed |
164 * expense (linear interpolation approximately doubles the number of | 164 * expense (linear interpolation approximately doubles the number of |
165 * bits of precision). | 165 * bits of precision). |
166 */ | 166 */ |
167 static inline float pow_m1_4(WMADecodeContext *s, float x) | 167 static inline float pow_m1_4(WMACodecContext *s, float x) |
168 { | 168 { |
169 union { | 169 union { |
170 float f; | 170 float f; |
171 unsigned int v; | 171 unsigned int v; |
172 } u, t; | 172 } u, t; |
181 a = s->lsp_pow_m_table1[m]; | 181 a = s->lsp_pow_m_table1[m]; |
182 b = s->lsp_pow_m_table2[m]; | 182 b = s->lsp_pow_m_table2[m]; |
183 return s->lsp_pow_e_table[e] * (a + b * t.f); | 183 return s->lsp_pow_e_table[e] * (a + b * t.f); |
184 } | 184 } |
185 | 185 |
186 static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len) | 186 static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len) |
187 { | 187 { |
188 float wdel, a, b; | 188 float wdel, a, b; |
189 int i, e, m; | 189 int i, e, m; |
190 | 190 |
191 wdel = M_PI / frame_len; | 191 wdel = M_PI / frame_len; |
222 | 222 |
223 /** | 223 /** |
224 * NOTE: We use the same code as Vorbis here | 224 * NOTE: We use the same code as Vorbis here |
225 * @todo optimize it further with SSE/3Dnow | 225 * @todo optimize it further with SSE/3Dnow |
226 */ | 226 */ |
227 static void wma_lsp_to_curve(WMADecodeContext *s, | 227 static void wma_lsp_to_curve(WMACodecContext *s, |
228 float *out, float *val_max_ptr, | 228 float *out, float *val_max_ptr, |
229 int n, float *lsp) | 229 int n, float *lsp) |
230 { | 230 { |
231 int i, j; | 231 int i, j; |
232 float p, q, w, v, val_max; | 232 float p, q, w, v, val_max; |
252 } | 252 } |
253 | 253 |
254 /** | 254 /** |
255 * decode exponents coded with LSP coefficients (same idea as Vorbis) | 255 * decode exponents coded with LSP coefficients (same idea as Vorbis) |
256 */ | 256 */ |
257 static void decode_exp_lsp(WMADecodeContext *s, int ch) | 257 static void decode_exp_lsp(WMACodecContext *s, int ch) |
258 { | 258 { |
259 float lsp_coefs[NB_LSP_COEFS]; | 259 float lsp_coefs[NB_LSP_COEFS]; |
260 int val, i; | 260 int val, i; |
261 | 261 |
262 for(i = 0; i < NB_LSP_COEFS; i++) { | 262 for(i = 0; i < NB_LSP_COEFS; i++) { |
272 } | 272 } |
273 | 273 |
274 /** | 274 /** |
275 * decode exponents coded with VLC codes | 275 * decode exponents coded with VLC codes |
276 */ | 276 */ |
277 static int decode_exp_vlc(WMADecodeContext *s, int ch) | 277 static int decode_exp_vlc(WMACodecContext *s, int ch) |
278 { | 278 { |
279 int last_exp, n, code; | 279 int last_exp, n, code; |
280 const uint16_t *ptr, *band_ptr; | 280 const uint16_t *ptr, *band_ptr; |
281 float v, *q, max_scale, *q_end; | 281 float v, *q, max_scale, *q_end; |
282 | 282 |
318 | 318 |
319 /** | 319 /** |
320 * @return 0 if OK. 1 if last block of frame. return -1 if | 320 * @return 0 if OK. 1 if last block of frame. return -1 if |
321 * unrecorrable error. | 321 * unrecorrable error. |
322 */ | 322 */ |
323 static int wma_decode_block(WMADecodeContext *s) | 323 static int wma_decode_block(WMACodecContext *s) |
324 { | 324 { |
325 int n, v, a, ch, code, bsize; | 325 int n, v, a, ch, code, bsize; |
326 int coef_nb_bits, total_gain, parse_exponents; | 326 int coef_nb_bits, total_gain, parse_exponents; |
327 int nb_coefs[MAX_CHANNELS]; | 327 int nb_coefs[MAX_CHANNELS]; |
328 float mdct_norm; | 328 float mdct_norm; |
737 else | 737 else |
738 return 0; | 738 return 0; |
739 } | 739 } |
740 | 740 |
741 /* decode a frame of frame_len samples */ | 741 /* decode a frame of frame_len samples */ |
742 static int wma_decode_frame(WMADecodeContext *s, int16_t *samples) | 742 static int wma_decode_frame(WMACodecContext *s, int16_t *samples) |
743 { | 743 { |
744 int ret, i, n, a, ch, incr; | 744 int ret, i, n, a, ch, incr; |
745 int16_t *ptr; | 745 int16_t *ptr; |
746 float *iptr; | 746 float *iptr; |
747 | 747 |
792 | 792 |
793 static int wma_decode_superframe(AVCodecContext *avctx, | 793 static int wma_decode_superframe(AVCodecContext *avctx, |
794 void *data, int *data_size, | 794 void *data, int *data_size, |
795 uint8_t *buf, int buf_size) | 795 uint8_t *buf, int buf_size) |
796 { | 796 { |
797 WMADecodeContext *s = avctx->priv_data; | 797 WMACodecContext *s = avctx->priv_data; |
798 int nb_frames, bit_offset, i, pos, len; | 798 int nb_frames, bit_offset, i, pos, len; |
799 uint8_t *q; | 799 uint8_t *q; |
800 int16_t *samples; | 800 int16_t *samples; |
801 | 801 |
802 tprintf(avctx, "***decode_superframe:\n"); | 802 tprintf(avctx, "***decode_superframe:\n"); |
889 AVCodec wmav1_decoder = | 889 AVCodec wmav1_decoder = |
890 { | 890 { |
891 "wmav1", | 891 "wmav1", |
892 CODEC_TYPE_AUDIO, | 892 CODEC_TYPE_AUDIO, |
893 CODEC_ID_WMAV1, | 893 CODEC_ID_WMAV1, |
894 sizeof(WMADecodeContext), | 894 sizeof(WMACodecContext), |
895 wma_decode_init, | 895 wma_decode_init, |
896 NULL, | 896 NULL, |
897 ff_wma_end, | 897 ff_wma_end, |
898 wma_decode_superframe, | 898 wma_decode_superframe, |
899 }; | 899 }; |
901 AVCodec wmav2_decoder = | 901 AVCodec wmav2_decoder = |
902 { | 902 { |
903 "wmav2", | 903 "wmav2", |
904 CODEC_TYPE_AUDIO, | 904 CODEC_TYPE_AUDIO, |
905 CODEC_ID_WMAV2, | 905 CODEC_ID_WMAV2, |
906 sizeof(WMADecodeContext), | 906 sizeof(WMACodecContext), |
907 wma_decode_init, | 907 wma_decode_init, |
908 NULL, | 908 NULL, |
909 ff_wma_end, | 909 ff_wma_end, |
910 wma_decode_superframe, | 910 wma_decode_superframe, |
911 }; | 911 }; |