static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) { int i; #ifdef FIXED_POINT for (i=0;i<nfft;++i) { opus_val32 phase = -i; kf_cexp2(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; kf_cexp(twiddles+i, phase ); } #endif }
/* * * User-callable function to allocate all necessary storage space for the fft. * * The return value is a contiguous block of memory, allocated with malloc. As such, * It can be freed with free(), rather than a kiss_fft-specific function. * */ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) { kiss_fft_cfg st=NULL; size_t memneeded = sizeof(struct kiss_fft_state) + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ if ( lenmem==NULL ) { st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); }else{ if (mem != NULL && *lenmem >= memneeded) st = (kiss_fft_cfg)mem; *lenmem = memneeded; } if (st) { int i; st->nfft=nfft; st->inverse = inverse_fft; #ifdef MS_FIXED_POINT for (i=0;i<nfft;++i) { ms_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; }