Skip to content
Snippets Groups Projects
Commit 6211c90d authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Split the radix functions into forward and backward versions, removed the

"inverse" flag from the state so it can be shared between the forward and
inverse transforms.
parent d7dfb008
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
struct kiss_fft_state{
int nfft;
int inverse;
int factors[2*MAXFACTORS];
int *bitrev;
kiss_fft_cpx twiddles[1];
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ typedef struct kiss_fft_state* kiss_fft_cfg;
* buffer size in *lenmem.
* */
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
kiss_fft_cfg kiss_fft_alloc(int nfft,void * mem,size_t * lenmem);
/*
* kiss_fft(cfg,in_out_buf)
......@@ -84,11 +84,13 @@ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
f[k].r and f[k].i
* */
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
void kiss_ifft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
/*
A more generic version of the above function. It reads its input from every Nth sample.
* */
void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
void kiss_ifft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
/* If kiss_fft_alloc allocated a buffer, it is one contiguous
buffer and can be simply free()d when no longer needed*/
......
......@@ -33,7 +33,7 @@ struct kiss_fftr_state{
#endif
};
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
kiss_fftr_cfg kiss_fftr_alloc(int nfft,void * mem,size_t * lenmem)
{
int i;
kiss_fftr_cfg st = NULL;
......@@ -45,7 +45,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme
}
nfft >>= 1;
kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize);
kiss_fft_alloc (nfft, NULL, &subsize);
memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2);
if (lenmem == NULL) {
......@@ -61,7 +61,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme
st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */
st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize);
st->super_twiddles = st->tmpbuf + nfft;
kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
kiss_fft_alloc(nfft, st->substate, &subsize);
#ifdef FIXED_POINT
for (i=0;i<nfft;++i) {
......@@ -85,10 +85,6 @@ void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar
kiss_fft_cpx f2k,tdc;
celt_word32_t f1kr, f1ki, twr, twi;
if ( st->substate->inverse) {
celt_fatal("kiss fft usage error: improper alloc\n");
}
ncfft = st->substate->nfft;
/*perform the parallel fft of two real signals packed in real,imag*/
......@@ -142,10 +138,6 @@ void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata,kiss_fft_scalar
/* input buffer timedata is stored row-wise */
int k, ncfft;
if (st->substate->inverse == 0) {
celt_fatal ("kiss fft usage error: improper alloc\n");
}
ncfft = st->substate->nfft;
st->tmpbuf[0].r = freqdata[0] + freqdata[1];
......@@ -169,5 +161,5 @@ void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata,kiss_fft_scalar
st->tmpbuf[ncfft - k].i *= -1;
#endif
}
kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
kiss_ifft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
}
......@@ -18,7 +18,7 @@ extern "C" {
typedef struct kiss_fftr_state *kiss_fftr_cfg;
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
kiss_fftr_cfg kiss_fftr_alloc(int nfft,void * mem, size_t * lenmem);
/*
nfft must be even
......
......@@ -54,8 +54,7 @@ void mdct_init(mdct_lookup *l,int N)
l->n = N;
N2 = N/2;
N4 = N/4;
l->kfft = kiss_fft_alloc(N4, 0, NULL, NULL);
l->ikfft = kiss_fft_alloc(N4, 1, NULL, NULL);
l->kfft = kiss_fft_alloc(N4, NULL, NULL);
l->trig = celt_alloc(N2*sizeof(float));
/* We have enough points that sine isn't necessary */
for (i=0;i<N2;i++)
......@@ -66,7 +65,6 @@ void mdct_init(mdct_lookup *l,int N)
void mdct_clear(mdct_lookup *l)
{
kiss_fft_free(l->kfft);
kiss_fft_free(l->ikfft);
celt_free(l->trig);
}
......@@ -131,7 +129,7 @@ void mdct_backward(mdct_lookup *l, float *in, float *out)
}
/* Inverse N/4 complex FFT. This one should *not* downscale even in fixed-point */
kiss_fft(l->ikfft, (const kiss_fft_cpx *)out, (kiss_fft_cpx *)f);
kiss_ifft(l->kfft, (const kiss_fft_cpx *)out, (kiss_fft_cpx *)f);
/* Post-rotate */
for(i=0;i<N4;i++)
......
......@@ -47,7 +47,6 @@
typedef struct {
int n;
kiss_fft_cfg kfft;
kiss_fft_cfg ikfft;
float *trig;
float scale;
} mdct_lookup;
......
......@@ -42,7 +42,7 @@ void test1d(int nfft,int isinverse)
kiss_fft_cpx * in = (kiss_fft_cpx*)malloc(buflen);
kiss_fft_cpx * out= (kiss_fft_cpx*)malloc(buflen);
kiss_fft_cfg cfg = kiss_fft_alloc(nfft,isinverse,0,0);
kiss_fft_cfg cfg = kiss_fft_alloc(nfft,0,0);
int k;
for (k=0;k<nfft;++k) {
......@@ -50,7 +50,10 @@ void test1d(int nfft,int isinverse)
in[k].i = (rand() % 65536) - 32768;
}
kiss_fft(cfg,in,out);
if (isinverse)
kiss_ifft(cfg,in,out);
else
kiss_fft(cfg,in,out);
check(in,out,nfft,isinverse);
......
......@@ -96,8 +96,8 @@ int main(void)
cin[i].i = zero;
}
kiss_fft_state = kiss_fft_alloc(NFFT,0,0,0);
kiss_fftr_state = kiss_fftr_alloc(NFFT,0,0,0);
kiss_fft_state = kiss_fft_alloc(NFFT,0,0);
kiss_fftr_state = kiss_fftr_alloc(NFFT,0,0);
kiss_fft(kiss_fft_state,cin,cout);
kiss_fftr(kiss_fftr_state,rin,sout);
......@@ -118,12 +118,6 @@ int main(void)
printf("%d complex ffts took %gs, real took %gs\n",NUMFFTS,tfft,trfft);
free(kiss_fft_state);
free(kiss_fftr_state);
kiss_fft_state = kiss_fft_alloc(NFFT,1,0,0);
kiss_fftr_state = kiss_fftr_alloc(NFFT,1,0,0);
memset(cin,0,sizeof(cin));
#if 1
cin[0].r = rand_scalar();
......@@ -153,7 +147,7 @@ int main(void)
fin[2*i+1] = cin[i].i;
}
kiss_fft(kiss_fft_state,cin,cout);
kiss_ifft(kiss_fft_state,cin,cout);
kiss_fftri(kiss_fftr_state,fin,rout);
/*
printf(" results from inverse kiss_fft : (%f,%f), (%f,%f), (%f,%f), (%f,%f), (%f,%f) ...\n "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment