Libav
|
00001 /* 00002 * Generate a header file for hardcoded ff_cos_* tables 00003 * 00004 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> 00005 * 00006 * This file is part of FFmpeg. 00007 * 00008 * FFmpeg is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * FFmpeg is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 }