Commit 9ced5d04 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Created an separate kiss_twiddle_cpx type to make it possible to use

different precision for twiddles and data.
parent 2c1d2f5b
......@@ -31,7 +31,7 @@ struct kiss_fft_state{
int nfft;
int factors[2*MAXFACTORS];
int *bitrev;
kiss_fft_cpx twiddles[1];
kiss_twiddle_cpx twiddles[1];
};
/*
......
......@@ -38,7 +38,7 @@ static void kf_bfly2(
)
{
kiss_fft_cpx * Fout2;
kiss_fft_cpx * tw1;
kiss_twiddle_cpx * tw1;
int i,j;
kiss_fft_cpx * Fout_beg = Fout;
for (i=0;i<N;i++)
......@@ -60,9 +60,9 @@ static void kf_bfly2(
Fout->r = PSHR32(ADD32(SHL32(EXTEND32(Fout->r), 14), tr), 15);
Fout->i = PSHR32(ADD32(SHL32(EXTEND32(Fout->i), 14), ti), 15);
#else
kiss_fft_cpx t;
Fout->r = SHR(Fout->r, 1);Fout->i = SHR(Fout->i, 1);
Fout2->r = SHR(Fout2->r, 1);Fout2->i = SHR(Fout2->i, 1);
kiss_fft_cpx t;
C_MUL (t, *Fout2 , *tw1);
tw1 += fstride;
C_SUB( *Fout2 , *Fout , t );
......@@ -84,7 +84,7 @@ static void ki_bfly2(
)
{
kiss_fft_cpx * Fout2;
kiss_fft_cpx * tw1;
kiss_twiddle_cpx * tw1;
kiss_fft_cpx t;
int i,j;
kiss_fft_cpx * Fout_beg = Fout;
......@@ -114,7 +114,7 @@ static void kf_bfly4(
int mm
)
{
kiss_fft_cpx *tw1,*tw2,*tw3;
kiss_twiddle_cpx *tw1,*tw2,*tw3;
kiss_fft_cpx scratch[6];
const size_t m2=2*m;
const size_t m3=3*m;
......@@ -163,7 +163,7 @@ static void ki_bfly4(
int mm
)
{
kiss_fft_cpx *tw1,*tw2,*tw3;
kiss_twiddle_cpx *tw1,*tw2,*tw3;
kiss_fft_cpx scratch[6];
const size_t m2=2*m;
const size_t m3=3*m;
......@@ -209,9 +209,9 @@ static void kf_bfly3(
{
size_t k=m;
const size_t m2 = 2*m;
kiss_fft_cpx *tw1,*tw2;
kiss_twiddle_cpx *tw1,*tw2;
kiss_fft_cpx scratch[5];
kiss_fft_cpx epi3;
kiss_twiddle_cpx epi3;
epi3 = st->twiddles[fstride*m];
tw1=tw2=st->twiddles;
......@@ -252,9 +252,9 @@ static void ki_bfly3(
{
size_t k=m;
const size_t m2 = 2*m;
kiss_fft_cpx *tw1,*tw2;
kiss_twiddle_cpx *tw1,*tw2;
kiss_fft_cpx scratch[5];
kiss_fft_cpx epi3;
kiss_twiddle_cpx epi3;
epi3 = st->twiddles[fstride*m];
tw1=tw2=st->twiddles;
......@@ -296,9 +296,9 @@ static void kf_bfly5(
kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
int u;
kiss_fft_cpx scratch[13];
kiss_fft_cpx * twiddles = st->twiddles;
kiss_fft_cpx *tw;
kiss_fft_cpx ya,yb;
kiss_twiddle_cpx * twiddles = st->twiddles;
kiss_twiddle_cpx *tw;
kiss_twiddle_cpx ya,yb;
ya = twiddles[fstride*m];
yb = twiddles[fstride*2*m];
......@@ -357,9 +357,9 @@ static void ki_bfly5(
kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
int u;
kiss_fft_cpx scratch[13];
kiss_fft_cpx * twiddles = st->twiddles;
kiss_fft_cpx *tw;
kiss_fft_cpx ya,yb;
kiss_twiddle_cpx * twiddles = st->twiddles;
kiss_twiddle_cpx *tw;
kiss_twiddle_cpx ya,yb;
ya = twiddles[fstride*m];
yb = twiddles[fstride*2*m];
......@@ -417,7 +417,7 @@ static void kf_bfly_generic(
)
{
int u,k,q1,q;
kiss_fft_cpx * twiddles = st->twiddles;
kiss_twiddle_cpx * twiddles = st->twiddles;
kiss_fft_cpx t;
kiss_fft_cpx scratchbuf[17];
int Norig = st->nfft;
......@@ -458,7 +458,7 @@ static void ki_bfly_generic(
)
{
int u,k,q1,q;
kiss_fft_cpx * twiddles = st->twiddles;
kiss_twiddle_cpx * twiddles = st->twiddles;
kiss_fft_cpx t;
kiss_fft_cpx scratchbuf[17];
int Norig = st->nfft;
......@@ -618,7 +618,7 @@ kiss_fft_cfg kiss_fft_alloc(int nfft,void * mem,size_t * lenmem )
{
kiss_fft_cfg st=NULL;
size_t memneeded = sizeof(struct kiss_fft_state)
+ sizeof(kiss_fft_cpx)*(nfft-1) + sizeof(int)*nfft; /* twiddle factors*/
+ sizeof(kiss_twiddle_cpx)*(nfft-1) + sizeof(int)*nfft; /* twiddle factors*/
if ( lenmem==NULL ) {
st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded );
......
......@@ -35,13 +35,16 @@ extern "C" {
#include "arch.h"
#ifdef DOUBLE_PRECISION
# define kiss_fft_scalar celt_int32_t
# define kiss_twiddle_scalar celt_int32_t
#else
# define kiss_fft_scalar celt_int16_t
# define kiss_twiddle_scalar celt_int16_t
#endif
#else
# ifndef kiss_fft_scalar
/* default is float */
# define kiss_fft_scalar float
# define kiss_twiddle_scalar float
# endif
#endif
......@@ -50,6 +53,11 @@ typedef struct {
kiss_fft_scalar i;
}kiss_fft_cpx;
typedef struct {
kiss_twiddle_scalar r;
kiss_twiddle_scalar i;
}kiss_twiddle_cpx;
typedef struct kiss_fft_state* kiss_fft_cfg;
/**
......
......@@ -27,7 +27,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
struct kiss_fftr_state{
kiss_fft_cfg substate;
kiss_fft_cpx * tmpbuf;
kiss_fft_cpx * super_twiddles;
kiss_twiddle_cpx * super_twiddles;
#ifdef USE_SIMD
long pad;
#endif
......@@ -46,7 +46,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,void * mem,size_t * lenmem)
nfft >>= 1;
kiss_fft_alloc (nfft, NULL, &subsize);
memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2);
memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft) + sizeof(kiss_twiddle_cpx)*nfft;
if (lenmem == NULL) {
st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
......@@ -60,7 +60,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,void * mem,size_t * lenmem)
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;
st->super_twiddles = (kiss_twiddle_cpx*)(st->tmpbuf + nfft);
kiss_fft_alloc(nfft, st->substate, &subsize);
#if defined (FIXED_POINT) && !defined(DOUBLE_PRECISION)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment