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

Jean-Marc Valin jm at xiph.org
Tue Jan 7 22:57:01 PST 2003



jm          03/01/08 01:57:01

  Modified:    libspeex nb_celp.c sb_celp.c speex.h
  Log:
  Fixed some bad DTX/packet-loss/wideband interactions.

Revision  Changes    Path
1.108     +11 -2     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- nb_celp.c	6 Jan 2003 20:43:48 -0000	1.107
+++ nb_celp.c	8 Jan 2003 06:57:01 -0000	1.108
@@ -927,8 +927,13 @@
          float r=.9;
          
          float k1,k2,k3;
-         k1=SUBMODE(lpc_enh_k1);
-         k2=SUBMODE(lpc_enh_k2);
+         if (st->submodes[st->submodeID] != NULL)
+         {
+            k1=SUBMODE(lpc_enh_k1);
+            k2=SUBMODE(lpc_enh_k2);
+         } else {
+            k1=k2=.7;
+         }
          k3=(1-(1-r*k1)/(1-r*k2))/r;
          if (!st->lpc_enh_enabled)
          {
@@ -1180,6 +1185,7 @@
    {
       int extra;
       extra = speex_bits_unpack_unsigned(bits, 4);
+
       if (extra==15)
          st->dtx_enabled=1;
       else
@@ -1689,6 +1695,9 @@
          for (i=0;i<st->frameSize;i++)
             e[i]=st->innov[i];
       }
+      break;
+   case SPEEX_GET_DTX_STATUS:
+      *((int*)ptr) = st->dtx_enabled;
       break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);

<p><p>1.114     +41 -37    speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- sb_celp.c	7 Jan 2003 04:11:04 -0000	1.113
+++ sb_celp.c	8 Jan 2003 06:57:01 -0000	1.114
@@ -720,6 +720,8 @@
    {
       saved_modeid=st->submodeID;
       st->submodeID=1;
+   } else {
+      bw_lpc(0.99, st->interp_qlpc, st->interp_qlpc, st->lpcSize);
    }
 
    st->first=1;
@@ -733,8 +735,13 @@
       float r=.9;
       
       float k1,k2,k3;
-      k1=SUBMODE(lpc_enh_k1);
-      k2=SUBMODE(lpc_enh_k2);
+      if (st->submodes[st->submodeID] != NULL)
+      {
+         k1=SUBMODE(lpc_enh_k1);
+         k2=SUBMODE(lpc_enh_k2);
+      } else {
+         k1=k2=.7;
+      }
       k3=(1-(1-r*k1)/(1-r*k2))/r;
       k3=k1-k2;
       if (!st->lpc_enh_enabled)
@@ -808,11 +815,7 @@
    /* Decode the low-band */
    ret = speex_decode(st->st_low, bits, st->x0d);
 
-   speex_decoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx);
-   if (dtx==0)
-      dtx=1;
-   else
-      dtx=0;
+   speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, &dtx);
 
    /* If error decoding the narrowband part, propagate error */
    if (ret!=0)
@@ -820,43 +823,38 @@
       return ret;
    }
 
-   if (bits || st->submodes[st->submodeID] != NULL)
+   if (!bits)
    {
-      if (!bits)
-      {
-         sb_decode_lost(st, out, 0, stack);
-         return 0;
-      }
-      
-      /*Check "wideband bit"*/
-      if (speex_bits_remaining(bits)>0)
-         wideband = speex_bits_peek(bits);
-      else
-         wideband = 0;
-      if (wideband)
-      {
-         /*Regular wideband frame, read the submode*/
-         wideband = speex_bits_unpack_unsigned(bits, 1);
-         st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
-      } else
-      {
-         /*Was a narrowband frame, set "null submode"*/
-         st->submodeID = 0;
-      }
-      
-      if (dtx)
-      {
-         sb_decode_lost(st, out, 1, stack);
-         return 0;      
-      }
+      sb_decode_lost(st, out, dtx, stack);
+      return 0;
    }
 
-   for (i=0;i<st->frame_size;i++)
-      st->exc[i]=0;
+   /*Check "wideband bit"*/
+   if (speex_bits_remaining(bits)>0)
+      wideband = speex_bits_peek(bits);
+   else
+      wideband = 0;
+   if (wideband)
+   {
+      /*Regular wideband frame, read the submode*/
+      wideband = speex_bits_unpack_unsigned(bits, 1);
+      st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
+   } else
+   {
+      /*Was a narrowband frame, set "null submode"*/
+      st->submodeID = 0;
+   }
+   /*FIXME: Check for valid submodeID */
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
    {
+      if (dtx)
+      {
+         sb_decode_lost(st, out, 1, stack);
+         return 0;
+      }
+
       for (i=0;i<st->frame_size;i++)
          st->exc[i]=0;
 
@@ -875,6 +873,9 @@
 
    }
 
+   for (i=0;i<st->frame_size;i++)
+      st->exc[i]=0;
+
    low_pi_gain = PUSH(stack, st->nbSubframes, float);
    low_exc = PUSH(stack, st->frame_size, float);
    low_innov = PUSH(stack, st->frame_size, float);
@@ -1309,6 +1310,9 @@
          for (i=0;i<st->frame_size;i++)
             e[2*i]=2*st->exc[i];
       }
+      break;
+   case SPEEX_GET_DTX_STATUS:
+      speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr);
       break;
    default:
       speex_warning_int("Unknown nb_ctl request: ", request);

<p><p>1.73      +2 -0      speex/libspeex/speex.h

Index: speex.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- speex.h	31 Dec 2002 06:07:33 -0000	1.72
+++ speex.h	8 Jan 2003 06:57:01 -0000	1.73
@@ -134,6 +134,8 @@
 #define SPEEX_GET_EXC     101
 /** Used internally*/
 #define SPEEX_GET_INNOV   102
+/** Used internally*/
+#define SPEEX_GET_DTX_STATUS   103
 
 
 /* Preserving compatibility:*/

<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