aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mdct.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-03-26 15:20:30 +0000
committerMans Rullgard <mans@mansr.com>2011-03-31 12:01:27 +0100
commit7087ce08c84dd20404ba258096530cc547d25c15 (patch)
treef4e9433089df1f8849d43c9a5f3c27d533a6b212 /libavcodec/mdct.c
parent2f97b12eaf8ada30b3884604d66dbdf51e727b67 (diff)
downloadffmpeg-7087ce08c84dd20404ba258096530cc547d25c15.tar.gz
Fixed-point FFT and MDCT
Diffstat (limited to 'libavcodec/mdct.c')
-rw-r--r--libavcodec/mdct.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index 9edb57760e..6f64534273 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -24,12 +24,19 @@
#include "libavutil/common.h"
#include "libavutil/mathematics.h"
#include "fft.h"
+#include "fft-internal.h"
/**
* @file
* MDCT/IMDCT transforms.
*/
+#if CONFIG_FFT_FLOAT
+# define RSCALE(x) (x)
+#else
+# define RSCALE(x) ((x) >> 1)
+#endif
+
/**
* init MDCT or IMDCT computation.
*/
@@ -70,8 +77,8 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
scale = sqrt(fabs(scale));
for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + theta) / n;
- s->tcos[i*tstep] = -cos(alpha) * scale;
- s->tsin[i*tstep] = -sin(alpha) * scale;
+ s->tcos[i*tstep] = FIX15(-cos(alpha) * scale);
+ s->tsin[i*tstep] = FIX15(-sin(alpha) * scale);
}
return 0;
fail:
@@ -79,17 +86,6 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
return -1;
}
-/* complex multiplication: p = a * b */
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
- FFTSample _are = (are);\
- FFTSample _aim = (aim);\
- FFTSample _bre = (bre);\
- FFTSample _bim = (bim);\
- (pre) = _are * _bre - _aim * _bim;\
- (pim) = _are * _bim + _aim * _bre;\
-}
-
/**
* Compute the middle half of the inverse MDCT of size N = 2^nbits,
* thus excluding the parts that can be derived by symmetry
@@ -161,7 +157,7 @@ void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
{
int i, j, n, n8, n4, n2, n3;
- FFTSample re, im;
+ FFTDouble re, im;
const uint16_t *revtab = s->revtab;
const FFTSample *tcos = s->tcos;
const FFTSample *tsin = s->tsin;
@@ -175,13 +171,13 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
/* pre rotation */
for(i=0;i<n8;i++) {
- re = -input[2*i+n3] - input[n3-1-2*i];
- im = -input[n4+2*i] + input[n4-1-2*i];
+ re = RSCALE(-input[2*i+n3] - input[n3-1-2*i]);
+ im = RSCALE(-input[n4+2*i] + input[n4-1-2*i]);
j = revtab[i];
CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
- re = input[2*i] - input[n2-1-2*i];
- im = -(input[n2+2*i] + input[n-1-2*i]);
+ re = RSCALE( input[2*i] - input[n2-1-2*i]);
+ im = RSCALE(-input[n2+2*i] - input[ n-1-2*i]);
j = revtab[n8 + i];
CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
}