shithub: opus

Download patch

ref: 5d937c0223451943d6630d15087eb5e16d16b8d7
parent: 40603b2f03c43b416263a41e5cb92268a03b96a3
author: Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
date: Wed Aug 25 22:04:03 EDT 2010

Disabling mdct and fft init code with static modes

--- a/libcelt/kiss_fft.c
+++ b/libcelt/kiss_fft.c
@@ -433,40 +433,6 @@
 
 #endif
 
-static
-void compute_bitrev_table(
-         int Fout,
-         celt_int16 *f,
-         const size_t fstride,
-         int in_stride,
-         celt_int16 * factors,
-         const kiss_fft_state *st
-            )
-{
-   const int p=*factors++; /* the radix  */
-   const int m=*factors++; /* stage's fft length/p */
-   
-    /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/
-   if (m==1)
-   {
-      int j;
-      for (j=0;j<p;j++)
-      {
-         *f = Fout+j;
-         f += fstride*in_stride;
-      }
-   } else {
-      int j;
-      for (j=0;j<p;j++)
-      {
-         compute_bitrev_table( Fout , f, fstride*p, in_stride, factors,st);
-         f += fstride*in_stride;
-         Fout += m;
-      }
-   }
-}
-
-
 static void kf_work(
         kiss_fft_cpx * Fout,
         const kiss_fft_cpx * f,
@@ -534,6 +500,43 @@
    }    
 }
 
+
+#ifndef STATIC_MODES
+
+static
+void compute_bitrev_table(
+         int Fout,
+         celt_int16 *f,
+         const size_t fstride,
+         int in_stride,
+         celt_int16 * factors,
+         const kiss_fft_state *st
+            )
+{
+   const int p=*factors++; /* the radix  */
+   const int m=*factors++; /* stage's fft length/p */
+
+    /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/
+   if (m==1)
+   {
+      int j;
+      for (j=0;j<p;j++)
+      {
+         *f = Fout+j;
+         f += fstride*in_stride;
+      }
+   } else {
+      int j;
+      for (j=0;j<p;j++)
+      {
+         compute_bitrev_table( Fout , f, fstride*p, in_stride, factors,st);
+         f += fstride*in_stride;
+         Fout += m;
+      }
+   }
+}
+
+
 /*  facbuf is populated by p1,m1,p2,m2, ...
     where 
     p[i] * m[i] = m[i-1]
@@ -643,7 +646,16 @@
    return kiss_fft_alloc_twiddles(nfft, mem, lenmem, NULL);
 }
 
-    
+void kiss_fft_free(const kiss_fft_state *cfg)
+{
+   celt_free((celt_int16*)cfg->bitrev);
+   if (cfg->shift < 0)
+      celt_free((kiss_twiddle_cpx*)cfg->twiddles);
+   celt_free((kiss_fft_state*)cfg);
+}
+
+#endif /* STATIC_MODES */
+
 static void kiss_fft_stride(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride)
 {
     if (fin == fout) 
@@ -688,10 +700,3 @@
    kiss_ifft_stride(cfg,fin,fout,1);
 }
 
-void kiss_fft_free(const kiss_fft_state *cfg)
-{
-   celt_free((celt_int16*)cfg->bitrev);
-   if (cfg->shift < 0)
-      celt_free((kiss_twiddle_cpx*)cfg->twiddles);
-   celt_free((kiss_fft_state*)cfg);
-}
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -43,9 +43,11 @@
    and scaling in many places. 
 */
 
+#ifndef SKIP_CONFIG_H
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#endif
 
 #include "mdct.h"
 #include "kiss_fft.h"
@@ -59,6 +61,8 @@
 #define M_PI 3.141592653
 #endif
 
+#ifndef STATIC_MODES
+
 void clt_mdct_init(mdct_lookup *l,int N, int maxshift)
 {
    int i;
@@ -99,6 +103,8 @@
       kiss_fft_free(l->kfft[i]);
    celt_free((kiss_twiddle_scalar*)l->trig);
 }
+
+#endif /* STATIC_MODES */
 
 void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 *window, int overlap, int shift)
 {
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -81,6 +81,8 @@
    return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start);
 }
 
+#ifndef STATIC_MODES
+
 celt_int16 *quant_prob_alloc(const CELTMode *m)
 {
    int i;
@@ -105,6 +107,7 @@
 {
    celt_free((celt_int16*)freq);
 }
+#endif
 
 static void quant_coarse_energy_impl(const CELTMode *m, int start, int end,
       const celt_word16 *eBands, celt_word16 *oldEBands, int budget,
--- a/tests/dft-test.c
+++ b/tests/dft-test.c
@@ -2,6 +2,12 @@
 #include "config.h"
 #endif
 
+#define SKIP_CONFIG_H
+
+#ifdef STATIC_MODES
+#undef STATIC_MODES
+#endif
+
 #include <stdio.h>
 #include "kiss_fft.h"
 
--- a/tests/mdct-test.c
+++ b/tests/mdct-test.c
@@ -2,6 +2,12 @@
 #include "config.h"
 #endif
 
+#define SKIP_CONFIG_H
+
+#ifdef STATIC_MODES
+#undef STATIC_MODES
+#endif
+
 #include <stdio.h>
 #include "mdct.h"
 #define CELT_C