[xiph-cvs] cvs commit: speex/src speexdec.c speexenc.c

Jean-Marc Valin jm at xiph.org
Fri May 30 12:44:54 PDT 2003



jm          03/05/30 15:44:54

  Modified:    libspeex bits.c nb_celp.c speex_bits.h
               src      speexdec.c speexenc.c
  Log:
  implemented new speex_bits_insert_terminator call so that the number of
  frames in a packet can be automatically determined.

Revision  Changes    Path
1.28      +8 -0      speex/libspeex/bits.c

Index: bits.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/bits.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- bits.c	18 Mar 2003 06:13:30 -0000	1.27
+++ bits.c	30 May 2003 19:44:54 -0000	1.28
@@ -342,3 +342,11 @@
 {
    return ((bits->nbBits+7)>>3);
 }
+
+void speex_bits_insert_terminator(SpeexBits *bits)
+{
+   if (bits->bitPtr<7)
+      speex_bits_pack(bits, 0, 1);
+   while (bits->bitPtr<7)
+      speex_bits_pack(bits, 1, 1);
+}

<p><p>1.118     +7 -1      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- nb_celp.c	16 May 2003 20:41:49 -0000	1.117
+++ nb_celp.c	30 May 2003 19:44:54 -0000	1.118
@@ -1158,6 +1158,8 @@
 
       /* Search for next narrowband block (handle requests, skip wideband blocks) */
       do {
+         if (speex_bits_remaining(bits)<5)
+            return -1;
          wideband = speex_bits_unpack_unsigned(bits, 1);
          if (wideband) /* Skip wideband block (for compatibility) */
          {
@@ -1172,6 +1174,9 @@
             } 
             advance -= (SB_SUBMODE_BITS+1);
             speex_bits_advance(bits, advance);
+            
+            if (speex_bits_remaining(bits)<5)
+               return -1;
             wideband = speex_bits_unpack_unsigned(bits, 1);
             if (wideband)
             {
@@ -1193,7 +1198,8 @@
 
             }
          }
-
+         if (speex_bits_remaining(bits)<4)
+            return -1;
          /* FIXME: Check for overflow */
          m = speex_bits_unpack_unsigned(bits, 4);
          if (m==15) /* We found a terminator */

<p><p>1.21      +7 -0      speex/libspeex/speex_bits.h

Index: speex_bits.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex_bits.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- speex_bits.h	3 Mar 2003 06:52:41 -0000	1.20
+++ speex_bits.h	30 May 2003 19:44:54 -0000	1.21
@@ -140,6 +140,13 @@
  */
 int speex_bits_remaining(SpeexBits *bits);
 
+/** Insert a terminator so that the data can be sent as a packet while auto-detecting 
+ * the number of frames in each packet 
+ *
+ * @param bits Bit-stream to operate on
+ */
+void speex_bits_insert_terminator(SpeexBits *bits);
+
 #ifdef __cplusplus
 }
 #endif

<p><p>1.76      +1 -1      speex/src/speexdec.c

Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- speexdec.c	7 May 2003 01:29:01 -0000	1.75
+++ speexdec.c	30 May 2003 19:44:54 -0000	1.76
@@ -571,7 +571,7 @@
 
                /*Copy Ogg packet to Speex bitstream*/
                speex_bits_read_from(&bits, (char*)op.packet, op.bytes);
-               for (j=0;j<nframes;j++)
+               for (j=0;j!=nframes;j++)
                {
                   int ret;
                   /*Decode frame*/

<p><p>1.78      +1 -0      speex/src/speexenc.c

Index: speexenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- speexenc.c	5 May 2003 23:34:19 -0000	1.77
+++ speexenc.c	30 May 2003 19:44:54 -0000	1.78
@@ -672,6 +672,7 @@
 
       if ((id+1)%nframes!=0)
          continue;
+      speex_bits_insert_terminator(&bits);
       nbBytes = speex_bits_write(&bits, cbits, MAX_FRAME_BYTES);
       speex_bits_reset(&bits);
       op.packet = (unsigned char *)cbits;

<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