[xiph-commits] r12055 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Tue Nov 7 07:02:57 PST 2006
Author: jm
Date: 2006-11-07 07:02:52 -0800 (Tue, 07 Nov 2006)
New Revision: 12055
Modified:
trunk/speex/libspeex/_kiss_fft_guts.h
trunk/speex/libspeex/kiss_fft.c
trunk/speex/libspeex/kiss_fftr.c
Log:
kissfft initialisation no longer uses any float operation. I think
the whole echo canceller+preprocessor are 100% float-free.
Modified: trunk/speex/libspeex/_kiss_fft_guts.h
===================================================================
--- trunk/speex/libspeex/_kiss_fft_guts.h 2006-11-07 13:25:33 UTC (rev 12054)
+++ trunk/speex/libspeex/_kiss_fft_guts.h 2006-11-07 15:02:52 UTC (rev 12055)
@@ -20,6 +20,7 @@
and defines
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
#include "kiss_fft.h"
+#include "math_approx.h"
#define MAXFACTORS 32
/* e.g. an fft of length 128 has 4 factors
@@ -140,6 +141,11 @@
(x)->r = KISS_FFT_COS(phase);\
(x)->i = KISS_FFT_SIN(phase);\
}while(0)
+#define kf_cexp2(x,phase) \
+ do{ \
+ (x)->r = spx_cos_norm((phase));\
+ (x)->i = spx_cos_norm((phase)-32768);\
+}while(0)
/* a debugging function */
Modified: trunk/speex/libspeex/kiss_fft.c
===================================================================
--- trunk/speex/libspeex/kiss_fft.c 2006-11-07 13:25:33 UTC (rev 12054)
+++ trunk/speex/libspeex/kiss_fft.c 2006-11-07 15:02:52 UTC (rev 12055)
@@ -338,8 +338,6 @@
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 {
@@ -349,7 +347,7 @@
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;
@@ -357,7 +355,6 @@
*facbuf++ = n;
} while (n > 1);
}
-
/*
*
* User-callable function to allocate all necessary storage space for the fft.
@@ -382,15 +379,22 @@
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;
Modified: trunk/speex/libspeex/kiss_fftr.c
===================================================================
--- trunk/speex/libspeex/kiss_fftr.c 2006-11-07 13:25:33 UTC (rev 12054)
+++ trunk/speex/libspeex/kiss_fftr.c 2006-11-07 15:02:52 UTC (rev 12055)
@@ -58,13 +58,22 @@
st->super_twiddles = st->tmpbuf + nfft;
kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
- for (i = 0; i < nfft; ++i) {
- double phase =
- -3.14159265358979323846264338327 * ((double) i / nfft + .5);
- if (inverse_fft)
- phase *= -1;
- kf_cexp (st->super_twiddles+i,phase);
+#ifdef FIXED_POINT
+ for (i=0;i<nfft;++i) {
+ spx_word32_t phase = i+(nfft>>1);
+ if (!inverse_fft)
+ phase = -phase;
+ kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft));
}
+#else
+ for (i=0;i<nfft;++i) {
+ const double pi=3.14159265358979323846264338327;
+ double phase = pi*(((double)i) /nfft + .5);
+ if (!inverse_fft)
+ phase = -phase;
+ kf_cexp(st->super_twiddles+i, phase );
+ }
+#endif
return st;
}
More information about the commits
mailing list