[xiph-cvs] cvs commit: speex/libspeex nb_celp.c testenc.c

Jean-Marc Valin jm at xiph.org
Thu Oct 9 13:53:42 PDT 2003



jm          03/10/09 16:53:42

  Modified:    libspeex nb_celp.c testenc.c
  Log:
  output saturation for narrowband (need to do the same for wideband)

Revision  Changes    Path
1.140     +34 -5     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- nb_celp.c	9 Oct 2003 03:54:37 -0000	1.139
+++ nb_celp.c	9 Oct 2003 20:53:41 -0000	1.140
@@ -891,7 +891,14 @@
 
    /* Replace input by synthesized speech */
    for (i=0;i<st->frameSize;i++)
-     in[i]=PSHR(st->frame[i],SIG_SHIFT);
+   {
+      spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     in[i]=sig;
+   }
 
    if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0)
       st->bounded_pitch = 1;
@@ -1088,7 +1095,14 @@
    }
 
    for (i=0;i<st->frameSize;i++)
-      out[i]=PSHR(st->frame[i],SIG_SHIFT);
+   {
+      spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     out[i]=sig;
+   }
    
    st->first = 0;
    st->count_lost++;
@@ -1248,7 +1262,15 @@
       iir_mem2(st->exc, lpc, st->frame, st->frameSize, st->lpcSize, st->mem_sp);
 
       for (i=0;i<st->frameSize;i++)
-         out[i]=PSHR(st->frame[i],SIG_SHIFT);
+      {
+         spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+         if (sig>32767)
+            sig = 32767;
+         if (sig<-32767)
+            sig = -32767;
+         out[i]=sig;
+      }
+
       st->count_lost=0;
       return 0;
    }
@@ -1599,9 +1621,16 @@
       }
    }
    
-   /*Copy output signal*/
+   /*Copy output signal*/   
    for (i=0;i<st->frameSize;i++)
-     out[i]=PSHR(st->frame[i],SIG_SHIFT);
+   {
+      spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     out[i]=sig;
+   }
 
    /*for (i=0;i<st->frameSize;i++)
      printf ("%d\n", (int)st->frame[i]);*/

<p><p>1.50      +2 -2      speex/libspeex/testenc.c

Index: testenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- testenc.c	8 Oct 2003 05:03:47 -0000	1.49
+++ testenc.c	9 Oct 2003 20:53:41 -0000	1.50
@@ -105,8 +105,8 @@
    {
         float s=0, e=0;
         for (i=0;i<FRAME_SIZE;++i) {
-            s += in_short[i] * in_short[i];
-            e += (in_short[i]-out_short[i]) * (in_short[i]-out_short[i]);
+            s += (float)in_short[i] * in_short[i];
+            e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
         }
         seg_snr += 10*log10((s+1)/(e+1));
         sigpow += s;

<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