From 18e5e8e3603c4d8c838c0a97a0b8588aa737b15e Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Fri, 10 Oct 2003 02:04:42 +0000 Subject: [PATCH] failed attempt -- DOES NOT WORK! --- kiss_fft.c | 99 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 23 deletions(-) diff --git a/kiss_fft.c b/kiss_fft.c index 555fab1..0649865 100644 --- a/kiss_fft.c +++ b/kiss_fft.c @@ -15,6 +15,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #include #include #include +#include #include "kiss_fft.h" /* * kiss_fft.h @@ -32,16 +33,21 @@ typedef struct { kiss_fft_cpx * twiddle; }kiss_fft_stage; +const double pi=3.14159265358979323846264338327; #define MAX_STAGES 20 typedef struct { + int nfft; int nstages; int allocsize; kiss_fft_stage stages[MAX_STAGES]; int * unscramble_indices; + kiss_fft_cpx * buf1; }kiss_fft_state; + + #ifdef FIXED_POINT # define TWIDDLE_RANGE ( (1<nr; - const kiss_fft_cpx * twid = stage->twiddle; - for ( n = 0 ; n < stage->nr ; ++n ) - { - C_ADD( csum, *f1 , *f2 ); - C_SUB( cdiff, *f1 , *f2 ); - *f1++ = csum; - C_MUL(*f2, cdiff, *twid); - ++f2; - ++twid; + int nx,ny,Nx,Ny; + kiss_fft_cpx twid; + double inc1 = -2*pi/(stage->radix * stage->nr); + Ny = stage->nr; + Nx = stage->radix; + + for (ny=0;nynr ; ++n ) + { + C_ADD( csum, *f1 , *f2 ); + C_SUB( cdiff, *f1 , *f2 ); + C_MUL(*f2, cdiff, *twid); + *f1++ = csum; + ++f2; + ++twid; + } +*/ } if ( nstages == 1 ) return; - - for (n=0;nradix;++n) - fft_work( f + n * stage->nr ,stage+1,nstages-1); + + for (n=0;nradix;++n) { + int offset = n * stage->nr; + fft_work( h2 + offset , h + offset ,stage+1,nstages-1); + } } + static kiss_fft_state * decompose( kiss_fft_state * st, int * pnfft,int radix,int inverse_fft) { @@ -213,12 +261,14 @@ void * kiss_fft_alloc(int nfft,int inverse_fft) kiss_fft_state * st=NULL; int tmp; int i; - int allocsize=sizeof(kiss_fft_state) + nfft*sizeof(int); + int allocsize=sizeof(kiss_fft_state) + nfft*( sizeof(int) + sizeof(kiss_fft_cpx) ); st = ( kiss_fft_state *)malloc( allocsize ); + st->nfft=nfft; st->nstages=0; st->allocsize=allocsize; st->unscramble_indices = (int*)(st+1);// just past end of buffer + st->buf1 = (kiss_fft_cpx*)( st->unscramble_indices + nfft); for (i=0;iunscramble_indices[i] = i; @@ -242,5 +292,8 @@ void * kiss_fft_alloc(int nfft,int inverse_fft) void kiss_fft(const void * cfg,kiss_fft_cpx *f) { const kiss_fft_state * st = cfg; - fft_work( f, st->stages , st->nstages ); + fft_work( f,st->buf1, st->stages , st->nstages ); + if (st->nstages&1) { + memcpy( st->buf1 , f,sizeof(kiss_fft_cpx) * st->nfft ); + } }