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 #define FIXEDFMT "%6d"
00033
00034 static int clip_f15(int v)
00035 {
00036 return v < -32767 ? -32767 :
00037 v > 32767 ? 32767 :
00038 v;
00039 }
00040
00041 static void printval(double val, int fixed)
00042 {
00043 if (fixed)
00044 printf(" "FIXEDFMT",", clip_f15(lrint(val * (double)(1<<15))));
00045 else
00046 printf(" "FLOATFMT",", val);
00047
00048 }
00049
00050 int main(int argc, char *argv[])
00051 {
00052 int i, j;
00053 int do_sin = argc > 1 && !strcmp(argv[1], "sin");
00054 int fixed = argc > 1 && strstr(argv[1], "fixed");
00055 double (*func)(double) = do_sin ? sin : cos;
00056
00057 printf("/* This file was automatically generated. */\n");
00058 printf("#define CONFIG_FFT_FLOAT %d\n", !fixed);
00059 printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h");
00060 for (i = 4; i <= BITS; i++) {
00061 int m = 1 << i;
00062 double freq = 2*M_PI/m;
00063 printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m);
00064 for (j = 0; j < m/2 - 1; j++) {
00065 int idx = j > m/4 ? m/2 - j : j;
00066 if (do_sin && j >= m/4)
00067 idx = m/4 - j;
00068 printval(func(idx*freq), fixed);
00069 if ((j & 3) == 3)
00070 printf("\n ");
00071 }
00072 printval(func(do_sin ? -(m/4 - 1)*freq : freq), fixed);
00073 printf("\n};\n");
00074 }
00075 return 0;
00076 }