]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/costablegen.c
Reindent
[ffmpeg] / libavcodec / costablegen.c
index c27d8877950eb836255ab08a4622604d6f5ffbd0..f82fb042fb350c3a86fad17d062180d9750e7012 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <math.h>
 
 #ifndef M_PI
 #define BITS 16
 #define FLOATFMT "%.18e"
 
-int main(void)
+int main(int argc, char *argv[])
 {
     int i, j;
+    int do_sin = argc == 2 && !strcmp(argv[1], "sin");
+    double (*func)(double) = do_sin ? sin : cos;
+
     printf("/* This file was generated by libavcodec/costablegen */\n");
-    printf("#include \"dsputil.h\"\n");
+    printf("#include \"libavcodec/dsputil.h\"\n");
     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("%s(%i) = {\n   ", do_sin ? "SINTABLE" : "COSTABLE", m);
         for (j = 0; j < m/2 - 1; j++) {
             int idx = j > m/4 ? m/2 - j : j;
-            printf(" "FLOATFMT",", cos(idx*freq));
+            if (do_sin && j >= m/4)
+                idx = m/4 - j;
+            printf(" "FLOATFMT",", func(idx*freq));
             if ((j & 3) == 3)
                 printf("\n   ");
         }
-        printf(" "FLOATFMT"\n};\n", cos(freq));
+        printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq));
     }
     return 0;
 }