[xiph-cvs] cvs commit: ogg/src bitwise.c

Monty xiphmont at xiph.org
Fri Jan 18 20:06:54 PST 2002



xiphmont    02/01/18 20:06:53

  Modified:    src      bitwise.c
  Log:
  Minor fix; reading zero bits from the packer at end of file should not
  cause EOF.

Revision  Changes    Path
1.11      +4 -29     ogg/src/bitwise.c

Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/bitwise.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- bitwise.c	2001/12/21 14:41:15	1.10
+++ bitwise.c	2002/01/19 04:06:53	1.11
@@ -5,13 +5,13 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
   function: packing variable sized words into an octet stream
-  last mod: $Id: bitwise.c,v 1.10 2001/12/21 14:41:15 segher Exp $
+  last mod: $Id: bitwise.c,v 1.11 2002/01/19 04:06:53 xiphmont Exp $
 
  ********************************************************************/
 
@@ -100,7 +100,7 @@
 
   if(b->endbyte+4>=b->storage){
     /* not the main path */
-    if(b->endbyte+(bits-1)/8>=b->storage)return(-1);
+    if(b->endbyte*8+bits>b->storage*8)return(-1);
   }
   
   ret=b->ptr[0]>>b->endbit;
@@ -123,21 +123,6 @@
   return((b->ptr[0]>>b->endbit)&1);
 }
 
-/* Read in bits without advancing the bitptr; bits <= 8 */
-/* we never return 'out of bits'; we'll handle it on _adv */
-long oggpack_look_huff(oggpack_buffer *b,int bits){
-  unsigned long ret;
-  unsigned long m=mask[bits];
-  
-  bits+=b->endbit;
-  
-  ret=b->ptr[0]>>b->endbit;
-  if(bits>8){
-    ret|=b->ptr[1]<<(8-b->endbit);  
-  }
-  return(m&ret);
-}
-
 void oggpack_adv(oggpack_buffer *b,int bits){
   bits+=b->endbit;
   b->ptr+=bits/8;
@@ -153,16 +138,6 @@
   }
 }
 
-/* have to check for overflow now. return -1 on overflow */
-int oggpack_adv_huff(oggpack_buffer *b,int bits){
-  if(b->endbyte+(b->endbit+bits-1)/8>=b->storage)return(-1);
-  bits+=b->endbit;
-  b->ptr+=bits/8;
-  b->endbyte+=bits/8;
-  b->endbit=bits&7;
-  return 0;
-}
-
 /* bits <= 32 */
 long oggpack_read(oggpack_buffer *b,int bits){
   unsigned long ret;
@@ -173,7 +148,7 @@
   if(b->endbyte+4>=b->storage){
     /* not the main path */
     ret=-1UL;
-    if(b->endbyte+(bits-1)/8>=b->storage)goto overflow;
+    if(b->endbyte*8+bits>b->storage*8)goto overflow;
   }
   
   ret=b->ptr[0]>>b->endbit;

<p><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