diff --git a/_kiss_fft_guts.h b/_kiss_fft_guts.h index 2018b65..147f398 100644 --- a/_kiss_fft_guts.h +++ b/_kiss_fft_guts.h @@ -37,17 +37,22 @@ struct kiss_fft_state{ C_ADDTO( res , a) : res += a * */ #ifdef FIXED_POINT -# define S_MUL(a,b) ( ( (a)*(b) + (1<<14) )>>15 ) + +# define smul(a,b) ( (long)(a)*(b) ) +# define sround( x ) (short)( ( (x) + (1<<14) ) >>15 ) + +# define S_MUL(a,b) sround( smul(a,b) ) + # define C_MUL(m,a,b) \ - do{ (m).r = ( ( (a).r*(b).r - (a).i*(b).i) + (1<<14) ) >> 15;\ - (m).i = ( ( (a).r*(b).i + (a).i*(b).r) + (1<<14) ) >> 15;\ - }while(0) + do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ + (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) + # define C_FIXDIV(c,div) \ do{ (c).r /= div; (c).i /=div; }while(0) # define C_MULBYSCALAR( c, s ) \ - do{ (c).r = ( ( (c).r*(s) ) + (1<<14) ) >> 15;\ - (c).i = ( ( (c).i*(s) ) + (1<<14) ) >> 15; }while(0) + do{ (c).r = sround( smul( (c).r , s ) ) ;\ + (c).i = sround( smul( (c).i , s ) ) ; }while(0) #else /* not FIXED_POINT*/