# HG changeset patch # User reimar # Date 1255629895 0 # Node ID 8fd8f6c1cdcc38cad8bedde03af2c5b092874297 # Parent 57acce8b1380aa6c21671a6f28fd3cd92c190002 Add support for hardcoded ff_sin_* tables. diff -r 57acce8b1380 -r 8fd8f6c1cdcc Makefile --- a/Makefile Thu Oct 15 17:55:51 2009 +0000 +++ b/Makefile Thu Oct 15 18:04:55 2009 +0000 @@ -31,7 +31,8 @@ OBJS-$(CONFIG_FFT) += fft.o $(FFT-OBJS-yes) OBJS-$(CONFIG_GOLOMB) += golomb.o OBJS-$(CONFIG_MDCT) += mdct.o -OBJS-$(CONFIG_RDFT) += rdft.o +RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o +OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) OBJS-$(CONFIG_VAAPI) += vaapi.o OBJS-$(CONFIG_VDPAU) += vdpau.o @@ -583,3 +584,6 @@ $(SUBDIR)cos_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) ./$< > $@ + +$(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF) + ./$< sin > $@ diff -r 57acce8b1380 -r 8fd8f6c1cdcc costablegen.c --- a/costablegen.c Thu Oct 15 17:55:51 2009 +0000 +++ b/costablegen.c Thu Oct 15 18:04:55 2009 +0000 @@ -21,6 +21,7 @@ */ #include +#include #include #ifndef M_PI @@ -29,22 +30,27 @@ #define BITS 16 #define FLOATFMT "%.18e" -int main(void) +int main(int argc, char *argv[]) { int i, j; + int do_sin = argc == 2 && !strcmp(argv[1], "sin"); + double (*func)(double) = do_sin ? sin : cos; + printf("/* This file was generated by libavcodec/costablegen */\n"); printf("#include \"dsputil.h\"\n"); for (i = 4; i <= BITS; i++) { int m = 1 << i; double freq = 2*M_PI/m; - printf("COSTABLE(%i) = {\n ", m); + printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m); for (j = 0; j < m/2 - 1; j++) { int idx = j > m/4 ? m/2 - j : j; - printf(" "FLOATFMT",", cos(idx*freq)); + if (do_sin && j >= m/4) + idx = m/4 - j; + printf(" "FLOATFMT",", func(idx*freq)); if ((j & 3) == 3) printf("\n "); } - printf(" "FLOATFMT"\n};\n", cos(freq)); + printf(" "FLOATFMT"\n};\n", func(do_sin ? -(m/4 - 1)*freq : freq)); } return 0; } diff -r 57acce8b1380 -r 8fd8f6c1cdcc dsputil.h --- a/dsputil.h Thu Oct 15 17:55:51 2009 +0000 +++ b/dsputil.h Thu Oct 15 18:04:55 2009 +0000 @@ -744,14 +744,16 @@ #if CONFIG_HARDCODED_TABLES #define COSTABLE_CONST const +#define SINTABLE_CONST const #else #define COSTABLE_CONST +#define SINTABLE_CONST #endif #define COSTABLE(size) \ COSTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]) #define SINTABLE(size) \ - DECLARE_ALIGNED_16(FFTSample, ff_sin_##size[size/2]) + SINTABLE_CONST DECLARE_ALIGNED_16(FFTSample, ff_sin_##size[size/2]) extern COSTABLE(16); extern COSTABLE(32); extern COSTABLE(64); @@ -874,7 +876,7 @@ /* pre/post rotation tables */ const FFTSample *tcos; - FFTSample *tsin; + SINTABLE_CONST FFTSample *tsin; FFTContext fft; } RDFTContext; diff -r 57acce8b1380 -r 8fd8f6c1cdcc rdft.c --- a/rdft.c Thu Oct 15 17:55:51 2009 +0000 +++ b/rdft.c Thu Oct 15 18:04:55 2009 +0000 @@ -27,6 +27,7 @@ */ /* sin(2*pi*x/n) for 0<=xtcos = ff_cos_tabs[nbits-4]; s->tsin = ff_sin_tabs[nbits-4]+(trans == RDFT || trans == IRIDFT)*(n>>2); +#if !CONFIG_HARDCODED_TABLES for (i = 0; i < (n>>2); i++) { s->tsin[i] = sin(i*theta); } +#endif return 0; }