aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Swain <robert.swain@gmail.com>2008-01-13 11:02:08 +0000
committerRobert Swain <robert.swain@gmail.com>2008-01-13 11:02:08 +0000
commit3ed546fe525eace861e708ab970cf91f69bfdd09 (patch)
treef34d1a9c71cb362238422c2a2c38df68be3a4409
parent99fac0806b0d20790b57b4f6c96676139438e2f6 (diff)
downloadffmpeg-3ed546fe525eace861e708ab970cf91f69bfdd09.tar.gz
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 Originally committed as revision 11520 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/ac3dec.c2
-rw-r--r--libavcodec/dsputil.h4
-rw-r--r--libavcodec/mdct.c15
3 files changed, 12 insertions, 9 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 5b0f868397..0ce75e7699 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -277,7 +277,7 @@ static int ac3_decode_init(AVCodecContext *avctx)
ac3_tables_init();
ff_mdct_init(&s->imdct_256, 8, 1);
ff_mdct_init(&s->imdct_512, 9, 1);
- ff_kbd_window_init(s->window);
+ ff_kbd_window_init(s->window, 5.0, 256);
dsputil_init(&s->dsp, avctx);
av_init_random(0, &s->dith_state);
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index da4c3a9089..c13943580a 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -648,8 +648,10 @@ typedef struct MDCTContext {
/**
* Generate a Kaiser-Bessel Derived Window.
* @param window pointer to half window
+ * @param alpha determines window shape
+ * @param n size of half window
*/
-void ff_kbd_window_init(float *window);
+void ff_kbd_window_init(float *window, float alpha, int n);
int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
void ff_imdct_calc(MDCTContext *s, FFTSample *output,
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index c7008df4f1..e809fcdcbc 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -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);
}