shithub: opus

Download patch

ref: 983f6387e05311b59b60467353d0794e1a5be2f3
parent: fcb841aa0bd187774f882268e567894a0eca9c11
author: Jean-Marc Valin <[email protected]>
date: Thu Mar 20 19:17:18 EDT 2008

Wrapper for the TI dsplib FFT

--- a/libcelt/kfft_single.h
+++ b/libcelt/kfft_single.h
@@ -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 */
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -109,7 +109,6 @@
    VARDECL(celt_mask_t, curve);
    int n2;
    int L2;
-   const int *bitrev;
    SAVE_STACK;
    n2 = lag/2;
    L2 = len/2;
@@ -116,7 +115,6 @@
    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 @@
    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 @@
    }
    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 @@
    /*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;