Mercurial > libavcodec.hg
diff 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 |
line wrap: on
line diff
--- a/mdct.c Sun Jan 13 08:33:00 2008 +0000 +++ b/mdct.c Sun Jan 13 11:02:08 2008 +0000 @@ -26,24 +26,25 @@ */ // Generate a Kaiser-Bessel Derived Window. -void ff_kbd_window_init(float *window) +#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation +void ff_kbd_window_init(float *window, float alpha, int n) { int i, j; double sum = 0.0, bessel, tmp; - double local_window[256]; - double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0); + double local_window[n]; + double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); - for (i = 0; i < 256; i++) { - tmp = i * (256 - i) * alpha2; + for (i = 0; i < n; i++) { + tmp = i * (n - i) * alpha2; bessel = 1.0; - for (j = 100; j > 0; j--) /* default to 100 iterations */ + for (j = BESSEL_I0_ITER; j > 0; j--) bessel = bessel * tmp / (j * j) + 1; sum += bessel; local_window[i] = sum; } sum++; - for (i = 0; i < 256; i++) + for (i = 0; i < n; i++) window[i] = sqrt(local_window[i] / sum); }