Revision 7087ce08 libavcodec/mdct.c

View differences:

libavcodec/mdct.c
24 24
#include "libavutil/common.h"
25 25
#include "libavutil/mathematics.h"
26 26
#include "fft.h"
27
#include "fft-internal.h"
27 28

  
28 29
/**
29 30
 * @file
30 31
 * MDCT/IMDCT transforms.
31 32
 */
32 33

  
34
#if CONFIG_FFT_FLOAT
35
#   define RSCALE(x) (x)
36
#else
37
#   define RSCALE(x) ((x) >> 1)
38
#endif
39

  
33 40
/**
34 41
 * init MDCT or IMDCT computation.
35 42
 */
......
70 77
    scale = sqrt(fabs(scale));
71 78
    for(i=0;i<n4;i++) {
72 79
        alpha = 2 * M_PI * (i + theta) / n;
73
        s->tcos[i*tstep] = -cos(alpha) * scale;
74
        s->tsin[i*tstep] = -sin(alpha) * scale;
80
        s->tcos[i*tstep] = FIX15(-cos(alpha) * scale);
81
        s->tsin[i*tstep] = FIX15(-sin(alpha) * scale);
75 82
    }
76 83
    return 0;
77 84
 fail:
......
79 86
    return -1;
80 87
}
81 88

  
82
/* complex multiplication: p = a * b */
83
#define CMUL(pre, pim, are, aim, bre, bim) \
84
{\
85
    FFTSample _are = (are);\
86
    FFTSample _aim = (aim);\
87
    FFTSample _bre = (bre);\
88
    FFTSample _bim = (bim);\
89
    (pre) = _are * _bre - _aim * _bim;\
90
    (pim) = _are * _bim + _aim * _bre;\
91
}
92

  
93 89
/**
94 90
 * Compute the middle half of the inverse MDCT of size N = 2^nbits,
95 91
 * thus excluding the parts that can be derived by symmetry
......
161 157
void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
162 158
{
163 159
    int i, j, n, n8, n4, n2, n3;
164
    FFTSample re, im;
160
    FFTDouble re, im;
165 161
    const uint16_t *revtab = s->revtab;
166 162
    const FFTSample *tcos = s->tcos;
167 163
    const FFTSample *tsin = s->tsin;
......
175 171

  
176 172
    /* pre rotation */
177 173
    for(i=0;i<n8;i++) {
178
        re = -input[2*i+n3] - input[n3-1-2*i];
179
        im = -input[n4+2*i] + input[n4-1-2*i];
174
        re = RSCALE(-input[2*i+n3] - input[n3-1-2*i]);
175
        im = RSCALE(-input[n4+2*i] + input[n4-1-2*i]);
180 176
        j = revtab[i];
181 177
        CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
182 178

  
183
        re = input[2*i] - input[n2-1-2*i];
184
        im = -(input[n2+2*i] + input[n-1-2*i]);
179
        re = RSCALE( input[2*i]    - input[n2-1-2*i]);
180
        im = RSCALE(-input[n2+2*i] - input[ n-1-2*i]);
185 181
        j = revtab[n8 + i];
186 182
        CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
187 183
    }

Also available in: Unified diff