ref: 9ced5d042d1f4167e2bcf181845fad6b0c4aceb4
parent: 2c1d2f5bcc17d1442bcde442cbdfc6808e748603
author: Jean-Marc Valin <[email protected]>
date: Sun Feb 24 08:46:30 EST 2008
Created an separate kiss_twiddle_cpx type to make it possible to use different precision for twiddles and data.
--- a/libcelt/_kiss_fft_guts.h
+++ b/libcelt/_kiss_fft_guts.h
@@ -31,7 +31,7 @@
int nfft;
int factors[2*MAXFACTORS];
int *bitrev;
- kiss_fft_cpx twiddles[1];
+ kiss_twiddle_cpx twiddles[1];
};
/*
--- a/libcelt/kiss_fft.c
+++ b/libcelt/kiss_fft.c
@@ -38,7 +38,7 @@
)
{
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 @@
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 @@
)
{
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
)
{
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 @@
)
{
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 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 );
--- a/libcelt/kiss_fft.h
+++ b/libcelt/kiss_fft.h
@@ -35,13 +35,16 @@
#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
@@ -49,6 +52,11 @@
kiss_fft_scalar r;
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;
--- a/libcelt/kiss_fftr.c
+++ b/libcelt/kiss_fftr.c
@@ -27,7 +27,7 @@
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 @@
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 @@
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)