summaryrefslogtreecommitdiff
path: root/libavcodec/costablegen.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-15 18:04:55 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-15 18:04:55 +0000
commit75df2edbb915f5faa0ee67d8d36d94a68e584fc0 (patch)
tree170a54282e94ee78425588bd88a3ab68d80723a9 /libavcodec/costablegen.c
parent4ee726b67097dcba8435f78235953389dac4e06e (diff)
Add support for hardcoded ff_sin_* tables.
Originally committed as revision 20244 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/costablegen.c')
-rw-r--r--libavcodec/costablegen.c14
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;
}