diff options
author | Robert Swain <robert.swain@gmail.com> | 2008-01-12 11:11:19 +0000 |
---|---|---|
committer | Andreas Ă–man <andreas@lonelycoder.com> | 2008-01-12 11:11:19 +0000 |
commit | 4eb7a735cb7218794909e19773415be57ec959e4 (patch) | |
tree | 63a307e8d8395993efab8a29a3678102339dccdc /libavcodec/mdct.c | |
parent | f5b410312fb201e819f158c78d3a8266dd07eae9 (diff) | |
download | ffmpeg-4eb7a735cb7218794909e19773415be57ec959e4.tar.gz |
Make the Kaiser-Bessel window generator a common function
Patch by Robert Swain, robert d swain a gmail d com
Originally committed as revision 11514 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mdct.c')
-rw-r--r-- | libavcodec/mdct.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c index de32752899..c7008df4f1 100644 --- a/libavcodec/mdct.c +++ b/libavcodec/mdct.c @@ -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. */ |