/******************************************************************** * * * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * * by the XIPHOPHORUS Company http://www.xiph.org/ * * * ******************************************************************** function: *unnormalized* fft transform last mod: $Id$ ********************************************************************/ /* FFT implementation from OggSquish, minus cosine transforms, * minus all but radix 2/4 case. In Vorbis we only need this * cut-down version. * * To do more than just power-of-two sized vectors, see the full * version I wrote for NetLib. * * Note that the packing is a little strange; rather than the FFT r/i * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the * FORTRAN version */ #ifdef HAVE_CONFIG_H #include "config-speex.h" #endif #include #include "smallft.h" #include "misc.h" static void drfti1(int n, float *wa, int *ifac){ static int ntryh[4] = { 4,2,3,5 }; static float tpi = 6.28318530717958648f; float arg,argh,argld,fi; int ntry=0,i,j=-1; int k1, l1, l2, ib; int ld, ii, ip, is, nq, nr; int ido, ipm, nfm1; int nl=n; int nf=0; L101: j++; if (j < 4) ntry=ntryh[j]; else ntry+=2; L104: nq=nl/ntry; nr=nl-ntry*nq; if (nr!=0) goto L101; nf++; ifac[nf+1]=ntry; nl=nq; if(ntry!=2)goto L107; if(nf==1)goto L107; for (i=1;i>1; ipp2=ip; idp2=ido; nbd=(ido-1)>>1; t0=l1*ido; t10=ip*ido; if(ido==1)goto L119; for(ik=0;ikl1){ for(j=1;j>1; ipp2=ip; ipph=(ip+1)>>1; if(idol1)goto L139; is= -ido-1; t1=0; for(j=1;jn==1)return; drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); } void spx_drft_backward(struct drft_lookup *l,float *data){ if (l->n==1)return; drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); } void spx_drft_init(struct drft_lookup *l,int n) { l->n=n; l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache)); l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache)); fdrffti(n, l->trigcache, l->splitcache); } void spx_drft_clear(struct drft_lookup *l) { if(l) { if(l->trigcache) speex_free(l->trigcache); if(l->splitcache) speex_free(l->splitcache); } }