aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Swain <robert.swain@gmail.com>2008-01-12 11:11:19 +0000
committerAndreas Ă–man <andreas@lonelycoder.com>2008-01-12 11:11:19 +0000
commit4eb7a735cb7218794909e19773415be57ec959e4 (patch)
tree63a307e8d8395993efab8a29a3678102339dccdc
parentf5b410312fb201e819f158c78d3a8266dd07eae9 (diff)
downloadffmpeg-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
-rw-r--r--libavcodec/ac3dec.c26
-rw-r--r--libavcodec/dsputil.h6
-rw-r--r--libavcodec/mdct.c22
3 files changed, 29 insertions, 25 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fb23725269..5b0f868397 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -197,30 +197,6 @@ typedef struct {
} AC3DecodeContext;
/**
- * Generate a Kaiser-Bessel Derived Window.
- */
-static void ac3_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);
-}
-
-/**
* Symmetrical Dequantization
* reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization
* Tables 7.19 to 7.23
@@ -301,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);
- ac3_window_init(s->window);
+ ff_kbd_window_init(s->window);
dsputil_init(&s->dsp, avctx);
av_init_random(0, &s->dith_state);
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index d541fe0abd..da4c3a9089 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -645,6 +645,12 @@ typedef struct MDCTContext {
FFTContext fft;
} MDCTContext;
+/**
+ * Generate a Kaiser-Bessel Derived Window.
+ * @param window pointer to half window
+ */
+void ff_kbd_window_init(float *window);
+
int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
void ff_imdct_calc(MDCTContext *s, FFTSample *output,
const FFTSample *input, FFTSample *tmp);
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.
*/