[FFmpeg-cvslog] r21108 - in trunk/libavcodec: Makefile aac.c aacenc.c atrac1.c dsputil.h mdct.c mdct_tablegen.c mdct_tablegen.h nellymoserdec.c tableprint.c tableprint.h twinvq.c wma.c wmaprodec.c

reimar subversion
Sat Jan 9 14:28:05 CET 2010


Author: reimar
Date: Sat Jan  9 14:28:04 2010
New Revision: 21108

Log:
Add support for hard-coded MDCT-related ff_sine_windows tables.

Added:
   trunk/libavcodec/mdct_tablegen.c
   trunk/libavcodec/mdct_tablegen.h
Modified:
   trunk/libavcodec/Makefile
   trunk/libavcodec/aac.c
   trunk/libavcodec/aacenc.c
   trunk/libavcodec/atrac1.c
   trunk/libavcodec/dsputil.h
   trunk/libavcodec/mdct.c
   trunk/libavcodec/nellymoserdec.c
   trunk/libavcodec/tableprint.c
   trunk/libavcodec/tableprint.h
   trunk/libavcodec/twinvq.c
   trunk/libavcodec/wma.c
   trunk/libavcodec/wmaprodec.c

Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/Makefile	Sat Jan  9 14:28:04 2010	(r21108)
@@ -697,6 +697,7 @@ $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen
 	./$< > $@
 
 ifdef CONFIG_HARDCODED_TABLES
+$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h
 $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h
 $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
 endif

Modified: trunk/libavcodec/aac.c
==============================================================================
--- trunk/libavcodec/aac.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/aac.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -552,8 +552,8 @@ static av_cold int aac_decode_init(AVCod
     // window initialization
     ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
     ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
-    ff_sine_window_init(ff_sine_1024, 1024);
-    ff_sine_window_init(ff_sine_128, 128);
+    ff_init_ff_sine_windows(10);
+    ff_init_ff_sine_windows( 7);
 
     return 0;
 }

Modified: trunk/libavcodec/aacenc.c
==============================================================================
--- trunk/libavcodec/aacenc.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/aacenc.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -178,8 +178,8 @@ static av_cold int aac_encode_init(AVCod
     // window init
     ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
     ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
-    ff_sine_window_init(ff_sine_1024, 1024);
-    ff_sine_window_init(ff_sine_128, 128);
+    ff_init_ff_sine_windows(10);
+    ff_init_ff_sine_windows(7);
 
     s->samples            = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0]));
     s->cpe                = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]);

Modified: trunk/libavcodec/atrac1.c
==============================================================================
--- trunk/libavcodec/atrac1.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/atrac1.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -339,7 +339,7 @@ static av_cold int atrac1_decode_init(AV
     ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
     ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
 
-    ff_sine_window_init(ff_sine_32, 32);
+    ff_init_ff_sine_windows(5);
 
     atrac_generate_tables();
 

Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/dsputil.h	Sat Jan  9 14:28:04 2010	(r21108)
@@ -741,15 +741,19 @@ typedef struct FFTContext {
 #if CONFIG_HARDCODED_TABLES
 #define COSTABLE_CONST const
 #define SINTABLE_CONST const
+#define SINETABLE_CONST const
 #else
 #define COSTABLE_CONST
 #define SINTABLE_CONST
+#define SINETABLE_CONST
 #endif
 
 #define COSTABLE(size) \
     COSTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2])
 #define SINTABLE(size) \
     SINTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_sin_##size[size/2])
+#define SINETABLE(size) \
+    SINETABLE_CONST DECLARE_ALIGNED_16(float, ff_sine_##size[size])
 extern COSTABLE(16);
 extern COSTABLE(32);
 extern COSTABLE(64);
@@ -846,15 +850,19 @@ void ff_kbd_window_init(float *window, f
  * @param   n       size of half window
  */
 void ff_sine_window_init(float *window, int n);
-extern float ff_sine_32  [  32];
-extern float ff_sine_64  [  64];
-extern float ff_sine_128 [ 128];
-extern float ff_sine_256 [ 256];
-extern float ff_sine_512 [ 512];
-extern float ff_sine_1024[1024];
-extern float ff_sine_2048[2048];
-extern float ff_sine_4096[4096];
-extern float * const ff_sine_windows[13];
+/**
+ * initialize the specified entry of ff_sine_windows
+ */
+void ff_init_ff_sine_windows(int index);
+extern SINETABLE(  32);
+extern SINETABLE(  64);
+extern SINETABLE( 128);
+extern SINETABLE( 256);
+extern SINETABLE( 512);
+extern SINETABLE(1024);
+extern SINETABLE(2048);
+extern SINETABLE(4096);
+extern SINETABLE_CONST float * const ff_sine_windows[13];
 
 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
 void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);

Modified: trunk/libavcodec/mdct.c
==============================================================================
--- trunk/libavcodec/mdct.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/mdct.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -48,26 +48,7 @@ av_cold void ff_kbd_window_init(float *w
        window[i] = sqrt(local_window[i] / sum);
 }
 
-DECLARE_ALIGNED(16, float, ff_sine_32  [  32]);
-DECLARE_ALIGNED(16, float, ff_sine_64  [  64]);
-DECLARE_ALIGNED(16, float, ff_sine_128 [ 128]);
-DECLARE_ALIGNED(16, float, ff_sine_256 [ 256]);
-DECLARE_ALIGNED(16, float, ff_sine_512 [ 512]);
-DECLARE_ALIGNED(16, float, ff_sine_1024[1024]);
-DECLARE_ALIGNED(16, float, ff_sine_2048[2048]);
-DECLARE_ALIGNED(16, float, ff_sine_4096[4096]);
-float * const ff_sine_windows[] = {
-    NULL, NULL, NULL, NULL, NULL, // unused
-    ff_sine_32 , ff_sine_64 ,
-    ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096
-};
-
-// Generate a sine window.
-av_cold void ff_sine_window_init(float *window, int n) {
-    int i;
-    for(i = 0; i < n; i++)
-        window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
-}
+#include "mdct_tablegen.h"
 
 /**
  * init MDCT or IMDCT computation.

Added: trunk/libavcodec/mdct_tablegen.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libavcodec/mdct_tablegen.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -0,0 +1,61 @@
+/*
+ * Generate a header file for hardcoded MDCT tables
+ *
+ * Copyright (c) 2009 Reimar D?ffinger <Reimar.Doeffinger at gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#define CONFIG_HARDCODED_TABLES 0
+#define av_cold
+#define SINETABLE_CONST
+#define SINETABLE(size) \
+    float ff_sine_##size[size]
+#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#include "mdct_tablegen.h"
+#include "tableprint.h"
+
+void tableinit(void)
+{
+    int i;
+    for (i = 5; i <= 12; i++)
+        ff_init_ff_sine_windows(i);
+}
+
+#define SINE_TABLE_DEF(size) \
+    { \
+        "SINETABLE("#size")", \
+        write_float_array, \
+        ff_sine_##size, \
+        size \
+    },
+
+const struct tabledef tables[] = {
+    SINE_TABLE_DEF(  32)
+    SINE_TABLE_DEF(  64)
+    SINE_TABLE_DEF( 128)
+    SINE_TABLE_DEF( 256)
+    SINE_TABLE_DEF( 512)
+    SINE_TABLE_DEF(1024)
+    SINE_TABLE_DEF(2048)
+    SINE_TABLE_DEF(4096)
+    { NULL }
+};

Added: trunk/libavcodec/mdct_tablegen.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libavcodec/mdct_tablegen.h	Sat Jan  9 14:28:04 2010	(r21108)
@@ -0,0 +1,59 @@
+/*
+ * Header file for hardcoded MDCT tables
+ *
+ * Copyright (c) 2009 Reimar D?ffinger <Reimar.Doeffinger at gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <assert.h>
+// do not use libavutil/mathematics.h since this is compiled both
+// for the host and the target and config.h is only valid for the target
+#include <math.h>
+
+#if !CONFIG_HARDCODED_TABLES
+SINETABLE(  32);
+SINETABLE(  64);
+SINETABLE( 128);
+SINETABLE( 256);
+SINETABLE( 512);
+SINETABLE(1024);
+SINETABLE(2048);
+SINETABLE(4096);
+#else
+#include "mdct_tables.h"
+#endif
+
+SINETABLE_CONST float * const ff_sine_windows[] = {
+    NULL, NULL, NULL, NULL, NULL, // unused
+    ff_sine_32 , ff_sine_64 ,
+    ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096
+};
+
+// Generate a sine window.
+av_cold void ff_sine_window_init(float *window, int n) {
+    int i;
+    for(i = 0; i < n; i++)
+        window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
+}
+
+av_cold void ff_init_ff_sine_windows(int index) {
+    assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows));
+#if !CONFIG_HARDCODED_TABLES
+    ff_sine_window_init(ff_sine_windows[index], 1 << index);
+#endif
+}

Modified: trunk/libavcodec/nellymoserdec.c
==============================================================================
--- trunk/libavcodec/nellymoserdec.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/nellymoserdec.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -144,7 +144,7 @@ static av_cold int decode_init(AVCodecCo
 
     /* Generate overlap window */
     if (!ff_sine_128[127])
-        ff_sine_window_init(ff_sine_128, 128);
+        ff_init_ff_sine_windows(7);
 
     avctx->sample_fmt = SAMPLE_FMT_S16;
     avctx->channel_layout = CH_LAYOUT_MONO;

Modified: trunk/libavcodec/tableprint.c
==============================================================================
--- trunk/libavcodec/tableprint.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/tableprint.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -39,6 +39,7 @@ void write_##name##_array(const void *ar
 
 WRITE_1D_FUNC(int8,   int8_t,   "%3"PRIi8, 15)
 WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7)
+WRITE_1D_FUNC(float,  float,    "%.18e", 3)
 
 #define WRITE_2D_FUNC(name, type)\
 void write_##name##_2d_array(const void *arg, int len, int len2)\

Modified: trunk/libavcodec/tableprint.h
==============================================================================
--- trunk/libavcodec/tableprint.h	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/tableprint.h	Sat Jan  9 14:28:04 2010	(r21108)
@@ -32,6 +32,7 @@
  */
 void write_int8_array     (const void *, int, int);
 void write_uint32_array   (const void *, int, int);
+void write_float_array    (const void *, int, int);
 void write_int8_2d_array  (const void *, int, int);
 void write_uint32_2d_array(const void *, int, int);
 /** \} */ // end of printfuncs group

Modified: trunk/libavcodec/twinvq.c
==============================================================================
--- trunk/libavcodec/twinvq.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/twinvq.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -893,9 +893,9 @@ static av_cold void init_mdct_win(TwinCo
     }
 
 
-    ff_sine_window_init(ff_sine_windows[av_log2(size_m)    ], size_m  );
-    ff_sine_window_init(ff_sine_windows[av_log2(size_s/2)  ], size_s/2);
-    ff_sine_window_init(ff_sine_windows[av_log2(mtab->size)], mtab->size);
+    ff_init_ff_sine_windows(av_log2(size_m));
+    ff_init_ff_sine_windows(av_log2(size_s/2));
+    ff_init_ff_sine_windows(av_log2(mtab->size));
 }
 
 /**

Modified: trunk/libavcodec/wma.c
==============================================================================
--- trunk/libavcodec/wma.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/wma.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -343,9 +343,7 @@ int ff_wma_init(AVCodecContext *avctx, i
 
     /* init MDCT windows : simple sinus window */
     for (i = 0; i < s->nb_block_sizes; i++) {
-        int n;
-        n = 1 << (s->frame_len_bits - i);
-        ff_sine_window_init(ff_sine_windows[s->frame_len_bits - i], n);
+        ff_init_ff_sine_windows(s->frame_len_bits - i);
         s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
     }
 

Modified: trunk/libavcodec/wmaprodec.c
==============================================================================
--- trunk/libavcodec/wmaprodec.c	Sat Jan  9 08:57:26 2010	(r21107)
+++ trunk/libavcodec/wmaprodec.c	Sat Jan  9 14:28:04 2010	(r21108)
@@ -425,9 +425,8 @@ static av_cold int decode_init(AVCodecCo
 
     /** init MDCT windows: simple sinus window */
     for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
-        const int n       = 1 << (WMAPRO_BLOCK_MAX_BITS - i);
         const int win_idx = WMAPRO_BLOCK_MAX_BITS - i;
-        ff_sine_window_init(ff_sine_windows[win_idx], n);
+        ff_init_ff_sine_windows(win_idx);
         s->windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx];
     }
 



More information about the ffmpeg-cvslog mailing list