[FFmpeg-cvslog] Move ff_kbd_window_init() to a separate file

Mans Rullgard git at videolan.org
Mon Mar 21 04:12:47 CET 2011


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Sat Mar 19 17:19:04 2011 +0000| [a45fbda994df54600101e845e29f0af60e456e95] | committer: Mans Rullgard

Move ff_kbd_window_init() to a separate file

This function is not tightly coupled to mdct, and it's in the way
of making a fixed-point mdct implementation.

Signed-off-by: Mans Rullgard <mans at mansr.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a45fbda994df54600101e845e29f0af60e456e95
---

 libavcodec/Makefile       |    6 ++--
 libavcodec/aacdec.c       |    1 +
 libavcodec/aacenc.c       |    1 +
 libavcodec/ac3dec.c       |    1 +
 libavcodec/ac3enc_float.c |    1 +
 libavcodec/fft.h          |   13 ------------
 libavcodec/kbdwin.c       |   48 +++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/kbdwin.h       |   35 ++++++++++++++++++++++++++++++++
 libavcodec/mdct.c         |   25 -----------------------
 9 files changed, 90 insertions(+), 41 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d72a340..b21921b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -49,14 +49,14 @@ OBJS-$(CONFIG_VDPAU)                   += vdpau.o
 OBJS-$(CONFIG_A64MULTI_ENCODER)        += a64multienc.o elbg.o
 OBJS-$(CONFIG_A64MULTI5_ENCODER)       += a64multienc.o elbg.o
 OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps.o \
-                                          aacadtsdec.o mpeg4audio.o
+                                          aacadtsdec.o mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o    \
                                           aacpsy.o aactab.o      \
                                           psymodel.o iirfilter.o \
-                                          mpeg4audio.o
+                                          mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
 OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o
-OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o
+OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
 OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index a981fbe..0a1ac93 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -87,6 +87,7 @@
 #include "fft.h"
 #include "fmtconvert.h"
 #include "lpc.h"
+#include "kbdwin.h"
 
 #include "aac.h"
 #include "aactab.h"
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index f74e285..9b53001 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -34,6 +34,7 @@
 #include "put_bits.h"
 #include "dsputil.h"
 #include "mpeg4audio.h"
+#include "kbdwin.h"
 
 #include "aac.h"
 #include "aactab.h"
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fbc8dd1..b089adc 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -35,6 +35,7 @@
 #include "ac3_parser.h"
 #include "ac3dec.h"
 #include "ac3dec_data.h"
+#include "kbdwin.h"
 
 /** Large enough for maximum possible frame size when the specification limit is ignored */
 #define AC3_FRAME_BUFFER_SIZE 32768
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index e46ec6a..91f73e5 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -28,6 +28,7 @@
 
 #define CONFIG_AC3ENC_FLOAT 1
 #include "ac3enc.c"
+#include "kbdwin.h"
 
 
 /**
diff --git a/libavcodec/fft.h b/libavcodec/fft.h
index 610a9a9..88fd325 100644
--- a/libavcodec/fft.h
+++ b/libavcodec/fft.h
@@ -125,19 +125,6 @@ void ff_dct_init_mmx(DCTContext *s);
 void ff_fft_end(FFTContext *s);
 
 /**
- * Maximum window size for ff_kbd_window_init.
- */
-#define FF_KBD_WINDOW_MAX 1024
-
-/**
- * Generate a Kaiser-Bessel Derived Window.
- * @param   window  pointer to half window
- * @param   alpha   determines window shape
- * @param   n       size of half window, max FF_KBD_WINDOW_MAX
- */
-void ff_kbd_window_init(float *window, float alpha, int n);
-
-/**
  * Generate a sine window.
  * @param   window  pointer to half window
  * @param   n       size of half window
diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c
new file mode 100644
index 0000000..c2c1c59
--- /dev/null
+++ b/libavcodec/kbdwin.c
@@ -0,0 +1,48 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <assert.h>
+#include <libavutil/mathematics.h>
+#include "libavutil/attributes.h"
+#include "kbdwin.h"
+
+#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
+
+av_cold void ff_kbd_window_init(float *window, float alpha, int n)
+{
+   int i, j;
+   double sum = 0.0, bessel, tmp;
+   double local_window[FF_KBD_WINDOW_MAX];
+   double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
+
+   assert(n <= FF_KBD_WINDOW_MAX);
+
+   for (i = 0; i < n; i++) {
+       tmp = i * (n - i) * alpha2;
+       bessel = 1.0;
+       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 < n; i++)
+       window[i] = sqrt(local_window[i] / sum);
+}
+
diff --git a/libavcodec/kbdwin.h b/libavcodec/kbdwin.h
new file mode 100644
index 0000000..5ac2b8c
--- /dev/null
+++ b/libavcodec/kbdwin.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_KBDWIN_H
+#define AVCODEC_KBDWIN_H
+
+/**
+ * Maximum window size for ff_kbd_window_init.
+ */
+#define FF_KBD_WINDOW_MAX 1024
+
+/**
+ * Generate a Kaiser-Bessel Derived Window.
+ * @param   window  pointer to half window
+ * @param   alpha   determines window shape
+ * @param   n       size of half window, max FF_KBD_WINDOW_MAX
+ */
+void ff_kbd_window_init(float *window, float alpha, int n);
+
+#endif
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index c99a6cf..f2f34f9 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -30,31 +30,6 @@
  * MDCT/IMDCT transforms.
  */
 
-// Generate a Kaiser-Bessel Derived Window.
-#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
-av_cold void ff_kbd_window_init(float *window, float alpha, int n)
-{
-   int i, j;
-   double sum = 0.0, bessel, tmp;
-   double local_window[FF_KBD_WINDOW_MAX];
-   double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
-
-   assert(n <= FF_KBD_WINDOW_MAX);
-
-   for (i = 0; i < n; i++) {
-       tmp = i * (n - i) * alpha2;
-       bessel = 1.0;
-       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 < n; i++)
-       window[i] = sqrt(local_window[i] / sum);
-}
-
 #include "mdct_tablegen.h"
 
 /**




More information about the ffmpeg-cvslog mailing list