[FFmpeg-devel] [RFC] declarations for ff_cos_* in dsputil.h

Reimar Döffinger Reimar.Doeffinger
Thu Oct 15 11:55:22 CEST 2009


On Thu, Oct 15, 2009 at 12:06:01AM +0200, Reimar D?ffinger wrote:
> On Wed, Oct 14, 2009 at 10:56:37PM +0100, M?ns Rullg?rd wrote:
> > Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
> > > Index: libavcodec/costablegen.c
> > > ===================================================================
> > > --- libavcodec/costablegen.c	(revision 20232)
> > > +++ libavcodec/costablegen.c	(working copy)
> > > @@ -37,7 +37,7 @@
> > >      for (i = 4; i <= BITS; i++) {
> > >          int m = 1 << i;
> > >          double freq = 2*M_PI/m;
> > > -        printf("const DECLARE_ALIGNED_16(FFTSample, ff_cos_%i[]) = {\n   ", m);
> > > +        printf("COSTABLE(%i) = {\n   ", m);
> > >          for (j = 0; j < m/2 - 1; j++) {
> > >              int idx = j > m/4 ? m/2 - j : j;
> > >              printf(" "FLOATFMT",", cos(idx*freq));
> > > Index: libavcodec/dsputil.h
> > > ===================================================================
> > > --- libavcodec/dsputil.h	(revision 20232)
> > > +++ libavcodec/dsputil.h	(working copy)
> > > @@ -743,11 +743,28 @@
> > >  } FFTContext;
> > >  
> > >  #if CONFIG_HARDCODED_TABLES
> > > -extern const FFTSample* const ff_cos_tabs[13];
> > > +#define COSTABLE_CONST const
> > >  #else
> > > -extern FFTSample* const ff_cos_tabs[13];
> > > +#define COSTABLE_CONST
> > >  #endif
> > >  
> > > +#define COSTABLE(size) \
> > > +    COSTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]);
> > 
> > Doesn't that semicolon break the initialisers?
> 
> Yes, I was too lazy to let the compile run through on this slow thing.
> I fixed it locally, I'll post a new version once I got time to run a full
> compile and make test.
> Any comments on the idea in general?

A working implementation for both ff_sin_ and ff_cos_
-------------- next part --------------
Index: libavcodec/fft.c
===================================================================
--- libavcodec/fft.c	(revision 20233)
+++ libavcodec/fft.c	(working copy)
@@ -28,32 +28,23 @@
 
 #include "dsputil.h"
 
-#if CONFIG_HARDCODED_TABLES
-#define COSTABLE(size) \
-    extern const DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]);
-#else
-#define COSTABLE(size) \
-    DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]);
-#endif
-
 /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
-COSTABLE(16)
-COSTABLE(32)
-COSTABLE(64)
-COSTABLE(128)
-COSTABLE(256)
-COSTABLE(512)
-COSTABLE(1024)
-COSTABLE(2048)
-COSTABLE(4096)
-COSTABLE(8192)
-COSTABLE(16384)
-COSTABLE(32768)
-COSTABLE(65536)
-#if CONFIG_HARDCODED_TABLES
-const
+#if !CONFIG_HARDCODED_TABLES
+COSTABLE(16);
+COSTABLE(32);
+COSTABLE(64);
+COSTABLE(128);
+COSTABLE(256);
+COSTABLE(512);
+COSTABLE(1024);
+COSTABLE(2048);
+COSTABLE(4096);
+COSTABLE(8192);
+COSTABLE(16384);
+COSTABLE(32768);
+COSTABLE(65536);
 #endif
-FFTSample * const ff_cos_tabs[] = {
+COSTABLE_CONST FFTSample * const ff_cos_tabs[] = {
     ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024,
     ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536,
 };
Index: libavcodec/costablegen.c
===================================================================
--- libavcodec/costablegen.c	(revision 20233)
+++ libavcodec/costablegen.c	(working copy)
@@ -37,7 +37,7 @@
     for (i = 4; i <= BITS; i++) {
         int m = 1 << i;
         double freq = 2*M_PI/m;
-        printf("const DECLARE_ALIGNED_16(FFTSample, ff_cos_%i[]) = {\n   ", m);
+        printf("COSTABLE(%i) = {\n   ", m);
         for (j = 0; j < m/2 - 1; j++) {
             int idx = j > m/4 ? m/2 - j : j;
             printf(" "FLOATFMT",", cos(idx*freq));
Index: libavcodec/dsputil.h
===================================================================
--- libavcodec/dsputil.h	(revision 20233)
+++ libavcodec/dsputil.h	(working copy)
@@ -743,11 +743,44 @@
 } FFTContext;
 
 #if CONFIG_HARDCODED_TABLES
-extern const FFTSample* const ff_cos_tabs[13];
+#define COSTABLE_CONST const
 #else
-extern FFTSample* const ff_cos_tabs[13];
+#define COSTABLE_CONST
 #endif
 
+#define COSTABLE(size) \
+    COSTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2])
+#define SINTABLE(size) \
+    DECLARE_ALIGNED_16(FFTSample, ff_sin_##size[size/2])
+extern COSTABLE(16);
+extern COSTABLE(32);
+extern COSTABLE(64);
+extern COSTABLE(128);
+extern COSTABLE(256);
+extern COSTABLE(512);
+extern COSTABLE(1024);
+extern COSTABLE(2048);
+extern COSTABLE(4096);
+extern COSTABLE(8192);
+extern COSTABLE(16384);
+extern COSTABLE(32768);
+extern COSTABLE(65536);
+extern COSTABLE_CONST FFTSample* const ff_cos_tabs[13];
+
+extern SINTABLE(16);
+extern SINTABLE(32);
+extern SINTABLE(64);
+extern SINTABLE(128);
+extern SINTABLE(256);
+extern SINTABLE(512);
+extern SINTABLE(1024);
+extern SINTABLE(2048);
+extern SINTABLE(4096);
+extern SINTABLE(8192);
+extern SINTABLE(16384);
+extern SINTABLE(32768);
+extern SINTABLE(65536);
+
 /**
  * Sets up a complex FFT.
  * @param nbits           log2 of the length of the input array
Index: libavcodec/rdft.c
===================================================================
--- libavcodec/rdft.c	(revision 20233)
+++ libavcodec/rdft.c	(working copy)
@@ -27,19 +27,19 @@
  */
 
 /* sin(2*pi*x/n) for 0<=x<n/4, followed by n/2<=x<3n/4 */
-DECLARE_ALIGNED_16(FFTSample, ff_sin_16[8]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_32[16]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_64[32]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_128[64]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_256[128]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_512[256]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_1024[512]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_2048[1024]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_4096[2048]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_8192[4096]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_16384[8192]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_32768[16384]);
-DECLARE_ALIGNED_16(FFTSample, ff_sin_65536[32768]);
+SINTABLE(16);
+SINTABLE(32);
+SINTABLE(64);
+SINTABLE(128);
+SINTABLE(256);
+SINTABLE(512);
+SINTABLE(1024);
+SINTABLE(2048);
+SINTABLE(4096);
+SINTABLE(8192);
+SINTABLE(16384);
+SINTABLE(32768);
+SINTABLE(65536);
 FFTSample * const ff_sin_tabs[] = {
     ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
     ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,



More information about the ffmpeg-devel mailing list