changeset 452:297eed976b20 libavcodec

fixing get_bits_count at the end
author michaelni
date Sun, 02 Jun 2002 12:13:09 +0000
parents 1228bf19299b
children 69876443a723
files common.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/common.c	Sun Jun 02 12:11:44 2002 +0000
+++ b/common.c	Sun Jun 02 12:13:09 2002 +0000
@@ -174,6 +174,9 @@
                 (buf_ptr[-2] << 8) |
                 (buf_ptr[-1]);	    
 #endif
+            val |= bit_buf >> (32 + bit_cnt);
+            bit_buf <<= - bit_cnt;
+            bit_cnt += 32;
         } else {
             buf_ptr -= 4;
             bit_buf = 0;
@@ -185,11 +188,13 @@
                 bit_buf |= *buf_ptr++ << 8;
             if (buf_ptr < s->buf_end)
                 bit_buf |= *buf_ptr++;
+
+            val |= bit_buf >> (32 + bit_cnt);
+            bit_buf <<= - bit_cnt;
+            bit_cnt += 8*(buf_ptr - s->buf_ptr);
+            if(bit_cnt<0) bit_cnt=0;
         }
         s->buf_ptr = buf_ptr;
-        val |= bit_buf >> (32 + bit_cnt);
-        bit_buf <<= - bit_cnt;
-        bit_cnt += 32;
     }
     s->bit_buf = bit_buf;
     s->bit_cnt = bit_cnt;