[xiph-commits] r10569 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Thu Dec 8 13:23:34 PST 2005


Author: jm
Date: 2005-12-08 13:23:31 -0800 (Thu, 08 Dec 2005)
New Revision: 10569

Modified:
   trunk/speex/libspeex/mdf.c
   trunk/speex/libspeex/pseudofloat.h
Log:
converted power normalization to pseudo-float type


Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c	2005-12-08 12:45:13 UTC (rev 10568)
+++ trunk/speex/libspeex/mdf.c	2005-12-08 21:23:31 UTC (rev 10569)
@@ -87,7 +87,7 @@
    spx_word16_t *PHI;
    spx_word16_t *W;
    spx_word32_t *power;
-   float *power_1;
+   spx_float_t *power_1;
    spx_word32_t *Rf;
    spx_word32_t *Yf;
    spx_word32_t *Xf;
@@ -175,16 +175,16 @@
 #endif
 
 /** Compute weighted cross-power spectrum of a half-complex (packed) vector with conjugate */
-static inline void weighted_spectral_mul_conj(float *w, spx_word16_t *X, spx_word16_t *Y, spx_word16_t *prod, int N)
+static inline void weighted_spectral_mul_conj(spx_float_t *w, spx_word16_t *X, spx_word16_t *Y, spx_word16_t *prod, int N)
 {
    int i, j;
-   prod[0] = w[0]*MULT16_16(X[0],Y[0]);
+   prod[0] = FLOAT_MUL32(w[0],MULT16_16(X[0],Y[0]));
    for (i=1,j=1;i<N-1;i+=2,j++)
    {
-      prod[i] = w[j]*MAC16_16(MULT16_16(X[i],Y[i]), X[i+1],Y[i+1]);
-      prod[i+1] = w[j]*MAC16_16(MULT16_16(-X[i+1],Y[i]), X[i],Y[i+1]);
+      prod[i] = FLOAT_MUL32(w[j],MAC16_16(MULT16_16(X[i],Y[i]), X[i+1],Y[i+1]));
+      prod[i+1] = FLOAT_MUL32(w[j],MAC16_16(MULT16_16(-X[i+1],Y[i]), X[i],Y[i+1]));
    }
-   prod[i] = w[j]*MULT16_16(X[i],Y[i]);
+   prod[i] = FLOAT_MUL32(w[j],MULT16_16(X[i],Y[i]));
 }
 
 
@@ -221,7 +221,7 @@
    st->W = (spx_word16_t*)speex_alloc(M*N*sizeof(spx_word16_t));
    st->PHI = (spx_word16_t*)speex_alloc(M*N*sizeof(spx_word16_t));
    st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t));
-   st->power_1 = (float*)speex_alloc((frame_size+1)*sizeof(float));
+   st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t));
    
    for (i=0;i<N*M;i++)
    {
@@ -423,12 +423,12 @@
          r = leak_estimate*st->Yf[i] / (1.f+st->Rf[i]);
          if (r>.5)
             r = .5;
-         st->power_1[i] = WEIGHT_SCALING*adapt_rate*r/(1.f+st->power[i]);
+         st->power_1[i] = FLOAT_DIV32(WEIGHT_SCALING*adapt_rate*r,ADD32(1,st->power[i]));
          /*printf ("%f ", st->power_1[i]);*/
       }
    } else {
       for (i=0;i<=st->frame_size;i++)
-         st->power_1[i] = WEIGHT_SCALING*adapt_rate/(1.f+st->power[i]);
+         st->power_1[i] = FLOAT_DIV32(WEIGHT_SCALING*adapt_rate,ADD32(1,st->power[i]));
    }
    /* Compute weight gradient */
    for (j=0;j<M;j++)

Modified: trunk/speex/libspeex/pseudofloat.h
===================================================================
--- trunk/speex/libspeex/pseudofloat.h	2005-12-08 12:45:13 UTC (rev 10568)
+++ trunk/speex/libspeex/pseudofloat.h	2005-12-08 21:23:31 UTC (rev 10569)
@@ -192,6 +192,8 @@
 #define FLOAT_ZERO 0.f
 #define PSEUDOFLOAT(x) (x)
 #define FLOAT_MULT(a,b) ((a)*(b))
+#define FLOAT_MUL32(a,b) ((a)*(b))
+#define FLOAT_DIV32(a,b) ((a)/(b))
 #define FLOAT_ADD(a,b) ((a)+(b))
 #define REALFLOAT(x) (x)
 



More information about the commits mailing list