comparison mdct.c @ 6142:a35b838ab955 libavcodec

Add variable alpha and size of half window for Kaiser-Bessel Derived window generation. Hard code Bessel I0 approximation iterations to 50. See thread for discussion: [FFmpeg-devel] [PATCH] Move Kaiser-Bessel Derived window to mdct.c Started on the 2008/01/10
author superdump
date Sun, 13 Jan 2008 11:02:08 +0000
parents 5077d1562573
children d9c48a85fd23
comparison
equal deleted inserted replaced
6141:932523fb0562 6142:a35b838ab955
24 * @file mdct.c 24 * @file mdct.c
25 * MDCT/IMDCT transforms. 25 * MDCT/IMDCT transforms.
26 */ 26 */
27 27
28 // Generate a Kaiser-Bessel Derived Window. 28 // Generate a Kaiser-Bessel Derived Window.
29 void ff_kbd_window_init(float *window) 29 #define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
30 void ff_kbd_window_init(float *window, float alpha, int n)
30 { 31 {
31 int i, j; 32 int i, j;
32 double sum = 0.0, bessel, tmp; 33 double sum = 0.0, bessel, tmp;
33 double local_window[256]; 34 double local_window[n];
34 double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0); 35 double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
35 36
36 for (i = 0; i < 256; i++) { 37 for (i = 0; i < n; i++) {
37 tmp = i * (256 - i) * alpha2; 38 tmp = i * (n - i) * alpha2;
38 bessel = 1.0; 39 bessel = 1.0;
39 for (j = 100; j > 0; j--) /* default to 100 iterations */ 40 for (j = BESSEL_I0_ITER; j > 0; j--)
40 bessel = bessel * tmp / (j * j) + 1; 41 bessel = bessel * tmp / (j * j) + 1;
41 sum += bessel; 42 sum += bessel;
42 local_window[i] = sum; 43 local_window[i] = sum;
43 } 44 }
44 45
45 sum++; 46 sum++;
46 for (i = 0; i < 256; i++) 47 for (i = 0; i < n; i++)
47 window[i] = sqrt(local_window[i] / sum); 48 window[i] = sqrt(local_window[i] / sum);
48 } 49 }
49 50
50 /** 51 /**
51 * init MDCT or IMDCT computation. 52 * init MDCT or IMDCT computation.