changeset 21:20e680e7a490 libavcodec

get_bits() specialization, gives 4\speedup
author arpi_esp
date Sat, 04 Aug 2001 00:46:50 +0000
parents 907b67420d84
children c31fb57d17a6
files common.h h263.c mpeg12.c msmpeg4.c
diffstat 4 files changed, 178 insertions(+), 137 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Fri Aug 03 23:09:15 2001 +0000
+++ b/common.h	Sat Aug 04 00:46:50 2001 +0000
@@ -80,6 +80,47 @@
     return get_bits_long(s,n);
 }
 
+static inline unsigned int get_bits1(GetBitContext *s){
+    if(s->bit_cnt>0){
+        /* most common case here */
+        unsigned int val = s->bit_buf >> 31;
+        s->bit_buf <<= 1;
+	s->bit_cnt--;
+#ifdef STATS
+	st_bit_counts[st_current_index]++;
+#endif
+	return val;
+    }
+    return get_bits_long(s,1);
+}
+
+static inline void skip_bits(GetBitContext *s, int n){
+    if(s->bit_cnt>=n){
+        /* most common case here */
+        s->bit_buf <<= n;
+	s->bit_cnt -= n;
+#ifdef STATS
+	st_bit_counts[st_current_index] += n;
+#endif
+    } else {
+	get_bits_long(s,n);
+    }
+}
+
+static inline void skip_bits1(GetBitContext *s){
+    if(s->bit_cnt>0){
+        /* most common case here */
+        s->bit_buf <<= 1;
+	s->bit_cnt--;
+#ifdef STATS
+	st_bit_counts[st_current_index]++;
+#endif
+    } else {
+	get_bits_long(s,1);
+    }
+}
+
+
 void align_get_bits(GetBitContext *s);
 int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
              const void *bits, int bits_wrap, int bits_size,
--- a/h263.c	Fri Aug 03 23:09:15 2001 +0000
+++ b/h263.c	Sat Aug 04 00:46:50 2001 +0000
@@ -729,7 +729,7 @@
     static UINT8 quant_tab[4] = { -1, -2, 1, 2 };
 
     if (s->pict_type == P_TYPE) {
-        if (get_bits(&s->gb, 1)) {
+        if (get_bits1(&s->gb)) {
             /* skip mb */
             s->mb_intra = 0;
             for(i=0;i<6;i++)
@@ -796,7 +796,7 @@
     } else {
         s->ac_pred = 0;
 	if (s->h263_pred) {
-            s->ac_pred = get_bits(&s->gb, 1);
+            s->ac_pred = get_bits1(&s->gb);
         }
         cbpy = get_vlc(&s->gb, &cbpy_vlc);
         cbp = (cbpc & 3) | (cbpy << 2);
@@ -834,7 +834,7 @@
 
     if (code == 0)
         return pred;
-    sign = get_bits(&s->gb, 1);
+    sign = get_bits1(&s->gb);
     shift = s->f_code - 1;
     val = (code - 1) << shift;
     if (shift > 0)
@@ -906,7 +906,7 @@
             return -1;
         if (code == rl->n) {
             /* escape */
-            last = get_bits(&s->gb, 1);
+            last = get_bits1(&s->gb);
             run = get_bits(&s->gb, 6);
             level = (INT8)get_bits(&s->gb, 8);
             if (s->h263_rv10 && level == -128) {
@@ -918,7 +918,7 @@
             run = rl->table_run[code];
             level = rl->table_level[code];
             last = code >= rl->last;
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -952,7 +952,7 @@
         if ((level >> (code - 1)) == 0) /* if MSB not set it is negative*/
             level = - (level ^ ((1 << code) - 1));
         if (code > 8)
-            get_bits(&s->gb, 1); /* marker */
+            skip_bits1(&s->gb); /* marker */
     }
 
     pred = mpeg4_pred_dc(s, n, &dc_val, dir_ptr);
@@ -1009,15 +1009,15 @@
             return -1;
         if (code == rl->n) {
             /* escape */
-            if (get_bits(&s->gb, 1) != 0) {
-                if (get_bits(&s->gb, 1) != 0) {
+            if (get_bits1(&s->gb) != 0) {
+                if (get_bits1(&s->gb) != 0) {
                     /* third escape */
-                    last = get_bits(&s->gb, 1);
+                    last = get_bits1(&s->gb);
                     run = get_bits(&s->gb, 6);
-                    get_bits(&s->gb, 1); /* marker */
+                    get_bits1(&s->gb); /* marker */
                     level = get_bits(&s->gb, 12);
                     level = (level << 20) >> 20; /* sign extend */
-                    get_bits(&s->gb, 1); /* marker */
+                    skip_bits1(&s->gb); /* marker */
                 } else {
                     /* second escape */
                     code = get_vlc(&s->gb, &rl->vlc);
@@ -1027,7 +1027,7 @@
                     level = rl->table_level[code];
                     last = code >= rl->last;
                     run += rl->max_run[last][level] + 1;
-                    if (get_bits(&s->gb, 1))
+                    if (get_bits1(&s->gb))
                         level = -level;
                 }
             } else {
@@ -1039,14 +1039,14 @@
                 level = rl->table_level[code];
                 last = code >= rl->last;
                 level += rl->max_level[last][run];
-                if (get_bits(&s->gb, 1))
+                if (get_bits1(&s->gb))
                     level = -level;
             }
         } else {
             run = rl->table_run[code];
             level = rl->table_level[code];
             last = code >= rl->last;
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -1077,15 +1077,15 @@
     /* picture header */
     if (get_bits(&s->gb, 22) != 0x20)
         return -1;
-    get_bits(&s->gb, 8); /* picture timestamp */
+    skip_bits(&s->gb, 8); /* picture timestamp */
 
-    if (get_bits(&s->gb, 1) != 1)
+    if (get_bits1(&s->gb) != 1)
         return -1;	/* marker */
-    if (get_bits(&s->gb, 1) != 0)
+    if (get_bits1(&s->gb) != 0)
         return -1;	/* h263 id */
-    get_bits(&s->gb, 1);	/* split screen off */
-    get_bits(&s->gb, 1);	/* camera  off */
-    get_bits(&s->gb, 1);	/* freeze picture release off */
+    skip_bits1(&s->gb);	/* split screen off */
+    skip_bits1(&s->gb);	/* camera  off */
+    skip_bits1(&s->gb);	/* freeze picture release off */
 
     format = get_bits(&s->gb, 3);
 
@@ -1097,20 +1097,20 @@
         if (!width)
             return -1;
 
-        s->pict_type = I_TYPE + get_bits(&s->gb, 1);
+        s->pict_type = I_TYPE + get_bits1(&s->gb);
 
-        s->unrestricted_mv = get_bits(&s->gb, 1); 
+        s->unrestricted_mv = get_bits1(&s->gb); 
         s->h263_long_vectors = s->unrestricted_mv;
 
-        if (get_bits(&s->gb, 1) != 0)
+        if (get_bits1(&s->gb) != 0)
             return -1;	/* SAC: off */
-        if (get_bits(&s->gb, 1) != 0)
+        if (get_bits1(&s->gb) != 0)
             return -1;	/* advanced prediction mode: off */
-        if (get_bits(&s->gb, 1) != 0)
+        if (get_bits1(&s->gb) != 0)
             return -1;	/* not PB frame */
 
         s->qscale = get_bits(&s->gb, 5);
-        get_bits(&s->gb, 1);	/* Continuous Presence Multipoint mode: off */
+        skip_bits1(&s->gb);	/* Continuous Presence Multipoint mode: off */
     } else {
         s->h263_plus = 1;
         /* H.263v2 */
@@ -1118,24 +1118,24 @@
             return -1;
         if (get_bits(&s->gb, 3) != 6) /* custom source format */
             return -1;
-        get_bits(&s->gb, 12);
-        get_bits(&s->gb, 3);
+        skip_bits(&s->gb, 12);
+        skip_bits(&s->gb, 3);
         s->pict_type = get_bits(&s->gb, 3) + 1;
         if (s->pict_type != I_TYPE &&
             s->pict_type != P_TYPE)
             return -1;
-        get_bits(&s->gb, 7);
-        get_bits(&s->gb, 4); /* aspect ratio */
+        skip_bits(&s->gb, 7);
+        skip_bits(&s->gb, 4); /* aspect ratio */
         width = (get_bits(&s->gb, 9) + 1) * 4;
-        get_bits(&s->gb, 1);
+        skip_bits1(&s->gb);
         height = get_bits(&s->gb, 9) * 4;
         if (height == 0)
             return -1;
         s->qscale = get_bits(&s->gb, 5);
     }
     /* PEI */
-    while (get_bits(&s->gb, 1) != 0) {
-        get_bits(&s->gb, 8);
+    while (get_bits1(&s->gb) != 0) {
+        skip_bits(&s->gb, 8);
     }
     s->f_code = 1;
     s->width = width;
@@ -1169,40 +1169,40 @@
         int time_increment_resolution, width, height;
 
         /* vol header */
-        get_bits(&s->gb, 1); /* random access */
-        get_bits(&s->gb, 8); /* vo_type */
-        get_bits(&s->gb, 1); /* is_ol_id */
-        get_bits(&s->gb, 4); /* vo_ver_id */
-        get_bits(&s->gb, 3); /* vo_priority */
+        skip_bits(&s->gb, 1); /* random access */
+        skip_bits(&s->gb, 8); /* vo_type */
+        skip_bits(&s->gb, 1); /* is_ol_id */
+        skip_bits(&s->gb, 4); /* vo_ver_id */
+        skip_bits(&s->gb, 3); /* vo_priority */
         
-        get_bits(&s->gb, 4); /* aspect_ratio_info */
-        get_bits(&s->gb, 1); /* vol control parameter */
-        get_bits(&s->gb, 2); /* vol shape */
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits(&s->gb, 4); /* aspect_ratio_info */
+        skip_bits(&s->gb, 1); /* vol control parameter */
+        skip_bits(&s->gb, 2); /* vol shape */
+        skip_bits1(&s->gb);   /* marker */
         
         time_increment_resolution = get_bits(&s->gb, 16);
         s->time_increment_bits = log2(time_increment_resolution - 1) + 1;
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits1(&s->gb);   /* marker */
 
-        get_bits(&s->gb, 1); /* vop rate  */
-        get_bits(&s->gb, s->time_increment_bits);
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits1(&s->gb);   /* vop rate  */
+        skip_bits(&s->gb, s->time_increment_bits);
+        skip_bits1(&s->gb);   /* marker */
         
         width = get_bits(&s->gb, 13);
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits1(&s->gb);   /* marker */
         height = get_bits(&s->gb, 13);
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits1(&s->gb);   /* marker */
         
-        get_bits(&s->gb, 1); /* interfaced */
-        get_bits(&s->gb, 1); /* OBMC */
-        get_bits(&s->gb, 2); /* vol_sprite_usage */
-        get_bits(&s->gb, 1); /* not_8_bit */
+        skip_bits1(&s->gb);   /* interfaced */
+        skip_bits1(&s->gb);   /* OBMC */
+        skip_bits(&s->gb, 2); /* vol_sprite_usage */
+        skip_bits1(&s->gb);   /* not_8_bit */
 
-        get_bits(&s->gb, 1); /* vol_quant_type */
-        get_bits(&s->gb, 1); /* vol_quarter_pixel */
-        get_bits(&s->gb, 1); /* complexity_estimation_disabled */
-        get_bits(&s->gb, 1); /* resync_marker_disabled */
-        get_bits(&s->gb, 1); /* data_partioning_enabled */
+        skip_bits1(&s->gb);   /* vol_quant_type */
+        skip_bits1(&s->gb);   /* vol_quarter_pixel */
+        skip_bits1(&s->gb);   /* complexity_estimation_disabled */
+        skip_bits1(&s->gb);   /* resync_marker_disabled */
+        skip_bits1(&s->gb);   /* data_partioning_enabled */
         goto redo;
     } else if (startcode != 0x1b6) {
         goto redo;
@@ -1215,19 +1215,19 @@
     
     /* XXX: parse time base */
     time_incr = 0;
-    while (get_bits(&s->gb, 1) != 0) 
+    while (get_bits1(&s->gb) != 0) 
         time_incr++;
 
-    get_bits(&s->gb, 1);	/* marker */
-    get_bits(&s->gb, s->time_increment_bits);
-    get_bits(&s->gb, 1);	/* marker */
+    skip_bits1(&s->gb);   	/* marker */
+    skip_bits(&s->gb, s->time_increment_bits);
+    skip_bits1(&s->gb);   	/* marker */
     /* vop coded */
-    if (get_bits(&s->gb, 1) != 1)
+    if (get_bits1(&s->gb) != 1)
 	return -1; 
     
     if (s->pict_type == P_TYPE) {
         /* rounding type for motion estimation */
-	s->no_rounding = get_bits(&s->gb, 1);
+	s->no_rounding = get_bits1(&s->gb);
     }
         
     if (get_bits(&s->gb, 3) != 0)
@@ -1249,15 +1249,15 @@
     /* picture header */
     if (get_bits(&s->gb, 22) != 0x20)
         return -1;
-    get_bits(&s->gb, 8); /* picture timestamp */
+    skip_bits(&s->gb, 8); /* picture timestamp */
 
-    if (get_bits(&s->gb, 1) != 1)
+    if (get_bits1(&s->gb) != 1)
         return -1;	/* marker */
-    if (get_bits(&s->gb, 1) != 0)
+    if (get_bits1(&s->gb) != 0)
         return -1;	/* h263 id */
-    get_bits(&s->gb, 1);	/* split screen off */
-    get_bits(&s->gb, 1);	/* camera  off */
-    get_bits(&s->gb, 1);	/* freeze picture release off */
+    skip_bits1(&s->gb);	/* split screen off */
+    skip_bits1(&s->gb);	/* camera  off */
+    skip_bits1(&s->gb);	/* freeze picture release off */
 
     format = get_bits(&s->gb, 3);
     if (format != 7)
@@ -1265,27 +1265,27 @@
 
     s->h263_plus = 0;
 
-    s->pict_type = I_TYPE + get_bits(&s->gb, 1);
+    s->pict_type = I_TYPE + get_bits1(&s->gb);
     
-    s->unrestricted_mv = get_bits(&s->gb, 1); 
+    s->unrestricted_mv = get_bits1(&s->gb); 
     s->h263_long_vectors = s->unrestricted_mv;
 
-    if (get_bits(&s->gb, 1) != 0)
+    if (get_bits1(&s->gb) != 0)
         return -1;	/* SAC: off */
-    if (get_bits(&s->gb, 1) != 0)
+    if (get_bits1(&s->gb) != 0)
         return -1;	/* advanced prediction mode: off */
-    if (get_bits(&s->gb, 1) != 0)
+    if (get_bits1(&s->gb) != 0)
         return -1;	/* not PB frame */
 
     /* skip unknown header garbage */
-    get_bits(&s->gb, 41);
+    skip_bits(&s->gb, 41);
 
     s->qscale = get_bits(&s->gb, 5);
-    get_bits(&s->gb, 1);	/* Continuous Presence Multipoint mode: off */
+    skip_bits1(&s->gb);	/* Continuous Presence Multipoint mode: off */
 
     /* PEI */
-    while (get_bits(&s->gb, 1) != 0) {
-        get_bits(&s->gb, 8);
+    while (get_bits1(&s->gb) != 0) {
+        skip_bits(&s->gb, 8);
     }
     s->f_code = 1;
     return 0;
--- a/mpeg12.c	Fri Aug 03 23:09:15 2001 +0000
+++ b/mpeg12.c	Sat Aug 04 00:46:50 2001 +0000
@@ -483,8 +483,8 @@
 
 static inline int get_dmv(MpegEncContext *s)
 {
-    if(get_bits(&s->gb, 1)) 
-        return 1 - (get_bits(&s->gb, 1) << 1);
+    if(get_bits1(&s->gb)) 
+        return 1 - (get_bits1(&s->gb) << 1);
     else
         return 0;
 }
@@ -552,8 +552,8 @@
     switch(s->pict_type) {
     default:
     case I_TYPE:
-        if (get_bits(&s->gb, 1) == 0) {
-            if (get_bits(&s->gb, 1) == 0)
+        if (get_bits1(&s->gb) == 0) {
+            if (get_bits1(&s->gb) == 0)
                 return -1;
             mb_type = MB_QUANT | MB_INTRA;
         } else {
@@ -584,7 +584,7 @@
     if (s->picture_structure == PICT_FRAME && 
         !s->frame_pred_frame_dct &&
         (mb_type & (MB_PAT | MB_INTRA))) {
-        s->interlaced_dct = get_bits(&s->gb, 1);
+        s->interlaced_dct = get_bits1(&s->gb);
 #ifdef DEBUG
         if (s->interlaced_dct)
             printf("interlaced_dct\n");
@@ -609,7 +609,7 @@
         if (s->concealment_motion_vectors) {
             /* just parse them */
             if (s->picture_structure != PICT_FRAME) 
-                get_bits(&s->gb, 1); /* field select */
+                skip_bits1(&s->gb); /* field select */
             mpeg_decode_motion(s, s->mpeg_f_code[0][0], 0);
             mpeg_decode_motion(s, s->mpeg_f_code[0][1], 0);
         }
@@ -655,7 +655,7 @@
                         /* MT_16X8 */
                         s->mv_type = MV_TYPE_16X8;
                         for(j=0;j<2;j++) {
-                            s->field_select[i][j] = get_bits(&s->gb, 1);
+                            s->field_select[i][j] = get_bits1(&s->gb);
                             for(k=0;k<2;k++) {
                                 val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
                                                          s->last_mv[i][j][k]);
@@ -669,7 +669,7 @@
                     if (s->picture_structure == PICT_FRAME) {
                         s->mv_type = MV_TYPE_FIELD;
                         for(j=0;j<2;j++) {
-                            s->field_select[i][j] = get_bits(&s->gb, 1);
+                            s->field_select[i][j] = get_bits1(&s->gb);
                             val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
                                                      s->last_mv[i][j][0]);
                             s->last_mv[i][j][0] = val;
@@ -683,7 +683,7 @@
                         }
                     } else {
                         s->mv_type = MV_TYPE_16X16;
-                        s->field_select[i][0] = get_bits(&s->gb, 1);
+                        s->field_select[i][0] = get_bits1(&s->gb);
                         for(k=0;k<2;k++) {
                             val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
                                                      s->last_mv[i][0][k]);
@@ -739,7 +739,7 @@
     }
 
     if ((mb_type & MB_INTRA) && s->concealment_motion_vectors) {
-        get_bits(&s->gb, 1); /* marker */
+        skip_bits1(&s->gb); /* marker */
     }
     
     if (mb_type & MB_PAT) {
@@ -789,7 +789,7 @@
     if (code == 0) {
         return pred;
     }
-    sign = get_bits(&s->gb, 1);
+    sign = get_bits1(&s->gb);
     shift = fcode - 1;
     val = (code - 1) << shift;
     if (shift > 0)
@@ -890,7 +890,7 @@
         } else {
             run = rl->table_run[code];
             level = rl->table_level[code];
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -963,7 +963,7 @@
         } else {
             run = rl->table_run[code];
             level = rl->table_level[code];
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -1036,7 +1036,7 @@
         } else {
             run = rl->table_run[code];
             level = rl->table_level[code];
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -1121,9 +1121,9 @@
     ref = get_bits(&s->gb, 10); /* temporal ref */
     s->pict_type = get_bits(&s->gb, 3);
     dprintf("pict_type=%d\n", s->pict_type);
-    get_bits(&s->gb, 16);
+    skip_bits(&s->gb, 16);
     if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
-        s->full_pel[0] = get_bits(&s->gb, 1);
+        s->full_pel[0] = get_bits1(&s->gb);
         f_code = get_bits(&s->gb, 3);
         if (f_code == 0)
             return -1;
@@ -1131,7 +1131,7 @@
         s->mpeg_f_code[0][1] = f_code;
     }
     if (s->pict_type == B_TYPE) {
-        s->full_pel[1] = get_bits(&s->gb, 1);
+        s->full_pel[1] = get_bits1(&s->gb);
         f_code = get_bits(&s->gb, 3);
         if (f_code == 0)
             return -1;
@@ -1150,18 +1150,18 @@
     int bit_rate_ext, vbv_buf_ext, low_delay;
     int frame_rate_ext_n, frame_rate_ext_d;
 
-    get_bits(&s->gb, 8); /* profil and level */
-    get_bits(&s->gb, 1); /* progressive_sequence */
-    get_bits(&s->gb, 2); /* chroma_format */
+    skip_bits(&s->gb, 8); /* profil and level */
+    skip_bits(&s->gb, 1); /* progressive_sequence */
+    skip_bits(&s->gb, 2); /* chroma_format */
     horiz_size_ext = get_bits(&s->gb, 2);
     vert_size_ext = get_bits(&s->gb, 2);
     s->width |= (horiz_size_ext << 12);
     s->height |= (vert_size_ext << 12);
     bit_rate_ext = get_bits(&s->gb, 12);  /* XXX: handle it */
     s->bit_rate = ((s->bit_rate / 400) | (bit_rate_ext << 12)) * 400;
-    get_bits(&s->gb, 1); /* marker */
+    skip_bits1(&s->gb); /* marker */
     vbv_buf_ext = get_bits(&s->gb, 8);
-    low_delay = get_bits(&s->gb, 1);
+    low_delay = get_bits1(&s->gb);
     frame_rate_ext_n = get_bits(&s->gb, 2);
     frame_rate_ext_d = get_bits(&s->gb, 5);
     if (frame_rate_ext_d >= 1)
@@ -1174,27 +1174,27 @@
 {
     int i, v;
 
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->intra_matrix[i] = v;
             s->chroma_intra_matrix[i] = v;
         }
     }
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->non_intra_matrix[i] = v;
             s->chroma_non_intra_matrix[i] = v;
         }
     }
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->chroma_intra_matrix[i] = v;
         }
     }
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->chroma_non_intra_matrix[i] = v;
@@ -1211,15 +1211,15 @@
     s->mpeg_f_code[1][1] = get_bits(&s->gb, 4);
     s->intra_dc_precision = get_bits(&s->gb, 2);
     s->picture_structure = get_bits(&s->gb, 2);
-    s->top_field_first = get_bits(&s->gb, 1);
-    s->frame_pred_frame_dct = get_bits(&s->gb, 1);
-    s->concealment_motion_vectors = get_bits(&s->gb, 1);
-    s->q_scale_type = get_bits(&s->gb, 1);
-    s->intra_vlc_format = get_bits(&s->gb, 1);
-    s->alternate_scan = get_bits(&s->gb, 1);
-    s->repeat_first_field = get_bits(&s->gb, 1);
-    s->chroma_420_type = get_bits(&s->gb, 1);
-    s->progressive_frame = get_bits(&s->gb, 1);
+    s->top_field_first = get_bits1(&s->gb);
+    s->frame_pred_frame_dct = get_bits1(&s->gb);
+    s->concealment_motion_vectors = get_bits1(&s->gb);
+    s->q_scale_type = get_bits1(&s->gb);
+    s->intra_vlc_format = get_bits1(&s->gb);
+    s->alternate_scan = get_bits1(&s->gb);
+    s->repeat_first_field = get_bits1(&s->gb);
+    s->chroma_420_type = get_bits1(&s->gb);
+    s->progressive_frame = get_bits1(&s->gb);
     /* composite display not parsed */
     dprintf("dc_preci=%d\n", s->intra_dc_precision);
     dprintf("pict_structure=%d\n", s->picture_structure);
@@ -1285,8 +1285,8 @@
 
     s->qscale = get_bits(&s->gb, 5);
     /* extra slice info */
-    while (get_bits(&s->gb, 1) != 0) {
-        get_bits(&s->gb, 8);
+    while (get_bits1(&s->gb) != 0) {
+        skip_bits(&s->gb, 8);
     }
 
     for(;;) {
@@ -1351,12 +1351,12 @@
 
     width = get_bits(&s->gb, 12);
     height = get_bits(&s->gb, 12);
-    get_bits(&s->gb, 4);
+    skip_bits(&s->gb, 4);
     s->frame_rate_index = get_bits(&s->gb, 4);
     if (s->frame_rate_index == 0)
         return -1;
     s->bit_rate = get_bits(&s->gb, 18) * 400;
-    if (get_bits(&s->gb, 1) == 0) /* marker */
+    if (get_bits1(&s->gb) == 0) /* marker */
         return -1;
     if (width <= 0 || height <= 0 ||
         (width % 2) != 0 || (height % 2) != 0)
@@ -1382,11 +1382,11 @@
         s1->mpeg_enc_ctx_allocated = 1;
     }
 
-    get_bits(&s->gb, 10); /* vbv_buffer_size */
-    get_bits(&s->gb, 1);
+    skip_bits(&s->gb, 10); /* vbv_buffer_size */
+    skip_bits(&s->gb, 1);
 
     /* get matrix */
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->intra_matrix[i] = v;
@@ -1399,7 +1399,7 @@
             s->chroma_intra_matrix[i] = v;
         }
     }
-    if (get_bits(&s->gb, 1)) {
+    if (get_bits1(&s->gb)) {
         for(i=0;i<64;i++) {
             v = get_bits(&s->gb, 8);
             s->non_intra_matrix[i] = v;
--- a/msmpeg4.c	Fri Aug 03 23:09:15 2001 +0000
+++ b/msmpeg4.c	Sat Aug 04 00:46:50 2001 +0000
@@ -601,11 +601,11 @@
 static int decode012(GetBitContext *gb)
 {
     int n;
-    n = get_bits(gb, 1);
+    n = get_bits1(gb);
     if (n == 0)
         return 0;
     else
-        return get_bits(gb, 1) + 1;
+        return get_bits1(gb) + 1;
 }
 
 int msmpeg4_decode_picture_header(MpegEncContext * s)
@@ -629,17 +629,17 @@
         s->rl_chroma_table_index = decode012(&s->gb);
         s->rl_table_index = decode012(&s->gb);
 
-        s->dc_table_index = get_bits(&s->gb, 1);
+        s->dc_table_index = get_bits1(&s->gb);
         s->no_rounding = 1;
     } else {
-        s->use_skip_mb_code = get_bits(&s->gb, 1);
+        s->use_skip_mb_code = get_bits1(&s->gb);
         
         s->rl_table_index = decode012(&s->gb);
         s->rl_chroma_table_index = s->rl_table_index;
 
-        s->dc_table_index = get_bits(&s->gb, 1);
+        s->dc_table_index = get_bits1(&s->gb);
 
-        s->mv_table_index = get_bits(&s->gb, 1);
+        s->mv_table_index = get_bits1(&s->gb);
         s->no_rounding ^= 1;
     }
 #ifdef DEBUG
@@ -685,7 +685,7 @@
     if (s->pict_type == P_TYPE) {
         set_stat(ST_INTER_MB);
         if (s->use_skip_mb_code) {
-            if (get_bits(&s->gb, 1)) {
+            if (get_bits1(&s->gb)) {
                 /* skip mb */
                 s->mb_intra = 0;
                 for(i=0;i<6;i++)
@@ -739,7 +739,7 @@
         s->mv[0][0][1] = my;
     } else {
         set_stat(ST_INTRA_MB);
-        s->ac_pred = get_bits(&s->gb, 1);
+        s->ac_pred = get_bits1(&s->gb);
     }
 
     for (i = 0; i < 6; i++) {
@@ -801,10 +801,10 @@
             return -1;
         if (code == rl->n) {
             /* escape */
-            if (get_bits(&s->gb, 1) == 0) {
-                if (get_bits(&s->gb, 1) == 0) {
+            if (get_bits1(&s->gb) == 0) {
+                if (get_bits1(&s->gb) == 0) {
                     /* third escape */
-                    last = get_bits(&s->gb, 1);
+                    last = get_bits1(&s->gb);
                     run = get_bits(&s->gb, 6);
                     level = get_bits(&s->gb, 8);
                     level = (level << 24) >> 24; /* sign extend */
@@ -817,7 +817,7 @@
                     level = rl->table_level[code];
                     last = code >= rl->last;
                     run += rl->max_run[last][level] + run_diff;
-                    if (get_bits(&s->gb, 1))
+                    if (get_bits1(&s->gb))
                         level = -level;
                 }
             } else {
@@ -829,14 +829,14 @@
                 level = rl->table_level[code];
                 last = code >= rl->last;
                 level += rl->max_level[last][run];
-                if (get_bits(&s->gb, 1))
+                if (get_bits1(&s->gb))
                     level = -level;
             }
         } else {
             run = rl->table_run[code];
             level = rl->table_level[code];
             last = code >= rl->last;
-            if (get_bits(&s->gb, 1))
+            if (get_bits1(&s->gb))
                 level = -level;
         }
         i += run;
@@ -875,10 +875,10 @@
 
     if (level == DC_MAX) {
         level = get_bits(&s->gb, 8);
-        if (get_bits(&s->gb, 1))
+        if (get_bits1(&s->gb))
             level = -level;
     } else if (level != 0) {
-        if (get_bits(&s->gb, 1))
+        if (get_bits1(&s->gb))
             level = -level;
     }