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

Jean-Marc Valin jm at xiph.org
Thu Oct 9 14:33:52 PDT 2003



jm          03/10/09 17:33:52

  Modified:    libspeex sb_celp.c
  Log:
  output saturation for wideband

Revision  Changes    Path
1.143     +24 -22    speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -r1.142 -r1.143
--- sb_celp.c	9 Oct 2003 03:54:37 -0000	1.142
+++ sb_celp.c	9 Oct 2003 21:33:52 -0000	1.143
@@ -133,6 +133,26 @@
 };
 #endif
 
+static void mix_and_saturate(spx_word32_t *y0, spx_word32_t *y1, short *out, int len)
+{
+   int i;
+   for (i=0;i<len;i++)
+   {
+      spx_word32_t tmp;
+#ifdef FIXED_POINT
+      tmp=PSHR(y0[i]-y1[i],SIG_SHIFT-1);
+#else
+      tmp=2*(y0[i]-y1[i]);
+#endif
+      if (tmp>32767)
+         out[i] = 32767;
+      else if (tmp<-32767)
+         out[i] = -32767;
+      else
+         out[i] = tmp;
+   }
+}
+
 void *sb_encoder_init(SpeexMode *m)
 {
    int i;
@@ -809,13 +829,7 @@
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-#ifdef FIXED_POINT
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=PSHR(st->y0[i]-st->y1[i],SIG_SHIFT-1);
-#else
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=2*(st->y0[i]-st->y1[i]);   
-#endif
+   mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
 
    if (dtx)
    {
@@ -912,14 +926,8 @@
       fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
       fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-#ifdef FIXED_POINT
-      for (i=0;i<st->full_frame_size;i++)
-         out[i]=PSHR(st->y0[i]-st->y1[i],SIG_SHIFT-1);
-#else
-      for (i=0;i<st->full_frame_size;i++)
-         out[i]=2*(st->y0[i]-st->y1[i]);   
-#endif
-      
+      mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
+
       return 0;
 
    }
@@ -1079,13 +1087,7 @@
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-#ifdef FIXED_POINT
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=PSHR(st->y0[i]-st->y1[i],SIG_SHIFT-1);
-#else
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=2*(st->y0[i]-st->y1[i]);   
-#endif
+   mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
 
    for (i=0;i<st->lpcSize;i++)
       st->old_qlsp[i] = st->qlsp[i];

<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