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