Mercurial > libavcodec.hg
comparison ac3dec.c @ 6139:5077d1562573 libavcodec
Make the Kaiser-Bessel window generator a common function
Patch by Robert Swain, robert d swain a gmail d com
author | andoma |
---|---|
date | Sat, 12 Jan 2008 11:11:19 +0000 |
parents | 5c485301f6f3 |
children | a35b838ab955 |
comparison
equal
deleted
inserted
replaced
6138:c7a61f83de73 | 6139:5077d1562573 |
---|---|
195 AVRandomState dith_state; ///< for dither generation | 195 AVRandomState dith_state; ///< for dither generation |
196 AVCodecContext *avctx; ///< parent context | 196 AVCodecContext *avctx; ///< parent context |
197 } AC3DecodeContext; | 197 } AC3DecodeContext; |
198 | 198 |
199 /** | 199 /** |
200 * Generate a Kaiser-Bessel Derived Window. | |
201 */ | |
202 static void ac3_window_init(float *window) | |
203 { | |
204 int i, j; | |
205 double sum = 0.0, bessel, tmp; | |
206 double local_window[256]; | |
207 double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0); | |
208 | |
209 for (i = 0; i < 256; i++) { | |
210 tmp = i * (256 - i) * alpha2; | |
211 bessel = 1.0; | |
212 for (j = 100; j > 0; j--) /* default to 100 iterations */ | |
213 bessel = bessel * tmp / (j * j) + 1; | |
214 sum += bessel; | |
215 local_window[i] = sum; | |
216 } | |
217 | |
218 sum++; | |
219 for (i = 0; i < 256; i++) | |
220 window[i] = sqrt(local_window[i] / sum); | |
221 } | |
222 | |
223 /** | |
224 * Symmetrical Dequantization | 200 * Symmetrical Dequantization |
225 * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization | 201 * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization |
226 * Tables 7.19 to 7.23 | 202 * Tables 7.19 to 7.23 |
227 */ | 203 */ |
228 static inline float | 204 static inline float |
299 | 275 |
300 ac3_common_init(); | 276 ac3_common_init(); |
301 ac3_tables_init(); | 277 ac3_tables_init(); |
302 ff_mdct_init(&s->imdct_256, 8, 1); | 278 ff_mdct_init(&s->imdct_256, 8, 1); |
303 ff_mdct_init(&s->imdct_512, 9, 1); | 279 ff_mdct_init(&s->imdct_512, 9, 1); |
304 ac3_window_init(s->window); | 280 ff_kbd_window_init(s->window); |
305 dsputil_init(&s->dsp, avctx); | 281 dsputil_init(&s->dsp, avctx); |
306 av_init_random(0, &s->dith_state); | 282 av_init_random(0, &s->dith_state); |
307 | 283 |
308 /* set bias values for float to int16 conversion */ | 284 /* set bias values for float to int16 conversion */ |
309 if(s->dsp.float_to_int16 == ff_float_to_int16_c) { | 285 if(s->dsp.float_to_int16 == ff_float_to_int16_c) { |