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

jm at svn.xiph.org jm at svn.xiph.org
Mon May 1 00:28:52 PDT 2006


Author: jm
Date: 2006-05-01 00:28:50 -0700 (Mon, 01 May 2006)
New Revision: 11330

Modified:
   trunk/speex/libspeex/mdf.c
Log:
Simple test for saturation. Saturated samples all get set to zero and no
adaptation is done for the whole frame.


Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c	2006-05-01 02:54:44 UTC (rev 11329)
+++ trunk/speex/libspeex/mdf.c	2006-05-01 07:28:50 UTC (rev 11330)
@@ -443,6 +443,7 @@
    spx_word16_t RER;
    spx_word32_t tmp32;
    spx_word16_t M_1;
+   int saturated=0;
    
    N = st->window_size;
    M = st->M;
@@ -506,6 +507,12 @@
       else if (tmp_out<-32768)
          tmp_out = -32768;
       tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE)));
+      /* This is an arbitrary test for saturation */
+      if (ref[i] <= -32000 || ref[i] >= 32000)
+      {
+         tmp_out = 0;
+         saturated = 1;
+      }
       out[i] = tmp_out;
       st->memE = tmp_out;
    }
@@ -662,12 +669,15 @@
       weighted_spectral_mul_conj(st->power_1, &st->X[j*N], st->E, st->PHI+N*j, N);
    }
 
-   /* Gradient descent */
-   for (i=0;i<M*N;i++)
+   if (!saturated)
    {
-      st->W[i] += st->PHI[i];
-      /* Old value of W in PHI */
-      st->PHI[i] = st->W[i] - st->PHI[i];
+      /* Gradient descent */
+      for (i=0;i<M*N;i++)
+      {
+         st->W[i] += st->PHI[i];
+         /* Old value of W in PHI */
+         st->PHI[i] = st->W[i] - st->PHI[i];
+      }
    }
    
    /* Update weight to prevent circular convolution (MDF / AUMDF) */



More information about the commits mailing list