Commit 983f6387 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Wrapper for the TI dsplib FFT

parent fcb841aa
......@@ -32,6 +32,31 @@
#ifndef KFFT_SINGLE_H
#define KFFT_SINGLE_H
#ifdef ENABLE_TI_DSPLIB
#include "dsplib.h"
#define real16_fft_alloc(length) NULL
#define real16_fft_free(state)
#define BITREV(state, i) i
#define real16_fft_inplace(state, X, nx)\
(\
cfft_SCALE(X,nx/2),\
cbrev(X,X,nx/2),\
unpack(X,nx)\
)
#define real16_ifft(state, X, Y, nx) \
(\
unpacki(X, nx),\
cifft_NOSCALE(X,nx/2),\
cbrev(X,Y,nx/2)\
)
#else /* ENABLE_TI_DSPLIB */
#ifdef FIXED_POINT
#ifdef DOUBLE_PRECISION
......@@ -50,8 +75,10 @@
#define real16_fft_alloc(length) kiss_fftr_alloc_celt_single(length, 0, 0);
#define real16_fft_free(state) kiss_fft_free(state)
#define real16_fft_inplace(state, X) kiss_fftr_inplace(state,X)
#define real16_fft_inplace(state, X, nx) kiss_fftr_inplace(state,X)
#define BITREV(state, i) ((state)->substate->bitrev[i])
#define real16_ifft(state, X, Y) kiss_fftri(state,X, Y)
#define real16_ifft(state, X, Y, nx) kiss_fftri(state,X, Y)
#endif /* !ENABLE_TI_DSPLIB */
#endif /* KFFT_SINGLE_H */
......@@ -109,14 +109,12 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
VARDECL(celt_mask_t, curve);
int n2;
int L2;
const int *bitrev;
SAVE_STACK;
n2 = lag/2;
L2 = len/2;
ALLOC(X, lag, celt_word16_t);
ALLOC(curve, n2, celt_mask_t);
bitrev = fft->substate->bitrev;
for (i=0;i<lag;i++)
X[i] = 0;
/* Sum all channels of the current frame and copy into X in bit-reverse order */
......@@ -140,7 +138,7 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
normalise16(X, lag, 8192);
/*for (i=0;i<lag;i++) printf ("%d ", X[i]);printf ("\n");*/
/* Forward real FFT (in-place) */
real16_fft_inplace(fft, X);
real16_fft_inplace(fft, X, lag);
compute_masking(decay, X, curve, lag);
......@@ -159,7 +157,7 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
}
normalise16(Y, lag, 8192);
/* Forward real FFT (in-place) */
real16_fft_inplace(fft, Y);
real16_fft_inplace(fft, Y, lag);
/* Compute cross-spectrum using the inverse masking curve as weighting */
for (i=1;i<n2;i++)
......@@ -179,7 +177,7 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
/*for (i=0;i<lag;i++) printf ("%d ", X[i]);printf ("\n");*/
normalise16(X, lag, 50);
/* Inverse half-complex to real FFT gives us the correlation */
real16_ifft(fft, X, Y);
real16_ifft(fft, X, Y, lag);
/* The peak in the correlation gives us the pitch */
max_corr=-VERY_LARGE32;
......
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