00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <string.h>
00025 #include <math.h>
00026
00027 #ifndef M_PI
00028 #define M_PI 3.14159265358979323846
00029 #endif
00030 #define BITS 16
00031 #define FLOATFMT "%.18e"
00032
00033 int main(int argc, char *argv[])
00034 {
00035 int i, j;
00036 int do_sin = argc == 2 && !strcmp(argv[1], "sin");
00037 double (*func)(double) = do_sin ? sin : cos;
00038
00039 printf("/* This file was generated by libavcodec/costablegen */\n");
00040 printf("#include \"libavcodec/fft.h\"\n");
00041 for (i = 4; i <= BITS; i++) {
00042 int m = 1 << i;
00043 double freq = 2*M_PI/m;
00044 printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m);
00045 for (j = 0; j < m/2 - 1; j++) {
00046 int idx = j > m/4 ? m/2 - j : j;
00047 if (do_sin && j >= m/4)
00048 idx = m/4 - j;
00049 printf(" "FLOATFMT",", func(idx*freq));
00050 if ((j & 3) == 3)
00051 printf("\n ");
00052 }
00053 printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq));
00054 }
00055 return 0;
00056 }