ref: 3fc0aada01594514377c4cb2b290395b76608ca3
parent: 732ea3881039f500ed5e852c1aa2377fd531a50b
author: Jean-Marc Valin <[email protected]>
date: Wed Aug 25 13:15:05 EDT 2010
FFT cleanup
--- a/libcelt/_kiss_fft_guts.h
+++ b/libcelt/_kiss_fft_guts.h
@@ -24,7 +24,7 @@
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
#include "kiss_fft.h"
-#define MAXFACTORS 32
+#define MAXFACTORS 8
/* e.g. an fft of length 128 has 4 factors
as far as kissfft is concerned
4*4*4*2
@@ -36,7 +36,7 @@
kiss_fft_scalar scale;
#endif
int shift;
- int factors[2*MAXFACTORS];
+ celt_int16 factors[2*MAXFACTORS];
celt_int16 *bitrev;
kiss_twiddle_cpx *twiddles;
};
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -644,7 +644,7 @@
return i;
}
-
+#ifndef STATIC_MODES
void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
int k;
/*_maxk==0 => there's nothing to do.*/
@@ -665,7 +665,7 @@
RESTORE_STACK;
}
}
-
+#endif /* STATIC_MODES */
void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
celt_uint32 i;
--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -108,6 +108,7 @@
fprintf(file, "#endif\n");
fprintf(file, "\n");
+ /* Pulse cache */
fprintf(file, "#ifndef DEF_PULSE_CACHE%d_%d\n", mode->Fs, mdctSize);
fprintf(file, "#define DEF_PULSE_CACHE%d_%d\n", mode->Fs, mdctSize);
fprintf (file, "static const celt_int16 cache_index%d_%d[%d] = {\n", mode->Fs, mdctSize, (mode->maxLM+2)*mode->nbEBands);
@@ -121,6 +122,24 @@
fprintf(file, "#endif\n");
fprintf(file, "\n");
+ /* FFTs */
+ /*
+ for (i=0;i<mode->mdct.maxshift;i++)
+ {
+ fprintf(file, "#ifndef FFT_BITREV%d_%d\n", mode->Fs, mdctSize>>i);
+ fprintf(file, "#define FFT_BITREV%d_%d\n", mode->Fs, mdctSize>>i);
+ fprintf (file, "static const celt_int16 fft_bitrev%d_%d[%d] = {\n",
+ mode->Fs, mdctSize/i, mode->mdct.kfft[i]->nfft);
+ for (j=0;j<mode->mdct.kfft[i]->nfft;j++)
+ fprintf (file, "%d, ", mode->mdct.kfft[i]->bitrev[j]);
+ fprintf (file, "};\n");
+
+ fprintf(file, "#endif\n");
+ fprintf(file, "\n");
+ }
+ */
+
+ /* Print the actual mode data */
fprintf(file, "static const CELTMode mode%d_%d_%d = {\n", mode->Fs, mdctSize, mode->overlap);
fprintf(file, "0x%x,\t/* marker */\n", 0xa110ca7e);
fprintf(file, INT32 ",\t/* Fs */\n", mode->Fs);
@@ -135,7 +154,7 @@
fprintf(file, "%d,\t/* nbAllocVectors */\n", mode->nbAllocVectors);
fprintf(file, "allocVectors%d_%d,\t/* allocVectors */\n", mode->Fs, mdctSize);
- fprintf(file, "{%d, 0, 0, 0},\t", 2*mode->shortMdctSize*mode->nbShortMdcts);
+ fprintf(file, "{%d, %d, 0, 0},\t", mode->mdct.n, mode->mdct.maxshift);
fprintf (file, "/* mdct */\n");
fprintf(file, "window%d,\t/* window */\n", mode->overlap);
--- a/libcelt/kiss_fft.c
+++ b/libcelt/kiss_fft.c
@@ -439,7 +439,7 @@
celt_int16 *f,
const size_t fstride,
int in_stride,
- int * factors,
+ celt_int16 * factors,
const kiss_fft_cfg st
)
{
@@ -472,7 +472,7 @@
const kiss_fft_cpx * f,
size_t fstride,
int in_stride,
- int * factors,
+ celt_int16 * factors,
const kiss_fft_cfg st,
int N,
int s2,
@@ -506,7 +506,7 @@
const kiss_fft_cpx * f,
size_t fstride,
int in_stride,
- int * factors,
+ celt_int16 * factors,
const kiss_fft_cfg st,
int N,
int s2,
@@ -539,7 +539,7 @@
p[i] * m[i] = m[i-1]
m0 = n */
static
-int kf_factor(int n,int * facbuf)
+int kf_factor(int n,celt_int16 * facbuf)
{
int p=4;
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -66,7 +66,6 @@
l->n = N;
N2 = N>>1;
N4 = N>>2;
- l->kfft = celt_alloc(sizeof(kiss_fft_cfg)*(maxshift+1));
l->maxshift = maxshift;
for (i=0;i<=maxshift;i++)
{
@@ -97,7 +96,6 @@
int i;
for (i=0;i<=l->maxshift;i++)
kiss_fft_free(l->kfft[i]);
- celt_free(l->kfft);
celt_free(l->trig);
}
--- a/libcelt/mdct.h
+++ b/libcelt/mdct.h
@@ -52,7 +52,7 @@
typedef struct {
int n;
int maxshift;
- kiss_fft_cfg *kfft;
+ kiss_fft_cfg kfft[4];
kiss_twiddle_scalar * restrict trig;
} mdct_lookup;