From 7087ce08c84dd20404ba258096530cc547d25c15 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 26 Mar 2011 15:20:30 +0000 Subject: Fixed-point FFT and MDCT --- libavcodec/mdct.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'libavcodec/mdct.c') 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;itcos[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