comparison nellymoserdec.c @ 6605:075d1d2b49a2 libavcodec

simplify transform
author michael
date Wed, 16 Apr 2008 13:28:13 +0000
parents 48759bfbd073
children 3c4822805c62
comparison
equal deleted inserted replaced
6604:e226f34ca284 6605:075d1d2b49a2
109 if (shift > 0) 109 if (shift > 0)
110 return i << shift; 110 return i << shift;
111 return i >> -shift; 111 return i >> -shift;
112 } 112 }
113 113
114 static void overlap_and_window(NellyMoserDecodeContext *s, float *state, float *audio) 114
115 static void overlap_and_window(NellyMoserDecodeContext *s, float *state, float *audio, float *a_in)
115 { 116 {
116 int bot, mid_up, mid_down, top; 117 int bot, top, top2;
117 float s_bot, s_top;
118 118
119 bot = 0; 119 bot = 0;
120 top = NELLY_BUF_LEN-1; 120 top = NELLY_BUF_LEN-1;
121 mid_up = NELLY_BUF_LEN/2; 121 top2 = 2*NELLY_BUF_LEN-1;
122 mid_down = (NELLY_BUF_LEN/2)-1; 122
123 123 while (bot < NELLY_BUF_LEN/2) {
124 while (bot < NELLY_BUF_LEN/4) { 124 audio[bot] = (- a_in[bot]*sine_window[bot]-state[bot]*sine_window[top])/s->scale_bias;
125 s_bot = audio[bot]; 125 audio[top] = (-state[bot]*sine_window[bot]+ a_in[bot]*sine_window[top])/s->scale_bias;
126 s_top = -audio[top]; 126 state[bot] = a_in[top2];
127 audio[bot] = (-audio[mid_up]*sine_window[bot]-state[bot ]*sine_window[top])/s->scale_bias + s->add_bias;
128 audio[top] = (-state[bot ]*sine_window[bot]+audio[mid_up]*sine_window[top])/s->scale_bias + s->add_bias;
129 state[bot] = audio[mid_down];
130
131 audio[mid_down] = (s_top *sine_window[mid_down]-state[mid_down]*sine_window[mid_up])/s->scale_bias + s->add_bias;
132 audio[mid_up ] = (-state[mid_down]*sine_window[mid_down]-s_top *sine_window[mid_up])/s->scale_bias + s->add_bias;
133 state[mid_down] = s_bot;
134 127
135 bot++; 128 bot++;
136 mid_up++; 129 top2--;
137 mid_down--;
138 top--; 130 top--;
139 } 131 }
140 } 132 }
141 133
142 static int sum_bits(short *buf, short shift, short off) 134 static int sum_bits(short *buf, short shift, short off)
321 313
322 s->imdct_ctx.fft.imdct_calc(&s->imdct_ctx, s->imdct_out, 314 s->imdct_ctx.fft.imdct_calc(&s->imdct_ctx, s->imdct_out,
323 aptr, s->imdct_tmp); 315 aptr, s->imdct_tmp);
324 /* XXX: overlapping and windowing should be part of a more 316 /* XXX: overlapping and windowing should be part of a more
325 generic imdct function */ 317 generic imdct function */
326 memcpy(&aptr[0],&s->imdct_out[NELLY_BUF_LEN+NELLY_BUF_LEN/2], (NELLY_BUF_LEN/2)*sizeof(float)); 318 overlap_and_window(s, s->state, aptr, s->imdct_out);
327 memcpy(&aptr[NELLY_BUF_LEN / 2],&s->imdct_out[0],(NELLY_BUF_LEN/2)*sizeof(float));
328 overlap_and_window(s, s->state, aptr);
329 } 319 }
330 } 320 }
331 321
332 static av_cold int decode_init(AVCodecContext * avctx) { 322 static av_cold int decode_init(AVCodecContext * avctx) {
333 NellyMoserDecodeContext *s = avctx->priv_data; 323 NellyMoserDecodeContext *s = avctx->priv_data;