Mercurial > libavcodec.hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
10407:57acce8b1380 | 10408:8fd8f6c1cdcc |
---|---|
19 * License along with FFmpeg; if not, write to the Free Software | 19 * License along with FFmpeg; if not, write to the Free Software |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 */ | 21 */ |
22 | 22 |
23 #include <stdio.h> | 23 #include <stdio.h> |
24 #include <string.h> | |
24 #include <math.h> | 25 #include <math.h> |
25 | 26 |
26 #ifndef M_PI | 27 #ifndef M_PI |
27 #define M_PI 3.14159265358979323846 | 28 #define M_PI 3.14159265358979323846 |
28 #endif | 29 #endif |
29 #define BITS 16 | 30 #define BITS 16 |
30 #define FLOATFMT "%.18e" | 31 #define FLOATFMT "%.18e" |
31 | 32 |
32 int main(void) | 33 int main(int argc, char *argv[]) |
33 { | 34 { |
34 int i, j; | 35 int i, j; |
36 int do_sin = argc == 2 && !strcmp(argv[1], "sin"); | |
37 double (*func)(double) = do_sin ? sin : cos; | |
38 | |
35 printf("/* This file was generated by libavcodec/costablegen */\n"); | 39 printf("/* This file was generated by libavcodec/costablegen */\n"); |
36 printf("#include \"dsputil.h\"\n"); | 40 printf("#include \"dsputil.h\"\n"); |
37 for (i = 4; i <= BITS; i++) { | 41 for (i = 4; i <= BITS; i++) { |
38 int m = 1 << i; | 42 int m = 1 << i; |
39 double freq = 2*M_PI/m; | 43 double freq = 2*M_PI/m; |
40 printf("COSTABLE(%i) = {\n ", m); | 44 printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m); |
41 for (j = 0; j < m/2 - 1; j++) { | 45 for (j = 0; j < m/2 - 1; j++) { |
42 int idx = j > m/4 ? m/2 - j : j; | 46 int idx = j > m/4 ? m/2 - j : j; |
43 printf(" "FLOATFMT",", cos(idx*freq)); | 47 if (do_sin && j >= m/4) |
48 idx = m/4 - j; | |
49 printf(" "FLOATFMT",", func(idx*freq)); | |
44 if ((j & 3) == 3) | 50 if ((j & 3) == 3) |
45 printf("\n "); | 51 printf("\n "); |
46 } | 52 } |
47 printf(" "FLOATFMT"\n};\n", cos(freq)); | 53 printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq)); |
48 } | 54 } |
49 return 0; | 55 return 0; |
50 } | 56 } |