X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=blobdiff_plain;f=libavcodec%2Fmdct.c;h=22320240dedc3568b8040ec3c77da52a42db2bf0;hp=87908d3d667a35dbb74ff0189682e28e1c7f1320;hb=16e52c86ba46e92d4a75e612d69ac97edb88a462;hpb=1429224b04cd10ef0d81c1c0d6eae82a5afad4d8 diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c index 87908d3d66..22320240de 100644 --- a/libavcodec/mdct.c +++ b/libavcodec/mdct.c @@ -19,38 +19,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include +#include "libavutil/common.h" #include "libavutil/mathematics.h" #include "fft.h" +#include "fft-internal.h" /** - * @file libavcodec/mdct.c + * @file * MDCT/IMDCT transforms. */ -// Generate a Kaiser-Bessel Derived Window. -#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation -av_cold void ff_kbd_window_init(float *window, float alpha, int n) -{ - int i, j; - double sum = 0.0, bessel, tmp; - double local_window[n]; - double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); - - for (i = 0; i < n; i++) { - tmp = i * (n - i) * alpha2; - bessel = 1.0; - for (j = BESSEL_I0_ITER; j > 0; j--) - bessel = bessel * tmp / (j * j) + 1; - sum += bessel; - local_window[i] = sum; - } - - sum++; - for (i = 0; i < n; i++) - window[i] = sqrt(local_window[i] / sum); -} - -#include "mdct_tablegen.h" +#if CONFIG_FFT_FLOAT +# define RSCALE(x) (x) +#else +# define RSCALE(x) ((x) >> 1) +#endif /** * init MDCT or IMDCT computation. @@ -66,7 +51,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) s->mdct_bits = nbits; s->mdct_size = n; n4 = n >> 2; - s->permutation = FF_MDCT_PERM_NONE; + s->mdct_permutation = FF_MDCT_PERM_NONE; if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) goto fail; @@ -75,7 +60,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) if (!s->tcos) goto fail; - switch (s->permutation) { + switch (s->mdct_permutation) { case FF_MDCT_PERM_NONE: s->tsin = s->tcos + n4; tstep = 1; @@ -92,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: @@ -101,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 @@ -141,7 +115,7 @@ void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) in1 += 2; in2 -= 2; } - ff_fft_calc(s, z); + s->fft_calc(s, z); /* post rotation + reordering */ for(k = 0; k < n8; k++) { @@ -183,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; @@ -197,18 +171,18 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) /* pre rotation */ for(i=0;ifft_calc(s, x); /* post rotation */ for(i=0;i