diff common.c @ 1257:6defe392d5d2 libavcodec

libmpeg2 style bitstream reader fixes
author michaelni
date Wed, 14 May 2003 10:55:59 +0000
parents 604661d34c68
children 9fce515e9894
line wrap: on
line diff
--- a/common.c	Wed May 14 10:54:25 2003 +0000
+++ b/common.c	Wed May 14 10:55:59 2003 +0000
@@ -140,7 +140,7 @@
 #ifdef ALT_BITSTREAM_READER
     s->index=0;
 #elif defined LIBMPEG2_BITSTREAM_READER
-#ifdef LIBMPEG2_BITSTREAM_HACK
+#ifdef LIBMPEG2_BITSTREAM_READER_HACK
   if ((int)buffer&1) {
      /* word alignment */
     s->cache = (*buffer++)<<24;
@@ -170,6 +170,30 @@
 #endif
 }
 
+/** 
+ * reads 0-32 bits.
+ */
+unsigned int get_bits_long(GetBitContext *s, int n){
+    if(n<=17) return get_bits(s, n);
+    else{
+        int ret= get_bits(s, 16) << (n-16);
+        return ret | get_bits(s, n-16);
+    }
+}
+
+/** 
+ * shows 0-32 bits.
+ */
+unsigned int show_bits_long(GetBitContext *s, int n){
+    if(n<=17) return show_bits(s, n);
+    else{
+        GetBitContext gb= *s;
+        int ret= get_bits_long(s, n);
+        *s= gb;
+        return ret;
+    }
+}
+
 void align_get_bits(GetBitContext *s)
 {
     int n= (-get_bits_count(s)) & 7;