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

Jean-Marc Valin jm at xiph.org
Fri Aug 22 15:01:48 PDT 2003



jm          03/08/22 18:01:48

  Modified:    libspeex nb_celp.c nb_celp.h sb_celp.c sb_celp.h
  Log:
  added a call telling the codec not to encode the submode in the frame.

Revision  Changes    Path
1.120     +20 -0     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- nb_celp.c	13 Jun 2003 03:59:46 -0000	1.119
+++ nb_celp.c	22 Aug 2003 22:01:48 -0000	1.120
@@ -100,6 +100,7 @@
    st->pre_mem2=0;
    st->bounded_pitch = 1;
 
+   st->encode_submode = 1;
 #ifdef EPIC_48K
    st->lbr_48k=mode->lbr48k;
 #endif
@@ -472,6 +473,8 @@
       st->relative_quality = -1;
    }
 
+   if (st->encode_submode)
+   {
 #ifdef EPIC_48K
    if (!st->lbr_48k) {
 #endif
@@ -485,6 +488,7 @@
 #ifdef EPIC_48K
    }
 #endif
+   }
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
@@ -929,6 +933,7 @@
 
    st->stack = ((char*)st) + sizeof(DecState);
 
+   st->encode_submode = 1;
 #ifdef EPIC_48K
    st->lbr_48k=mode->lbr48k;
 #endif
@@ -1139,6 +1144,8 @@
    st=(DecState*)state;
    stack=st->stack;
 
+   if (st->encode_submode)
+   {
 #ifdef EPIC_48K
    if (!st->lbr_48k) {
 #endif
@@ -1230,6 +1237,7 @@
 #ifdef EPIC_48K
    }
 #endif
+   }
 
    /* Shift all buffers by one frame */
    speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
@@ -1763,6 +1771,12 @@
             st->excBuf[i]=st->swBuf[i]=st->inBuf[i]=st->exc2Buf[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;
@@ -1853,6 +1867,12 @@
             st->excBuf[i]=st->inBuf[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;

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

Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- nb_celp.h	16 May 2003 20:41:49 -0000	1.50
+++ nb_celp.h	22 Aug 2003 22:01:48 -0000	1.51
@@ -117,6 +117,7 @@
    int    complexity;     /**< Complexity setting (0-10 from least complex to most complex) */
    int    sampling_rate;
 
+   int    encode_submode;
    SpeexSubmode **submodes; /**< Sub-mode data */
    int    submodeID;      /**< Activated sub-mode */
    int    submodeSelect;  /**< Mode chosen by the user (may differ from submodeID if VAD is on) */
@@ -164,6 +165,7 @@
    float  pitch_gain_buf[3];  /**< Pitch gain of last decoded frames */
    int    pitch_gain_buf_idx; /**< Tail of the buffer */
 
+   int    encode_submode;
    SpeexSubmode **submodes; /**< Sub-mode data */
    int    submodeID;      /**< Activated sub-mode */
    int    lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */

<p><p>1.124     +47 -23    speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- sb_celp.c	10 Aug 2003 06:35:39 -0000	1.123
+++ sb_celp.c	22 Aug 2003 22:01:48 -0000	1.124
@@ -143,6 +143,7 @@
    st->lpcSize=mode->lpcSize;
    st->bufSize=mode->bufSize;
 
+   st->encode_submode = 1;
    st->submodes=mode->submodes;
    st->submodeSelect = st->submodeID=mode->defaultSubmode;
    
@@ -390,11 +391,14 @@
       /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/
    }
 
-   speex_bits_pack(bits, 1, 1);
-   if (dtx)
-      speex_bits_pack(bits, 0, SB_SUBMODE_BITS);
-   else
-      speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
+   if (st->encode_submode)
+   {
+      speex_bits_pack(bits, 1, 1);
+      if (dtx)
+         speex_bits_pack(bits, 0, SB_SUBMODE_BITS);
+      else
+         speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
+   }
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (dtx || st->submodes[st->submodeID] == NULL)
@@ -659,6 +663,8 @@
    st->mode = m;
    mode=(SpeexSBMode*)m->mode;
 
+   st->encode_submode = 1;
+
    st->stack = ((char*)st) + sizeof(SBDecState);
 
 
@@ -834,25 +840,29 @@
       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 (st->submodeID != 0 && st->submodes[st->submodeID] == NULL)
+   if (st->encode_submode)
    {
-      speex_warning("Invalid mode encountered: corrupted stream?");
-      return -2;
+
+      /*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 (st->submodeID != 0 && st->submodes[st->submodeID] == NULL)
+      {
+         speex_warning("Invalid mode encountered: corrupted stream?");
+         return -2;
+      }
    }
 
    /* If null mode (no transmission), just set a couple things to zero*/
@@ -1207,6 +1217,13 @@
             st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      speex_encoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, &ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;
@@ -1294,6 +1311,13 @@
             st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      speex_decoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, &ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;

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

Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- sb_celp.h	16 May 2003 20:41:50 -0000	1.39
+++ sb_celp.h	22 Aug 2003 22:01:48 -0000	1.40
@@ -98,6 +98,7 @@
    int    vad_enabled;         /**< 1 for enabling VAD, 0 otherwise */
    float  relative_quality;
 
+   int    encode_submode;
    SpeexSubmode **submodes;
    int    submodeID;
    int    submodeSelect;
@@ -135,6 +136,7 @@
    float *mem_sp;
    float *pi_gain;
 
+   int    encode_submode;
    SpeexSubmode **submodes;
    int    submodeID;
 } SBDecState;

<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