33 int factors[2*MAXFACTORS];
50# define SAMPPROD int64_t
51#define SAMP_MAX INT32_MAX
52#define SAMP_MIN INT32_MIN
55# define SAMPPROD int32_t
56#define SAMP_MAX INT16_MAX
57#define SAMP_MIN INT16_MIN
60#if defined(CHECK_OVERFLOW)
61# define CHECK_OVERFLOW_OP(a,op,b) \
62 if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
63 fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
67# define smul(a,b) ( (SAMPPROD)(a)*(b) )
68# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
70# define S_MUL(a,b) sround( smul(a,b) )
72# define C_MUL(m,a,b) \
73 do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
74 (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
76# define DIVSCALAR(x,k) \
77 (x) = sround( smul( x, SAMP_MAX/k ) )
79# define C_FIXDIV(c,div) \
80 do { DIVSCALAR( (c).r , div); \
81 DIVSCALAR( (c).i , div); }while (0)
83# define C_MULBYSCALAR( c, s ) \
84 do{ (c).r = sround( smul( (c).r , s ) ) ;\
85 (c).i = sround( smul( (c).i , s ) ) ; }while(0)
89# define S_MUL(a,b) ( (a)*(b) )
91 do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
92 (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
93# define C_FIXDIV(c,div)
94# define C_MULBYSCALAR( c, s ) \
96 (c).i *= (s); }while(0)
99#ifndef CHECK_OVERFLOW_OP
100# define CHECK_OVERFLOW_OP(a,op,b)
103#define C_ADD( res, a,b)\
105 CHECK_OVERFLOW_OP((a).r,+,(b).r)\
106 CHECK_OVERFLOW_OP((a).i,+,(b).i)\
107 (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
109#define C_SUB( res, a,b)\
111 CHECK_OVERFLOW_OP((a).r,-,(b).r)\
112 CHECK_OVERFLOW_OP((a).i,-,(b).i)\
113 (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
115#define C_ADDTO( res , a)\
117 CHECK_OVERFLOW_OP((res).r,+,(a).r)\
118 CHECK_OVERFLOW_OP((res).i,+,(a).i)\
119 (res).r += (a).r; (res).i += (a).i;\
122#define C_SUBFROM( res , a)\
124 CHECK_OVERFLOW_OP((res).r,-,(a).r)\
125 CHECK_OVERFLOW_OP((res).i,-,(a).i)\
126 (res).r -= (a).r; (res).i -= (a).i; \
131# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase))
132# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase))
133# define HALF_OF(x) ((x)>>1)
134#elif defined(USE_SIMD)
135# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
136# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
137# define HALF_OF(x) ((x)*_mm_set1_ps(.5))
139# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
140# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
141# define HALF_OF(x) ((x)*.5f)
144#define kf_cexp(x,phase) \
146 (x)->r = KISS_FFT_COS(phase);\
147 (x)->i = KISS_FFT_SIN(phase);\
153 fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
156#ifdef KISS_FFT_USE_ALLOCA
162#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes)
163#define KISS_FFT_TMP_FREE(ptr)
165#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
166#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
The default complex <-> complex FFT.
Complex data type used by kissFFT.
Internal KissFFT structure.