From a09cf1dc954bca593406a3a1e46d54d040230443 Mon Sep 17 00:00:00 2001 From: Christian Daniel Date: Fri, 22 Jun 2012 00:06:05 +0200 Subject: [PATCH] KissFFT: not fully legal speed optimisation (doesn't take care of inf/nan) --- dsp/kissfft.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dsp/kissfft.h b/dsp/kissfft.h index b5b5b22..82c0260 100644 --- a/dsp/kissfft.h +++ b/dsp/kissfft.h @@ -176,7 +176,8 @@ private: } void C_MUL(cpx_type& c, const cpx_type& a, const cpx_type& b) { - c = a * b; + //c = a * b; + c = cpx_type(a.real() * b.real() - a.imag() * b.imag(), a.real() * b.imag() + a.imag() * b.real()); } void C_SUB(cpx_type& c, const cpx_type& a, const cpx_type& b) { @@ -205,7 +206,9 @@ private: void kf_bfly2(cpx_type* Fout, const size_t fstride, int m) { for(int k = 0; k < m; ++k) { - cpx_type t = Fout[m + k] * _traits.twiddle(k * fstride); + //cpx_type t = Fout[m + k] * _traits.twiddle(k * fstride); + cpx_type t; + C_MUL(t, Fout[m + k], _traits.twiddle(k * fstride)); Fout[m + k] = Fout[k] - t; Fout[k] += t; } @@ -216,9 +219,10 @@ private: cpx_type scratch[7]; int negative_if_inverse = _inverse * -2 + 1; for(size_t k = 0; k < m; ++k) { - scratch[0] = Fout[k + m] * _traits.twiddle(k * fstride); - scratch[1] = Fout[k + 2 * m] * _traits.twiddle(k * fstride * 2); - scratch[2] = Fout[k + 3 * m] * _traits.twiddle(k * fstride * 3); + //scratch[0] = Fout[k + m] * _traits.twiddle(k * fstride); + C_MUL(scratch[0], Fout[k + m], _traits.twiddle(k * fstride)); + C_MUL(scratch[1], Fout[k + 2 * m], _traits.twiddle(k * fstride * 2)); + C_MUL(scratch[2], Fout[k + 3 * m], _traits.twiddle(k * fstride * 3)); scratch[5] = Fout[k] - scratch[1]; Fout[k] += scratch[1];