Revision a45fbda9 libavcodec/mdct.c

View differences:

libavcodec/mdct.c
30 30
 * MDCT/IMDCT transforms.
31 31
 */
32 32

  
33
// Generate a Kaiser-Bessel Derived Window.
34
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
35
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
36
{
37
   int i, j;
38
   double sum = 0.0, bessel, tmp;
39
   double local_window[FF_KBD_WINDOW_MAX];
40
   double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
41

  
42
   assert(n <= FF_KBD_WINDOW_MAX);
43

  
44
   for (i = 0; i < n; i++) {
45
       tmp = i * (n - i) * alpha2;
46
       bessel = 1.0;
47
       for (j = BESSEL_I0_ITER; j > 0; j--)
48
           bessel = bessel * tmp / (j * j) + 1;
49
       sum += bessel;
50
       local_window[i] = sum;
51
   }
52

  
53
   sum++;
54
   for (i = 0; i < n; i++)
55
       window[i] = sqrt(local_window[i] / sum);
56
}
57

  
58 33
#include "mdct_tablegen.h"
59 34

  
60 35
/**

Also available in: Unified diff