re-added radix 3 butterfly

This commit is contained in:
Mark Borgerding
2003-10-30 02:02:29 +00:00
parent ca4c74e07c
commit d4f87befda
4 changed files with 81 additions and 25 deletions

View File

@ -59,6 +59,8 @@ typedef struct {
# define C_FIXDIV(c,div) /* NOOP */
#endif
#define C_ADD( res, a,b)\
do { (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; }while(0)
#define C_SUB( res, a,b)\
do { (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; }while(0)
#define C_ADDTO( res , a)\
@ -162,6 +164,59 @@ void bfly4(
}while(--m);
}
void bfly3(
kiss_fft_cpx * Fout,
int fstride,
const kiss_fft_state * st,
int m
)
{
kiss_fft_cpx *Fout0,*Fout1,*Fout2;
kiss_fft_cpx *tw1,*tw2;
kiss_fft_cpx * scratch = st->scratch;
kiss_fft_cpx * twiddles = st->twiddles;
kiss_fft_cpx epi3;
epi3 = twiddles[fstride*m];
Fout0=Fout;
Fout1=Fout0+m;
Fout2=Fout0+2*m;
tw1=tw2=twiddles;
do{
C_FIXDIV(*Fout,3); C_FIXDIV(*Fout1,3); C_FIXDIV(*Fout2,3);
scratch[0] = *Fout0;
C_MUL(scratch[1],*Fout1 , *tw1);
C_MUL(scratch[2],*Fout2 , *tw2);
tw1 += fstride;
tw2 += fstride*2;
C_ADD(scratch[4],scratch[1],scratch[2]);
C_ADD(*Fout0,scratch[0],scratch[4]);
scratch[4].r /= -2;
scratch[4].i /= -2;
C_SUB(scratch[5],scratch[1],scratch[2]);
scratch[5].r *= epi3.i;
scratch[5].i *= epi3.i;
scratch[3].r = scratch[4].r - scratch[5].i ;
scratch[3].i = scratch[4].i + scratch[5].r ;
C_ADD( *Fout1, scratch[0] , scratch[3] );
scratch[3].r = scratch[4].r + scratch[5].i;
scratch[3].i = scratch[4].i - scratch[5].r;
C_ADD( *Fout2, scratch[0] , scratch[3] );
++Fout0;++Fout1;++Fout2;
}while(--m);
}
/* perform the butterfly for one stage of a mixed radix FFT */
void bfly_generic(
kiss_fft_cpx * Fout,
@ -221,8 +276,11 @@ void fft_work(
}
switch (p) {
case 4: bfly4(Fout,fstride,st,m); break;
case 2: bfly2(Fout,fstride,st,m); break;
#if 1
case 3: bfly3(Fout,fstride,st,m); break;
#endif
case 4: bfly4(Fout,fstride,st,m); break;
default: bfly_generic(Fout,fstride,st,m,p); break;
}
}