changeset 306:ebfd518cbbbf libavcodec

dump_stream support (nicely formated 0s and 1s)
author michaelni
date Thu, 04 Apr 2002 20:04:10 +0000
parents 1de85b419387
children 764aeec1320e
files common.h
diffstat 1 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Thu Apr 04 19:50:46 2002 +0000
+++ b/common.h	Thu Apr 04 20:04:10 2002 +0000
@@ -13,6 +13,7 @@
 //#define ALT_BITSTREAM_READER
 //#define ALIGNED_BITSTREAM
 #define FAST_GET_FIRST_VLC
+//#define DUMP_STREAM // only works with the ALT_BITSTREAM_READER
 
 #ifdef HAVE_AV_CONFIG_H
 /* only include the following when compiling package */
@@ -243,7 +244,7 @@
 #endif
     //    printf("put_bits=%d %x\n", n, value);
     assert(n == 32 || value < (1U << n));
-
+    
     bit_buf = s->bit_buf;
     bit_left = s->bit_left;
 
@@ -469,7 +470,13 @@
     result>>= 32 - n;
     index+= n;
     s->index= index;
-    
+#ifdef DUMP_STREAM
+    while(n){
+        printf("%d", (result>>(n-1))&1);
+        n--;
+    }
+    printf(" ");
+#endif
     return result;
 #endif //!ALIGNED_BITSTREAM
 #else //ALT_BITSTREAM_READER
@@ -496,6 +503,9 @@
     index++;
     s->index= index;
     
+#ifdef DUMP_STREAM
+    printf("%d ", result);
+#endif
     return result;
 #else
     if(s->bit_cnt>0){
@@ -593,6 +603,14 @@
 static inline void skip_bits(GetBitContext *s, int n){
 #ifdef ALT_BITSTREAM_READER
     s->index+= n;
+#ifdef DUMP_STREAM
+    {
+        int result;
+        s->index-= n;
+        result= get_bits(s, n);
+    }
+#endif
+
 #else
     if(s->bit_cnt>=n){
         /* most common case here */
@@ -610,6 +628,10 @@
 static inline void skip_bits1(GetBitContext *s){
 #ifdef ALT_BITSTREAM_READER
     s->index++;
+#ifdef DUMP_STREAM
+    s->index--;
+    printf("%d ", get_bits1(s));
+#endif
 #else
     if(s->bit_cnt>0){
         /* most common case here */
@@ -735,6 +757,13 @@
     if (n > 0) {
         /* most common case (90%)*/
         FLUSH_BITS(n);
+#ifdef DUMP_STREAM
+        {
+            int n= bit_cnt - s->index;
+            skip_bits(s, n);
+            RESTORE_BITS(s);
+        }
+#endif
         RESTORE_BITS(s);
         return code;
     } else if (n == 0) {
@@ -769,6 +798,13 @@
             table_bits = vlc->table_bits + code;
         }
     }
+#ifdef DUMP_STREAM
+    {
+        int n= bit_cnt - s->index;
+        skip_bits(s, n);
+        RESTORE_BITS(s);
+    }
+#endif
     RESTORE_BITS(s);
     return code;
 }