comparison wmaenc.c @ 4601:7b9ce6f729ae libavcodec

Rename WMADecodeContext to WMACodecContext
author mbardiaux
date Tue, 27 Feb 2007 09:54:48 +0000
parents 6ac364a4ce2b
children 2ba8d13a66bc
comparison
equal deleted inserted replaced
4600:6ac364a4ce2b 4601:7b9ce6f729ae
25 #undef NDEBUG 25 #undef NDEBUG
26 #include <assert.h> 26 #include <assert.h>
27 27
28 28
29 static int encode_init(AVCodecContext * avctx){ 29 static int encode_init(AVCodecContext * avctx){
30 WMADecodeContext *s = avctx->priv_data; 30 WMACodecContext *s = avctx->priv_data;
31 int i, flags1, flags2; 31 int i, flags1, flags2;
32 uint8_t *extradata; 32 uint8_t *extradata;
33 33
34 s->avctx = avctx; 34 s->avctx = avctx;
35 35
76 return 0; 76 return 0;
77 } 77 }
78 78
79 79
80 static void apply_window_and_mdct(AVCodecContext * avctx, signed short * audio, int len) { 80 static void apply_window_and_mdct(AVCodecContext * avctx, signed short * audio, int len) {
81 WMADecodeContext *s = avctx->priv_data; 81 WMACodecContext *s = avctx->priv_data;
82 int window_index= s->frame_len_bits - s->block_len_bits; 82 int window_index= s->frame_len_bits - s->block_len_bits;
83 int i, j, channel; 83 int i, j, channel;
84 const float * win = s->windows[window_index]; 84 const float * win = s->windows[window_index];
85 int window_len = 1 << s->block_len_bits; 85 int window_len = 1 << s->block_len_bits;
86 float n = window_len/2; 86 float n = window_len/2;
95 ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output, s->mdct_tmp); 95 ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output, s->mdct_tmp);
96 } 96 }
97 } 97 }
98 98
99 //FIXME use for decoding too 99 //FIXME use for decoding too
100 static void init_exp(WMADecodeContext *s, int ch, int *exp_param){ 100 static void init_exp(WMACodecContext *s, int ch, int *exp_param){
101 int n; 101 int n;
102 const uint16_t *ptr; 102 const uint16_t *ptr;
103 float v, *q, max_scale, *q_end; 103 float v, *q, max_scale, *q_end;
104 104
105 ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; 105 ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
116 } while (--n); 116 } while (--n);
117 } 117 }
118 s->max_exponent[ch] = max_scale; 118 s->max_exponent[ch] = max_scale;
119 } 119 }
120 120
121 static void encode_exp_vlc(WMADecodeContext *s, int ch, const int *exp_param){ 121 static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param){
122 int last_exp; 122 int last_exp;
123 const uint16_t *ptr; 123 const uint16_t *ptr;
124 float *q, *q_end; 124 float *q, *q_end;
125 125
126 ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; 126 ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
142 q+= *ptr++; 142 q+= *ptr++;
143 last_exp= exp; 143 last_exp= exp;
144 } 144 }
145 } 145 }
146 146
147 static int encode_block(WMADecodeContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){ 147 static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){
148 int v, bsize, ch, coef_nb_bits, parse_exponents; 148 int v, bsize, ch, coef_nb_bits, parse_exponents;
149 float mdct_norm; 149 float mdct_norm;
150 int nb_coefs[MAX_CHANNELS]; 150 int nb_coefs[MAX_CHANNELS];
151 static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20}; 151 static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
152 152
306 } 306 }
307 } 307 }
308 return 0; 308 return 0;
309 } 309 }
310 310
311 static int encode_frame(WMADecodeContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], uint8_t *buf, int buf_size, int total_gain){ 311 static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], uint8_t *buf, int buf_size, int total_gain){
312 init_put_bits(&s->pb, buf, buf_size); 312 init_put_bits(&s->pb, buf, buf_size);
313 313
314 if (s->use_bit_reservoir) { 314 if (s->use_bit_reservoir) {
315 assert(0);//FIXME not implemented 315 assert(0);//FIXME not implemented
316 }else{ 316 }else{
323 return put_bits_count(&s->pb)/8 - s->block_align; 323 return put_bits_count(&s->pb)/8 - s->block_align;
324 } 324 }
325 325
326 static int encode_superframe(AVCodecContext *avctx, 326 static int encode_superframe(AVCodecContext *avctx,
327 unsigned char *buf, int buf_size, void *data){ 327 unsigned char *buf, int buf_size, void *data){
328 WMADecodeContext *s = avctx->priv_data; 328 WMACodecContext *s = avctx->priv_data;
329 short *samples = data; 329 short *samples = data;
330 int i, total_gain, best; 330 int i, total_gain, best;
331 331
332 s->block_len_bits= s->frame_len_bits; //required by non variable block len 332 s->block_len_bits= s->frame_len_bits; //required by non variable block len
333 s->block_len = 1 << s->block_len_bits; 333 s->block_len = 1 << s->block_len_bits;
384 AVCodec wmav1_encoder = 384 AVCodec wmav1_encoder =
385 { 385 {
386 "wmav1", 386 "wmav1",
387 CODEC_TYPE_AUDIO, 387 CODEC_TYPE_AUDIO,
388 CODEC_ID_WMAV1, 388 CODEC_ID_WMAV1,
389 sizeof(WMADecodeContext), 389 sizeof(WMACodecContext),
390 encode_init, 390 encode_init,
391 encode_superframe, 391 encode_superframe,
392 ff_wma_end, 392 ff_wma_end,
393 }; 393 };
394 394
395 AVCodec wmav2_encoder = 395 AVCodec wmav2_encoder =
396 { 396 {
397 "wmav2", 397 "wmav2",
398 CODEC_TYPE_AUDIO, 398 CODEC_TYPE_AUDIO,
399 CODEC_ID_WMAV2, 399 CODEC_ID_WMAV2,
400 sizeof(WMADecodeContext), 400 sizeof(WMACodecContext),
401 encode_init, 401 encode_init,
402 encode_superframe, 402 encode_superframe,
403 ff_wma_end, 403 ff_wma_end,
404 }; 404 };