diff options
Diffstat (limited to 'apps/codecs/libspeex/kiss_fft.c')
| -rw-r--r-- | apps/codecs/libspeex/kiss_fft.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/apps/codecs/libspeex/kiss_fft.c b/apps/codecs/libspeex/kiss_fft.c index f913a15..4ab31f2 100644 --- a/apps/codecs/libspeex/kiss_fft.c +++ b/apps/codecs/libspeex/kiss_fft.c @@ -19,7 +19,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #include "_kiss_fft_guts.h" #include "misc.h" -#include "math_approx.h" /* The guts header contains all the multiplication and addition macros that are defined for fixed or floating point complex numbers. It also delares the kf_ internal functions. @@ -55,8 +54,8 @@ static void kf_bfly2( kiss_fft_cpx *x=Fout; for (i=0;i<2*m;i++) { - x[i].r = SHR(x[i].r,1); - x[i].i = SHR(x[i].i,1); + x[i].r = SHR16(x[i].r,1); + x[i].i = SHR16(x[i].i,1); } } @@ -86,9 +85,9 @@ static void kf_bfly4( tw3 = tw2 = tw1 = st->twiddles; if (!st->inverse) { - int i; + unsigned int i; kiss_fft_cpx *x=Fout; - for (i=0;i<4*(signed int)m;i++) + for (i=0;i<4*m;i++) { x[i].r = PSHR16(x[i].r,2); x[i].i = PSHR16(x[i].i,2); @@ -339,8 +338,6 @@ static void kf_factor(int n,int * facbuf) { int p=4; - double floor_sqrt; - floor_sqrt = floor( sqrt((double)n) ); /*factor out powers of 4, powers of 2, then any remaining primes */ do { @@ -350,7 +347,7 @@ void kf_factor(int n,int * facbuf) case 2: p = 3; break; default: p += 2; break; } - if (p > floor_sqrt) + if (p>32000 || (spx_int32_t)p*(spx_int32_t)p > n) p = n; /* no more factors, skip to end */ } n /= p; @@ -358,7 +355,6 @@ void kf_factor(int n,int * facbuf) *facbuf++ = n; } while (n > 1); } - /* * * User-callable function to allocate all necessary storage space for the fft. @@ -383,15 +379,22 @@ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem int i; st->nfft=nfft; st->inverse = inverse_fft; - +#ifdef FIXED_POINT for (i=0;i<nfft;++i) { - const double pi=3.14159265358979323846264338327; - double phase = ( -2*pi /nfft ) * i; - if (st->inverse) - phase *= -1; - kf_cexp(st->twiddles+i, phase ); + spx_word32_t phase = i; + if (!st->inverse) + phase = -phase; + kf_cexp2(st->twiddles+i, DIV32(SHL32(phase,17),nfft)); } - +#else + for (i=0;i<nfft;++i) { + const double pi=3.14159265358979323846264338327; + double phase = ( -2*pi /nfft ) * i; + if (st->inverse) + phase *= -1; + kf_cexp(st->twiddles+i, phase ); + } +#endif kf_factor(nfft,st->factors); } return st; |