[xiph-cvs] cvs commit: speex/libspeex mdf.c preprocess.c smallft.c smallft.h speex_echo.h speex_preprocess.h

Jean-Marc Valin jm at xiph.org
Tue Sep 16 11:35:47 PDT 2003



jm          03/09/16 14:35:45

  Modified:    libspeex mdf.c preprocess.c smallft.c smallft.h speex_echo.h
                        speex_preprocess.h
  Log:
  smallft.h doesn't need to be included from the .h files anymore

Revision  Changes    Path
1.9       +12 -10    speex/libspeex/mdf.c

Index: mdf.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/mdf.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mdf.c	22 Aug 2003 20:17:56 -0000	1.8
+++ mdf.c	16 Sep 2003 18:35:45 -0000	1.9
@@ -55,7 +55,8 @@
    st->cancel_count=0;
    st->adapt_rate = .01;
 
-   drft_init(&st->fft_lookup, N);
+   st->fft_lookup = speex_alloc(sizeof(struct drft_lookup));
+   drft_init(st->fft_lookup, N);
    
    st->x = (float*)speex_alloc(N*sizeof(float));
    st->d = (float*)speex_alloc(N*sizeof(float));
@@ -82,7 +83,8 @@
 /** Destroys an echo canceller state */
 void speex_echo_state_destroy(SpeexEchoState *st)
 {
-   drft_clear(&st->fft_lookup);
+   drft_clear(st->fft_lookup);
+   speex_free(st->fft_lookup);
    speex_free(st->x);
    speex_free(st->d);
    speex_free(st->y);
@@ -133,7 +135,7 @@
       st->X[(M-1)*N+i]=st->x[i];
 
    /* Convert x (echo input) to frequency domain */
-   drft_forward(&st->fft_lookup, &st->X[(M-1)*N]);
+   drft_forward(st->fft_lookup, &st->X[(M-1)*N]);
 
 
    /* Compute filter response Y */
@@ -157,7 +159,7 @@
    /* Transform d (reference signal) to frequency domain */
    for (i=0;i<N;i++)
       st->D[i]=st->d[i];
-   drft_forward(&st->fft_lookup, st->D);
+   drft_forward(st->fft_lookup, st->D);
 
    /* Evaluate "spectral distance" between Y and D t odetect crosstalk */
    for (i=1;i<N-1;i+=2)
@@ -187,7 +189,7 @@
       st->y[i] = st->Y[i];
    
    /* Convery Y (filter response) to time domain */
-   drft_backward(&st->fft_lookup, st->y);
+   drft_backward(st->fft_lookup, st->y);
    for (i=0;i<N;i++)
       st->y[i] *= scale;
 
@@ -200,7 +202,7 @@
    }
 
    /* Convert error to frequency domain */
-   drft_forward(&st->fft_lookup, st->E);
+   drft_forward(st->fft_lookup, st->E);
 
    for (i=0;i<st->frame_size;i++)
    {
@@ -296,12 +298,12 @@
       
 
 #if 0 /* Set to 1 to enable MDF instead of AUMDF (and comment out weight constraint below) */
-      drft_backward(&st->fft_lookup, st->PHI);
+      drft_backward(st->fft_lookup, st->PHI);
       for (i=0;i<N;i++)
          st->PHI[i]*=scale;
       for (i=st->frame_size;i<N;i++)
         st->PHI[i]=0;
-      drft_forward(&st->fft_lookup, st->PHI);
+      drft_forward(st->fft_lookup, st->PHI);
 #endif
      
 
@@ -339,14 +341,14 @@
    {
       if (st->cancel_count%M == j)
       {
-         drft_backward(&st->fft_lookup, &st->W[j*N]);
+         drft_backward(st->fft_lookup, &st->W[j*N]);
          for (i=0;i<N;i++)
             st->W[j*N+i]*=scale;
          for (i=st->frame_size;i<N;i++)
          {
             st->W[j*N+i]=0;
          }
-         drft_forward(&st->fft_lookup, &st->W[j*N]);
+         drft_forward(st->fft_lookup, &st->W[j*N]);
       }
 
    }

<p><p>1.2       +8 -5      speex/libspeex/preprocess.c

Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- preprocess.c	16 Sep 2003 17:50:45 -0000	1.1
+++ preprocess.c	16 Sep 2003 18:35:45 -0000	1.2
@@ -35,6 +35,7 @@
 #include "speex_preprocess.h"
 #include <stdio.h>
 #include "misc.h"
+#include "smallft.h"
 
 #define STABILITY_TIME 20
 #define NB_LAST_PS 10
@@ -181,7 +182,8 @@
    st->loudness2 = 6000;
    st->nb_loudness_adapt = 0;
 
-   drft_init(&st->fft_lookup,2*N);
+   st->fft_lookup = speex_alloc(sizeof(struct drft_lookup));
+   drft_init(st->fft_lookup,2*N);
 
    st->nb_adapt=0;
    st->consec_noise=0;
@@ -217,8 +219,9 @@
    speex_free(st->inbuf);
    speex_free(st->outbuf);
 
-   drft_clear(&st->fft_lookup);
-   
+   drft_clear(st->fft_lookup);
+   speex_free(st->fft_lookup);
+
    speex_free(st);
 }
 
@@ -512,7 +515,7 @@
       st->frame[i] *= st->window[i];
 
    /* Perform FFT */
-   drft_forward(&st->fft_lookup, st->frame);
+   drft_forward(st->fft_lookup, st->frame);
 
    /************************************************************** 
     *  Denoise in spectral domain using Ephraim-Malah algorithm  *
@@ -756,7 +759,7 @@
    st->frame[2*N-1]=0;
 
    /* Inverse FFT with 1/N scaling */
-   drft_backward(&st->fft_lookup, st->frame);
+   drft_backward(st->fft_lookup, st->frame);
 
    for (i=0;i<2*N;i++)
       st->frame[i] *= scale;

<p><p>1.2       +5 -5      speex/libspeex/smallft.c

Index: smallft.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/smallft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- smallft.c	8 May 2003 04:04:49 -0000	1.1
+++ smallft.c	16 Sep 2003 18:35:45 -0000	1.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: *unnormalized* fft transform
- last mod: $Id: smallft.c,v 1.1 2003/05/08 04:04:49 jm Exp $
+ last mod: $Id: smallft.c,v 1.2 2003/09/16 18:35:45 jm Exp $
 
  ********************************************************************/
 
@@ -1228,24 +1228,24 @@
   for(i=0;i<n;i++)c[i]=ch[i];
 }
 
-void drft_forward(drft_lookup *l,float *data){
+void drft_forward(struct drft_lookup *l,float *data){
   if(l->n==1)return;
   drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache);
 }
 
-void drft_backward(drft_lookup *l,float *data){
+void drft_backward(struct drft_lookup *l,float *data){
   if (l->n==1)return;
   drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache);
 }
 
-void drft_init(drft_lookup *l,int n){
+void drft_init(struct drft_lookup *l,int n){
   l->n=n;
   l->trigcache=calloc(3*n,sizeof(*l->trigcache));
   l->splitcache=calloc(32,sizeof(*l->splitcache));
   fdrffti(n, l->trigcache, l->splitcache);
 }
 
-void drft_clear(drft_lookup *l){
+void drft_clear(struct drft_lookup *l){
   if(l){
     if(l->trigcache)free(l->trigcache);
     if(l->splitcache)free(l->splitcache);

<p><p>1.3       +7 -7      speex/libspeex/smallft.h

Index: smallft.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/smallft.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- smallft.h	12 May 2003 01:23:51 -0000	1.2
+++ smallft.h	16 Sep 2003 18:35:45 -0000	1.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: fft transform
- last mod: $Id: smallft.h,v 1.2 2003/05/12 01:23:51 jm Exp $
+ last mod: $Id: smallft.h,v 1.3 2003/09/16 18:35:45 jm Exp $
 
  ********************************************************************/
 
@@ -24,16 +24,16 @@
 extern "C" {
 #endif
 
-typedef struct {
+struct drft_lookup{
   int n;
   float *trigcache;
   int *splitcache;
-} drft_lookup;
+};
 
-extern void drft_forward(drft_lookup *l,float *data);
-extern void drft_backward(drft_lookup *l,float *data);
-extern void drft_init(drft_lookup *l,int n);
-extern void drft_clear(drft_lookup *l);
+extern void drft_forward(struct drft_lookup *l,float *data);
+extern void drft_backward(struct drft_lookup *l,float *data);
+extern void drft_init(struct drft_lookup *l,int n);
+extern void drft_clear(struct drft_lookup *l);
 
 #ifdef __cplusplus
 }

<p><p>1.5       +2 -2      speex/libspeex/speex_echo.h

Index: speex_echo.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex_echo.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- speex_echo.h	21 Aug 2003 23:25:14 -0000	1.4
+++ speex_echo.h	16 Sep 2003 18:35:45 -0000	1.5
@@ -30,7 +30,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "smallft.h"
+struct drft_lookup;
 
 typedef struct SpeexEchoState {
    int frame_size;           /**< Number of samples processed each time */
@@ -53,7 +53,7 @@
    float *grad;
    float *old_grad;
 
-   drft_lookup fft_lookup;
+   struct drft_lookup *fft_lookup;
 
 
 } SpeexEchoState;

<p><p>1.2       +3 -3      speex/libspeex/speex_preprocess.h

Index: speex_preprocess.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex_preprocess.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- speex_preprocess.h	16 Sep 2003 17:50:45 -0000	1.1
+++ speex_preprocess.h	16 Sep 2003 18:35:45 -0000	1.2
@@ -32,12 +32,12 @@
 */
 
 
-#include "smallft.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct drft_lookup;
+
 typedef struct SpeexPreprocessState {
    int    frame_size;        /**< Number of samples processed each time */
    int    ps_size;           /**< Number of points in the power spectrum */
@@ -87,7 +87,7 @@
    int    nb_min_estimate;   /**< */
    int    last_update;       /**< */
    float  min_ener;          /**< */
-   drft_lookup fft_lookup;   /**< Lookup table for the FFT */
+   struct drft_lookup *fft_lookup;   /**< Lookup table for the FFT */
 
 } SpeexPreprocessState;
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list