diff options
Diffstat (limited to 'libavcodec/costablegen.c')
-rw-r--r-- | libavcodec/costablegen.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/costablegen.c b/libavcodec/costablegen.c index bb02666cf4..8a33fd4cf7 100644 --- a/libavcodec/costablegen.c +++ b/libavcodec/costablegen.c @@ -21,6 +21,7 @@ */ #include <stdio.h> +#include <string.h> #include <math.h> #ifndef M_PI @@ -29,22 +30,27 @@ #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"); for (i = 4; i <= BITS; i++) { int m = 1 << i; double freq = 2*M_PI/m; - printf("COSTABLE(%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; } |