diff mdct.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 c8c591fe26f8
children a35b838ab955
line wrap: on
line diff
--- a/mdct.c	Fri Jan 11 21:34:05 2008 +0000
+++ b/mdct.c	Sat Jan 12 11:11:19 2008 +0000
@@ -25,6 +25,28 @@
  * MDCT/IMDCT transforms.
  */
 
+// Generate a Kaiser-Bessel Derived Window.
+void ff_kbd_window_init(float *window)
+{
+   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);
+
+   for (i = 0; i < 256; i++) {
+       tmp = i * (256 - i) * alpha2;
+       bessel = 1.0;
+       for (j = 100; j > 0; j--) /* default to 100 iterations */
+           bessel = bessel * tmp / (j * j) + 1;
+       sum += bessel;
+       local_window[i] = sum;
+   }
+
+   sum++;
+   for (i = 0; i < 256; i++)
+       window[i] = sqrt(local_window[i] / sum);
+}
+
 /**
  * init MDCT or IMDCT computation.
  */