Revision 7087ce08 libavcodec/fft.c

View differences:

libavcodec/fft.c
30 30
#include <string.h>
31 31
#include "libavutil/mathematics.h"
32 32
#include "fft.h"
33
#include "fft-internal.h"
33 34

  
34 35
/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
35 36
#if !CONFIG_HARDCODED_TABLES
......
47 48
COSTABLE(32768);
48 49
COSTABLE(65536);
49 50
#endif
50
COSTABLE_CONST FFTSample * const ff_cos_tabs[] = {
51
COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
51 52
    NULL, NULL, NULL, NULL,
52
    ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024,
53
    ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536,
53
    FFT_NAME(ff_cos_16),
54
    FFT_NAME(ff_cos_32),
55
    FFT_NAME(ff_cos_64),
56
    FFT_NAME(ff_cos_128),
57
    FFT_NAME(ff_cos_256),
58
    FFT_NAME(ff_cos_512),
59
    FFT_NAME(ff_cos_1024),
60
    FFT_NAME(ff_cos_2048),
61
    FFT_NAME(ff_cos_4096),
62
    FFT_NAME(ff_cos_8192),
63
    FFT_NAME(ff_cos_16384),
64
    FFT_NAME(ff_cos_32768),
65
    FFT_NAME(ff_cos_65536),
54 66
};
55 67

  
56 68
static void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
......
73 85
    int i;
74 86
    int m = 1<<index;
75 87
    double freq = 2*M_PI/m;
76
    FFTSample *tab = ff_cos_tabs[index];
88
    FFTSample *tab = FFT_NAME(ff_cos_tabs)[index];
77 89
    for(i=0; i<=m/4; i++)
78
        tab[i] = cos(i*freq);
90
        tab[i] = FIX15(cos(i*freq));
79 91
    for(i=1; i<m/4; i++)
80 92
        tab[m/2-i] = tab[i];
81 93
#endif
......
107 119
    s->mdct_calc   = ff_mdct_calc_c;
108 120
#endif
109 121

  
122
#if CONFIG_FFT_FLOAT
110 123
    if (ARCH_ARM)     ff_fft_init_arm(s);
111 124
    if (HAVE_ALTIVEC) ff_fft_init_altivec(s);
112 125
    if (HAVE_MMX)     ff_fft_init_mmx(s);
126
#endif
113 127

  
114 128
    for(j=4; j<=nbits; j++) {
115 129
        ff_init_ff_cos_tabs(j);
......
144 158
    av_freep(&s->tmp_buf);
145 159
}
146 160

  
147
#define sqrthalf (float)M_SQRT1_2
148

  
149
#define BF(x,y,a,b) {\
150
    x = a - b;\
151
    y = a + b;\
152
}
153

  
154 161
#define BUTTERFLIES(a0,a1,a2,a3) {\
155 162
    BF(t3, t5, t5, t1);\
156 163
    BF(a2.re, a0.re, a0.re, t5);\
......
174 181
}
175 182

  
176 183
#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
177
    t1 = a2.re * wre + a2.im * wim;\
178
    t2 = a2.im * wre - a2.re * wim;\
179
    t5 = a3.re * wre - a3.im * wim;\
180
    t6 = a3.im * wre + a3.re * wim;\
184
    CMUL(t1, t2, a2.re, a2.im, wre, -wim);\
185
    CMUL(t5, t6, a3.re, a3.im, wre,  wim);\
181 186
    BUTTERFLIES(a0,a1,a2,a3)\
182 187
}
183 188

  
......
193 198
#define PASS(name)\
194 199
static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
195 200
{\
196
    FFTSample t1, t2, t3, t4, t5, t6;\
201
    FFTDouble t1, t2, t3, t4, t5, t6;\
197 202
    int o1 = 2*n;\
198 203
    int o2 = 4*n;\
199 204
    int o3 = 6*n;\
......
222 227
    fft##n2(z);\
223 228
    fft##n4(z+n4*2);\
224 229
    fft##n4(z+n4*3);\
225
    pass(z,ff_cos_##n,n4/2);\
230
    pass(z,FFT_NAME(ff_cos_##n),n4/2);\
226 231
}
227 232

  
228 233
static void fft4(FFTComplex *z)
229 234
{
230
    FFTSample t1, t2, t3, t4, t5, t6, t7, t8;
235
    FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
231 236

  
232 237
    BF(t3, t1, z[0].re, z[1].re);
233 238
    BF(t8, t6, z[3].re, z[2].re);
......
241 246

  
242 247
static void fft8(FFTComplex *z)
243 248
{
244
    FFTSample t1, t2, t3, t4, t5, t6, t7, t8;
249
    FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
245 250

  
246 251
    fft4(z);
247 252

  
......
262 267
#if !CONFIG_SMALL
263 268
static void fft16(FFTComplex *z)
264 269
{
265
    FFTSample t1, t2, t3, t4, t5, t6;
270
    FFTDouble t1, t2, t3, t4, t5, t6;
271
    FFTSample cos_16_1 = FFT_NAME(ff_cos_16)[1];
272
    FFTSample cos_16_3 = FFT_NAME(ff_cos_16)[3];
266 273

  
267 274
    fft8(z);
268 275
    fft4(z+8);
......
270 277

  
271 278
    TRANSFORM_ZERO(z[0],z[4],z[8],z[12]);
272 279
    TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf);
273
    TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]);
274
    TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]);
280
    TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3);
281
    TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1);
275 282
}
276 283
#else
277 284
DECL_FFT(16,8,4)

Also available in: Unified diff