Mercurial > libavcodec.hg
comparison fft.c @ 10400:866dffa620d1 libavcodec
Use hardcoded instead of runtime-calculated ff_cos_* tables if
--enable-hardcoded-tables was used.
Due to the size, the code for the tables is generated at compile time.
author | reimar |
---|---|
date | Wed, 14 Oct 2009 21:41:24 +0000 |
parents | 74715d4288ad |
children | 57acce8b1380 |
comparison
equal
deleted
inserted
replaced
10399:136334ad62b3 | 10400:866dffa620d1 |
---|---|
26 * FFT/IFFT transforms. | 26 * FFT/IFFT transforms. |
27 */ | 27 */ |
28 | 28 |
29 #include "dsputil.h" | 29 #include "dsputil.h" |
30 | 30 |
31 #if CONFIG_HARDCODED_TABLES | |
32 #define COSTABLE(size) \ | |
33 extern const DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]); | |
34 #else | |
35 #define COSTABLE(size) \ | |
36 DECLARE_ALIGNED_16(FFTSample, ff_cos_##size[size/2]); | |
37 #endif | |
38 | |
31 /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ | 39 /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ |
32 DECLARE_ALIGNED_16(FFTSample, ff_cos_16[8]); | 40 COSTABLE(16) |
33 DECLARE_ALIGNED_16(FFTSample, ff_cos_32[16]); | 41 COSTABLE(32) |
34 DECLARE_ALIGNED_16(FFTSample, ff_cos_64[32]); | 42 COSTABLE(64) |
35 DECLARE_ALIGNED_16(FFTSample, ff_cos_128[64]); | 43 COSTABLE(128) |
36 DECLARE_ALIGNED_16(FFTSample, ff_cos_256[128]); | 44 COSTABLE(256) |
37 DECLARE_ALIGNED_16(FFTSample, ff_cos_512[256]); | 45 COSTABLE(512) |
38 DECLARE_ALIGNED_16(FFTSample, ff_cos_1024[512]); | 46 COSTABLE(1024) |
39 DECLARE_ALIGNED_16(FFTSample, ff_cos_2048[1024]); | 47 COSTABLE(2048) |
40 DECLARE_ALIGNED_16(FFTSample, ff_cos_4096[2048]); | 48 COSTABLE(4096) |
41 DECLARE_ALIGNED_16(FFTSample, ff_cos_8192[4096]); | 49 COSTABLE(8192) |
42 DECLARE_ALIGNED_16(FFTSample, ff_cos_16384[8192]); | 50 COSTABLE(16384) |
43 DECLARE_ALIGNED_16(FFTSample, ff_cos_32768[16384]); | 51 COSTABLE(32768) |
44 DECLARE_ALIGNED_16(FFTSample, ff_cos_65536[32768]); | 52 COSTABLE(65536) |
53 #if CONFIG_HARDCODED_TABLES | |
54 const | |
55 #endif | |
45 FFTSample * const ff_cos_tabs[] = { | 56 FFTSample * const ff_cos_tabs[] = { |
46 ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, | 57 ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, |
47 ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, | 58 ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, |
48 }; | 59 }; |
49 | 60 |
91 if (ARCH_ARM) ff_fft_init_arm(s); | 102 if (ARCH_ARM) ff_fft_init_arm(s); |
92 if (HAVE_ALTIVEC) ff_fft_init_altivec(s); | 103 if (HAVE_ALTIVEC) ff_fft_init_altivec(s); |
93 if (HAVE_MMX) ff_fft_init_mmx(s); | 104 if (HAVE_MMX) ff_fft_init_mmx(s); |
94 | 105 |
95 if (s->split_radix) { | 106 if (s->split_radix) { |
107 #if !CONFIG_HARDCODED_TABLES | |
96 for(j=4; j<=nbits; j++) { | 108 for(j=4; j<=nbits; j++) { |
97 int m = 1<<j; | 109 int m = 1<<j; |
98 double freq = 2*M_PI/m; | 110 double freq = 2*M_PI/m; |
99 FFTSample *tab = ff_cos_tabs[j-4]; | 111 FFTSample *tab = ff_cos_tabs[j-4]; |
100 for(i=0; i<=m/4; i++) | 112 for(i=0; i<=m/4; i++) |
101 tab[i] = cos(i*freq); | 113 tab[i] = cos(i*freq); |
102 for(i=1; i<m/4; i++) | 114 for(i=1; i<m/4; i++) |
103 tab[m/2-i] = tab[i]; | 115 tab[m/2-i] = tab[i]; |
104 } | 116 } |
117 #endif | |
105 for(i=0; i<n; i++) | 118 for(i=0; i<n; i++) |
106 s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; | 119 s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; |
107 s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); | 120 s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); |
108 } else { | 121 } else { |
109 int np, nblocks, np2, l; | 122 int np, nblocks, np2, l; |