OSDN Git Service

bitstream_incrpos の bit_incr に負の値を指定できるように改造
authoryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Fri, 5 Jun 2009 08:08:28 +0000 (08:08 +0000)
committeryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Fri, 5 Jun 2009 08:08:28 +0000 (08:08 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/swfed/trunk@143 7c90b180-03d5-4157-b861-58a559ae9d1e

src/bitstream.c
src/bitstream.h

index d0b5bc9..67686e1 100644 (file)
@@ -318,9 +318,13 @@ bitstream_align(bitstream_t *bs) {
 
 int
 bitstream_incrpos(bitstream_t *bs, signed long byte_incr,
-                             unsigned long bit_incr) {
+                  signed long bit_incr) {
     bs->byte_offset += byte_incr;
     bs->bit_offset += bit_incr;
+    while (bs->bit_offset < 0) {
+        bs->bit_offset += 8;
+        bs->byte_offset --;
+    }
     while (bs->bit_offset >= 8) {
         bs->bit_offset -= 8;
         bs->byte_offset ++;
index 26a0d72..bb0d28d 100644 (file)
@@ -50,7 +50,7 @@ extern void bitstream_align(bitstream_t *bs);
 
 /* seeking */
 extern int bitstream_incrpos(bitstream_t *bs, signed long byte_incr,
-                             unsigned long bit_incr);
+                             signed long bit_incr);
 extern int bitstream_setpos(bitstream_t *bs, unsigned long byte_offset,
                            unsigned long bit_offset);
 extern unsigned long bitstream_getbytepos(bitstream_t *bs);