mirror of
https://github.com/mborgerding/kissfft.git
synced 2025-06-04 01:28:23 -04:00
reduced calling parameters
negligible performane impact
This commit is contained in:
parent
0d44569b3b
commit
0d6d61cfce
30
kiss_fft.c
30
kiss_fft.c
@ -27,7 +27,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||||||
* }kiss_fft_cpx;
|
* }kiss_fft_cpx;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int nfft;
|
int nfft;
|
||||||
int inverse;
|
int inverse;
|
||||||
@ -65,38 +64,31 @@ kiss_fft_cpx cexp(double phase)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static kiss_fft_cpx cmul(kiss_fft_cpx a,kiss_fft_cpx b)
|
|
||||||
{
|
|
||||||
kiss_fft_cpx c;
|
|
||||||
C_MUL(c,a,b);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the heart of the fft
|
// the heart of the fft
|
||||||
static
|
static
|
||||||
void fft_work(
|
void fft_work(
|
||||||
kiss_fft_cpx * Fout,
|
kiss_fft_cpx * Fout,
|
||||||
const kiss_fft_cpx * f,
|
const kiss_fft_cpx * f,
|
||||||
int fstride,
|
int fstride,
|
||||||
int n,
|
int * factors,
|
||||||
int Norig,
|
const kiss_fft_state * st
|
||||||
int inverse,
|
|
||||||
kiss_fft_cpx * scratch,
|
|
||||||
kiss_fft_cpx * twiddles,
|
|
||||||
int * factors
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int m,p=0,q,q1,u,k;
|
int m,p=0,q,q1,u,k;
|
||||||
kiss_fft_cpx t;
|
kiss_fft_cpx t;
|
||||||
|
kiss_fft_cpx * scratch = st->scratch;
|
||||||
|
kiss_fft_cpx * twiddles = st->twiddles;
|
||||||
|
int Norig = st->nfft;
|
||||||
|
|
||||||
p=*factors++;
|
p=*factors++;
|
||||||
m=*factors++;//m = n/p;
|
m=*factors++;//m = n/p;
|
||||||
|
|
||||||
for (q=0;q<p;++q) {
|
for (q=0;q<p;++q) {
|
||||||
|
// TODO f+= fstride; instead of offset below
|
||||||
if (m==1)
|
if (m==1)
|
||||||
*(Fout + m*q) = *(f+q*fstride);
|
*(Fout + m*q) = *(f+q*fstride);
|
||||||
else
|
else
|
||||||
fft_work( Fout + m*q, f+q*fstride, fstride*p, m,Norig,inverse, scratch ,twiddles,factors);
|
fft_work( Fout + m*q, f+q*fstride, fstride*p,factors,st);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( u=0; u<m; ++u ) {
|
for ( u=0; u<m; ++u ) {
|
||||||
@ -159,12 +151,6 @@ void * kiss_fft_alloc(int nfft,int inverse_fft)
|
|||||||
st->scratch = (kiss_fft_cpx*)(st->tmpbuf + nfft);
|
st->scratch = (kiss_fft_cpx*)(st->tmpbuf + nfft);
|
||||||
st->factors = (int*)(st->scratch + nfft); // just after tmpbuf
|
st->factors = (int*)(st->scratch + nfft); // just after tmpbuf
|
||||||
|
|
||||||
/*
|
|
||||||
st->twiddles = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
|
||||||
st->tmpbuf = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
|
||||||
st->scratch = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
|
||||||
st->factors = (int*)malloc( sizeof(int)*nfft );
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (i=0;i<nfft;++i) {
|
for (i=0;i<nfft;++i) {
|
||||||
const double pi=3.14159265358979323846264338327;
|
const double pi=3.14159265358979323846264338327;
|
||||||
@ -200,5 +186,5 @@ void kiss_fft(const void * cfg,kiss_fft_cpx *f)
|
|||||||
|
|
||||||
n = st->nfft;
|
n = st->nfft;
|
||||||
memcpy(st->tmpbuf,f,sizeof(kiss_fft_cpx)*n);
|
memcpy(st->tmpbuf,f,sizeof(kiss_fft_cpx)*n);
|
||||||
fft_work( f, st->tmpbuf, 1, n,n, st->inverse, st->scratch ,st->twiddles,st->factors);
|
fft_work( f, st->tmpbuf, 1, st->factors,st );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user