diff options
author | Mans Rullgard <mans@mansr.com> | 2011-03-26 15:20:30 +0000 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-03-31 12:01:27 +0100 |
commit | 7087ce08c84dd20404ba258096530cc547d25c15 (patch) | |
tree | f4e9433089df1f8849d43c9a5f3c27d533a6b212 /libavcodec/costablegen.c | |
parent | 2f97b12eaf8ada30b3884604d66dbdf51e727b67 (diff) | |
download | ffmpeg-7087ce08c84dd20404ba258096530cc547d25c15.tar.gz |
Fixed-point FFT and MDCT
Diffstat (limited to 'libavcodec/costablegen.c')
-rw-r--r-- | libavcodec/costablegen.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libavcodec/costablegen.c b/libavcodec/costablegen.c index 33afd8de2d..65c492696b 100644 --- a/libavcodec/costablegen.c +++ b/libavcodec/costablegen.c @@ -29,14 +29,33 @@ #endif #define BITS 16 #define FLOATFMT "%.18e" +#define FIXEDFMT "%6d" + +static int clip_f15(int v) +{ + return v < -32767 ? -32767 : + v > 32767 ? 32767 : + v; +} + +static void printval(double val, int fixed) +{ + if (fixed) + printf(" "FIXEDFMT",", clip_f15(lrint(val * (double)(1<<15)))); + else + printf(" "FLOATFMT",", val); + +} int main(int argc, char *argv[]) { int i, j; - int do_sin = argc == 2 && !strcmp(argv[1], "sin"); + int do_sin = argc > 1 && !strcmp(argv[1], "sin"); + int fixed = argc > 2 && !strcmp(argv[2], "fixed"); double (*func)(double) = do_sin ? sin : cos; printf("/* This file was generated by libavcodec/costablegen */\n"); + printf("#define CONFIG_FFT_FLOAT %d\n", !fixed); printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h"); for (i = 4; i <= BITS; i++) { int m = 1 << i; @@ -46,11 +65,12 @@ int main(int argc, char *argv[]) int idx = j > m/4 ? m/2 - j : j; if (do_sin && j >= m/4) idx = m/4 - j; - printf(" "FLOATFMT",", func(idx*freq)); + printval(func(idx*freq), fixed); if ((j & 3) == 3) printf("\n "); } - printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq)); + printval(func(do_sin ? -(m/4 - 1)*freq : freq), fixed); + printf("\n};\n"); } return 0; } |