comparison nellymoserdec.c @ 6613:54f88d1cee72 libavcodec

Move scale_bias to a more sane place. I am starting to wonder how this trash got into svn ...
author michael
date Wed, 16 Apr 2008 15:28:11 +0000
parents 80cadb0595fb
children d525255f5688
comparison
equal deleted inserted replaced
6612:80cadb0595fb 6613:54f88d1cee72
94 DECLARE_ALIGNED_16(float,float_buf[NELLY_SAMPLES]); 94 DECLARE_ALIGNED_16(float,float_buf[NELLY_SAMPLES]);
95 float state[128]; 95 float state[128];
96 AVRandomState random_state; 96 AVRandomState random_state;
97 GetBitContext gb; 97 GetBitContext gb;
98 int add_bias; 98 int add_bias;
99 int scale_bias; 99 float scale_bias;
100 DSPContext dsp; 100 DSPContext dsp;
101 MDCTContext imdct_ctx; 101 MDCTContext imdct_ctx;
102 DECLARE_ALIGNED_16(float,imdct_tmp[NELLY_BUF_LEN]); 102 DECLARE_ALIGNED_16(float,imdct_tmp[NELLY_BUF_LEN]);
103 DECLARE_ALIGNED_16(float,imdct_out[NELLY_BUF_LEN * 2]); 103 DECLARE_ALIGNED_16(float,imdct_out[NELLY_BUF_LEN * 2]);
104 } NellyMoserDecodeContext; 104 } NellyMoserDecodeContext;
118 118
119 bot = 0; 119 bot = 0;
120 top = NELLY_BUF_LEN-1; 120 top = NELLY_BUF_LEN-1;
121 121
122 while (bot < NELLY_BUF_LEN) { 122 while (bot < NELLY_BUF_LEN) {
123 audio[bot] = ( a_in[bot]*sine_window[bot]+state[bot]*sine_window[top])/s->scale_bias + s->add_bias; 123 audio[bot] = a_in[bot]*sine_window[bot]+state[bot]*sine_window[top] + s->add_bias;
124 124
125 bot++; 125 bot++;
126 top--; 126 top--;
127 } 127 }
128 memcpy(state, a_in + NELLY_BUF_LEN, sizeof(float)*NELLY_BUF_LEN); 128 memcpy(state, a_in + NELLY_BUF_LEN, sizeof(float)*NELLY_BUF_LEN);
277 pptr = pows; 277 pptr = pows;
278 val = nelly_init_table[get_bits(&s->gb, 6)]; 278 val = nelly_init_table[get_bits(&s->gb, 6)];
279 for (i=0 ; i<NELLY_BANDS ; i++) { 279 for (i=0 ; i<NELLY_BANDS ; i++) {
280 if (i > 0) 280 if (i > 0)
281 val += nelly_delta_table[get_bits(&s->gb, 5)]; 281 val += nelly_delta_table[get_bits(&s->gb, 5)];
282 pval = pow(2, val/2048); 282 pval = pow(2, val/2048) * s->scale_bias;
283 for (j = 0; j < nelly_band_sizes_table[i]; j++) { 283 for (j = 0; j < nelly_band_sizes_table[i]; j++) {
284 *bptr++ = val; 284 *bptr++ = val;
285 *pptr++ = pval; 285 *pptr++ = pval;
286 } 286 }
287 287
326 326
327 dsputil_init(&s->dsp, avctx); 327 dsputil_init(&s->dsp, avctx);
328 328
329 if(s->dsp.float_to_int16 == ff_float_to_int16_c) { 329 if(s->dsp.float_to_int16 == ff_float_to_int16_c) {
330 s->add_bias = 385; 330 s->add_bias = 385;
331 s->scale_bias = 8*32768; 331 s->scale_bias = 1.0/(8*32768);
332 } else { 332 } else {
333 s->add_bias = 0; 333 s->add_bias = 0;
334 s->scale_bias = 1*8; 334 s->scale_bias = 1.0/(1*8);
335 } 335 }
336 336
337 /* Generate overlap window */ 337 /* Generate overlap window */
338 if (!sine_window[0]) 338 if (!sine_window[0])
339 for (i=0 ; i<128; i++) { 339 for (i=0 ; i<128; i++) {