aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-15 18:04:55 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-10-15 18:04:55 +0000
commit75df2edbb915f5faa0ee67d8d36d94a68e584fc0 (patch)
tree170a54282e94ee78425588bd88a3ab68d80723a9
parent4ee726b67097dcba8435f78235953389dac4e06e (diff)
downloadffmpeg-75df2edbb915f5faa0ee67d8d36d94a68e584fc0.tar.gz
Add support for hardcoded ff_sin_* tables.
Originally committed as revision 20244 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/Makefile6
-rw-r--r--libavcodec/costablegen.c14
-rw-r--r--libavcodec/dsputil.h6
-rw-r--r--libavcodec/rdft.c6
4 files changed, 24 insertions, 8 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 390d11e5d8..b00da207b7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -31,7 +31,8 @@ FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o
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)costablegen$(HOSTEXESUF): $(SUBDIR)costablegen.c
$(SUBDIR)cos_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF)
./$< > $@
+
+$(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF)
+ ./$< sin > $@
diff --git a/libavcodec/costablegen.c b/libavcodec/costablegen.c
index bb02666cf4..8a33fd4cf7 100644
--- a/libavcodec/costablegen.c
+++ b/libavcodec/costablegen.c
@@ -21,6 +21,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <math.h>
#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 --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index cfa9bcf011..b94c2f910a 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -744,14 +744,16 @@ typedef struct FFTContext {
#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 @@ typedef struct {
/* pre/post rotation tables */
const FFTSample *tcos;
- FFTSample *tsin;
+ SINTABLE_CONST FFTSample *tsin;
FFTContext fft;
} RDFTContext;
diff --git a/libavcodec/rdft.c b/libavcodec/rdft.c
index 5d3a07c146..01aef872c2 100644
--- a/libavcodec/rdft.c
+++ b/libavcodec/rdft.c
@@ -27,6 +27,7 @@
*/
/* sin(2*pi*x/n) for 0<=x<n/4, followed by n/2<=x<3n/4 */
+#if !CONFIG_HARDCODED_TABLES
SINTABLE(16);
SINTABLE(32);
SINTABLE(64);
@@ -40,7 +41,8 @@ SINTABLE(8192);
SINTABLE(16384);
SINTABLE(32768);
SINTABLE(65536);
-FFTSample * const ff_sin_tabs[] = {
+#endif
+SINTABLE_CONST FFTSample * const ff_sin_tabs[] = {
ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
};
@@ -63,9 +65,11 @@ av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
s->tcos = 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;
}