[vorbis-dev] Re: libogg 1.1 test failure on alpha
Christian Weisgerber
naddy at mips.inka.de
Sat Dec 6 17:11:09 PST 2003
Bill Nottingham <notting at redhat.com> wrote:
> The oggpackB_{look,read} functions appear to not be right on 64-bit.
I finally sat down and looked at this.
Both functions fail to mask off the upper bits. There's an implicit
assumption that all arithmetic is & 0xffffffff, which holds on
32-bit machines, but fails on 64-bit ones.
(BTW, I don't understand the change from 1.16 to 1.17 in bitwise.c.
These expressions are exactly equivalent, aren't they?)
<p>--- src/bitwise.c.orig 2003-12-07 01:48:17.000000000 +0100
+++ src/bitwise.c 2003-12-07 01:52:58.000000000 +0100
@@ -251,7 +251,8 @@ long oggpack_look(oggpack_buffer *b,int
/* Read in bits without advancing the bitptr; bits <= 32 */
long oggpackB_look(oggpack_buffer *b,int bits){
unsigned long ret;
- int m=32-bits;
+ unsigned long m=mask[bits];
+ int s=32-bits;
bits+=b->endbit;
@@ -272,7 +273,7 @@ long oggpackB_look(oggpack_buffer *b,int
}
}
}
- return (ret>>(m>>1))>>((m+1)>>1);
+ return ((ret>>(s>>1))>>((s+1)>>1)&m);
}
long oggpack_look1(oggpack_buffer *b){
@@ -347,7 +348,8 @@ long oggpack_read(oggpack_buffer *b,int
/* bits <= 32 */
long oggpackB_read(oggpack_buffer *b,int bits){
unsigned long ret;
- long m=32-bits;
+ unsigned long m=mask[bits];
+ long s=32-bits;
bits+=b->endbit;
@@ -369,7 +371,7 @@ long oggpackB_read(oggpack_buffer *b,int
}
}
}
- ret=(ret>>(m>>1))>>((m+1)>>1);
+ ret=((ret>>(s>>1))>>((s+1)>>1)&m);
overflow:
--
Christian "naddy" Weisgerber naddy at mips.inka.de
--- >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 'vorbis-dev-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 Vorbis-dev
mailing list