Mercurial > libavcodec.hg
diff costablegen.c @ 10408:8fd8f6c1cdcc libavcodec
Add support for hardcoded ff_sin_* tables.
author | reimar |
---|---|
date | Thu, 15 Oct 2009 18:04:55 +0000 |
parents | 57acce8b1380 |
children | 36a16fb5c497 |
line wrap: on
line diff
--- a/costablegen.c Thu Oct 15 17:55:51 2009 +0000 +++ b/costablegen.c Thu Oct 15 18:04:55 2009 +0000 @@ -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; }