[FFmpeg-devel] [RFC] "simplify" rdft sin table init

Reimar Döffinger Reimar.Doeffinger
Thu Nov 5 19:37:37 CET 2009


Hello,
this patch would make rdft init initialize the whole table for the bit
size selected, not just one half depending on transform.
It seems a bit simpler to me, though mostly due to the different but very
similar-looking conditions used, which could also be avoided by using an
extra variable for the condition.
Any opinions?
-------------- next part --------------
Index: libavcodec/rdft.c
===================================================================
--- libavcodec/rdft.c	(revision 20464)
+++ libavcodec/rdft.c	(working copy)
@@ -52,7 +52,7 @@
 {
     int n = 1 << nbits;
     int i;
-    const double theta = (trans == RDFT || trans == IRIDFT ? -1 : 1)*2*M_PI/n;
+    const double theta = 2*M_PI/n;
 
     s->nbits           = nbits;
     s->inverse         = trans == IRDFT || trans == IRIDFT;
@@ -66,12 +66,15 @@
 
     ff_init_ff_cos_tabs(nbits);
     s->tcos = ff_cos_tabs[nbits];
-    s->tsin = ff_sin_tabs[nbits]+(trans == RDFT || trans == IRIDFT)*(n>>2);
+    s->tsin = ff_sin_tabs[nbits];
 #if !CONFIG_HARDCODED_TABLES
     for (i = 0; i < (n>>2); i++) {
         s->tsin[i] = sin(i*theta);
+        s->tsin[i + (n>>2)] = -s->tsin[i];
     }
 #endif
+    if (trans == RDFT || trans == IRIDFT)
+        s->tsin += n>>2;
     return 0;
 }
 



More information about the ffmpeg-devel mailing list