From e8b6830f538e41a5a0db076bd183db43e3b99b3e Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Sun, 24 Feb 2008 22:06:04 +1100 Subject: [PATCH] minor tweak to FFT --- libcelt/_kiss_fft_guts.h | 11 +++++++++-- tests/dft-test.c | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libcelt/_kiss_fft_guts.h b/libcelt/_kiss_fft_guts.h index e7c7cfd6..57695cc0 100644 --- a/libcelt/_kiss_fft_guts.h +++ b/libcelt/_kiss_fft_guts.h @@ -103,6 +103,13 @@ struct kiss_fft_state{ do{ (c).r = S_MUL( (c).r , s ) ;\ (c).i = S_MUL( (c).i , s ) ; }while(0) +# define DIVSCALAR(x,k) \ + (x) = S_MUL( x, (TWID_MAX-((k)>>1))/(k)+1 ) + +# define C_FIXDIV(c,div) \ + do { DIVSCALAR( (c).r , div); \ + DIVSCALAR( (c).i , div); }while (0) + #else /* MIXED_PRECISION */ # define sround4( x ) (kiss_fft_scalar)( ( (x) + ((SAMPPROD)1<<(FRACBITS-1)) ) >> (FRACBITS+2) ) @@ -123,8 +130,6 @@ struct kiss_fft_state{ do{ (c).r = sround( smul( (c).r , s ) ) ;\ (c).i = sround( smul( (c).i , s ) ) ; }while(0) -#endif /* !MIXED_PRECISION */ - # define DIVSCALAR(x,k) \ (x) = sround( smul( x, SAMP_MAX/k ) ) @@ -132,6 +137,8 @@ struct kiss_fft_state{ do { DIVSCALAR( (c).r , div); \ DIVSCALAR( (c).i , div); }while (0) +#endif /* !MIXED_PRECISION */ + #define L1 32767 diff --git a/tests/dft-test.c b/tests/dft-test.c index 8765767e..b546d89b 100644 --- a/tests/dft-test.c +++ b/tests/dft-test.c @@ -66,8 +66,8 @@ void test1d(int nfft,int isinverse) #ifdef DOUBLE_PRECISION for (k=0;k