Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <ffmpegagent-at-gmail.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 29/48] avcodec/h263dec: Stop using MpegEncContext.gb
Date: Mon, 23 Jun 2025 13:36:29 +0000
Message-ID: <ae7ab847c80220767effe9c3be7067e9663507fd.1750685809.git.ffmpegagent@gmail.com> (raw)
In-Reply-To: <pull.102.ffstaging.FFmpeg.1750685808.ffmpegagent@gmail.com>

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Add a GetBitContext to H263DecContext instead. This is in preparation
for removing MpegEncContext.gb.
Also move last_resync_gb to H263DecContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/flvdec.c        |  24 +--
 libavcodec/h263dec.c       |  52 +++---
 libavcodec/h263dec.h       |   5 +
 libavcodec/intelh263dec.c  |  64 +++----
 libavcodec/ituh263dec.c    | 339 +++++++++++++++++++------------------
 libavcodec/mpeg12dec.c     |  10 +-
 libavcodec/mpeg4videodec.c | 320 +++++++++++++++++-----------------
 libavcodec/mpegvideo.h     |   1 -
 libavcodec/mpegvideodec.h  |   6 +-
 libavcodec/msmpeg4dec.c    | 188 ++++++++++----------
 libavcodec/rv10.c          |  62 +++----
 libavcodec/vaapi_mpeg4.c   |   8 +-
 libavcodec/wmv2dec.c       |  92 +++++-----
 13 files changed, 588 insertions(+), 583 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index a5d96584f1..f2d0b642b7 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -31,26 +31,26 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
     int format, width, height;
 
     /* picture header */
-    if (get_bits(&h->c.gb, 17) != 1) {
+    if (get_bits(&h->gb, 17) != 1) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
         return AVERROR_INVALIDDATA;
     }
-    format = get_bits(&h->c.gb, 5);
+    format = get_bits(&h->gb, 5);
     if (format != 0 && format != 1) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
         return AVERROR_INVALIDDATA;
     }
     h->c.h263_flv       = format + 1;
-    h->c.picture_number = get_bits(&h->c.gb, 8); /* picture timestamp */
-    format            = get_bits(&h->c.gb, 3);
+    h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
+    format            = get_bits(&h->gb, 3);
     switch (format) {
     case 0:
-        width  = get_bits(&h->c.gb, 8);
-        height = get_bits(&h->c.gb, 8);
+        width  = get_bits(&h->gb, 8);
+        height = get_bits(&h->gb, 8);
         break;
     case 1:
-        width  = get_bits(&h->c.gb, 16);
-        height = get_bits(&h->c.gb, 16);
+        width  = get_bits(&h->gb, 16);
+        height = get_bits(&h->gb, 16);
         break;
     case 2:
         width  = 352;
@@ -81,18 +81,18 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
     h->c.width  = width;
     h->c.height = height;
 
-    h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->c.gb, 2);
+    h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->gb, 2);
     h->c.droppable = h->c.pict_type > AV_PICTURE_TYPE_P;
     if (h->c.droppable)
         h->c.pict_type = AV_PICTURE_TYPE_P;
 
-    skip_bits1(&h->c.gb); /* deblocking flag */
-    h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
+    skip_bits1(&h->gb); /* deblocking flag */
+    h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
 
     h->c.h263_long_vectors = 0;
 
     /* PEI */
-    if (skip_1stop_8data_bits(&h->c.gb) < 0)
+    if (skip_1stop_8data_bits(&h->gb) < 0)
         return AVERROR_INVALIDDATA;
 
     if (h->c.ehc_mode)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 161f13b1e1..fc63e8a5d8 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -187,7 +187,7 @@ static int decode_slice(H263DecContext *const h)
     const int mb_size   = 16 >> h->c.avctx->lowres;
     int ret;
 
-    h->c.last_resync_gb   = h->c.gb;
+    h->last_resync_gb     = h->gb;
     h->c.first_slice_line = 1;
     h->c.resync_mb_x      = h->c.mb_x;
     h->c.resync_mb_y      = h->c.mb_y;
@@ -200,8 +200,8 @@ static int decode_slice(H263DecContext *const h)
     }
 
     if (h->c.avctx->hwaccel) {
-        const uint8_t *start = h->c.gb.buffer + get_bits_count(&h->c.gb) / 8;
-        ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->c.gb.buffer_end - start);
+        const uint8_t *start = h->gb.buffer + get_bits_count(&h->gb) / 8;
+        ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->gb.buffer_end - start);
         // ensure we exit decode loop
         h->c.mb_y = h->c.mb_height;
         return ret;
@@ -253,7 +253,7 @@ static int decode_slice(H263DecContext *const h)
             h->c.mv_dir  = MV_DIR_FORWARD;
             h->c.mv_type = MV_TYPE_16X16;
             ff_dlog(h->c.avctx, "%d %06X\n",
-                    get_bits_count(&h->c.gb), show_bits(&h->c.gb, 24));
+                    get_bits_count(&h->gb), show_bits(&h->gb, 24));
 
             ff_tlog(NULL, "Decoding MB at %dx%d\n", h->c.mb_x, h->c.mb_y);
             ret = h->decode_mb(h);
@@ -300,7 +300,7 @@ static int decode_slice(H263DecContext *const h)
                 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
                                 h->c.mb_x, h->c.mb_y, ER_MB_ERROR & part_mask);
 
-                if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&h->c.gb) > 0)
+                if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&h->gb) > 0)
                     continue;
                 return AVERROR_INVALIDDATA;
             }
@@ -321,29 +321,29 @@ static int decode_slice(H263DecContext *const h)
     // Detect incorrect padding with wrong stuffing codes used by NEC N-02B
     if (h->c.codec_id == AV_CODEC_ID_MPEG4         &&
         (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
-        get_bits_left(&h->c.gb) >= 48              &&
-        show_bits(&h->c.gb, 24) == 0x4010          &&
+        get_bits_left(&h->gb) >= 48                &&
+        show_bits(&h->gb, 24) == 0x4010            &&
         !h->c.data_partitioning)
         h->c.padding_bug_score += 32;
 
     /* try to detect the padding bug */
     if (h->c.codec_id == AV_CODEC_ID_MPEG4         &&
         (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
-        get_bits_left(&h->c.gb) >= 0               &&
-        get_bits_left(&h->c.gb) < 137              &&
+        get_bits_left(&h->gb) >= 0                 &&
+        get_bits_left(&h->gb) < 137                &&
         !h->c.data_partitioning) {
-        const int bits_count = get_bits_count(&h->c.gb);
-        const int bits_left  = h->c.gb.size_in_bits - bits_count;
+        const int bits_count = get_bits_count(&h->gb);
+        const int bits_left  = h->gb.size_in_bits - bits_count;
 
         if (bits_left == 0) {
             h->c.padding_bug_score += 16;
         } else if (bits_left != 1) {
-            int v = show_bits(&h->c.gb, 8);
+            int v = show_bits(&h->gb, 8);
             v |= 0x7F >> (7 - (bits_count & 7));
 
             if (v == 0x7F && bits_left <= 8)
                 h->c.padding_bug_score--;
-            else if (v == 0x7F && ((get_bits_count(&h->c.gb) + 8) & 8) &&
+            else if (v == 0x7F && ((get_bits_count(&h->gb) + 8) & 8) &&
                      bits_left <= 16)
                 h->c.padding_bug_score += 4;
             else
@@ -353,10 +353,10 @@ static int decode_slice(H263DecContext *const h)
 
     if (h->c.codec_id == AV_CODEC_ID_H263          &&
         (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
-        get_bits_left(&h->c.gb) >= 8               &&
-        get_bits_left(&h->c.gb) < 300              &&
+        get_bits_left(&h->gb) >= 8                 &&
+        get_bits_left(&h->gb) < 300                &&
         h->c.pict_type == AV_PICTURE_TYPE_I        &&
-        show_bits(&h->c.gb, 8) == 0                &&
+        show_bits(&h->gb, 8) == 0                  &&
         !h->c.data_partitioning) {
 
         h->c.padding_bug_score += 32;
@@ -364,8 +364,8 @@ static int decode_slice(H263DecContext *const h)
 
     if (h->c.codec_id == AV_CODEC_ID_H263          &&
         (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
-        get_bits_left(&h->c.gb) >= 64              &&
-        AV_RB64(h->c.gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
+        get_bits_left(&h->gb) >= 64                &&
+        AV_RB64(h->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
 
         h->c.padding_bug_score += 32;
     }
@@ -380,7 +380,7 @@ static int decode_slice(H263DecContext *const h)
 
     // handle formats which don't have unique end markers
     if (h->c.msmpeg4_version != MSMP4_UNUSED || (h->c.workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
-        int left      = get_bits_left(&h->c.gb);
+        int left      = get_bits_left(&h->gb);
         int max_extra = 7;
 
         /* no markers in M$ crap */
@@ -398,7 +398,7 @@ static int decode_slice(H263DecContext *const h)
         if (left > max_extra)
             av_log(h->c.avctx, AV_LOG_ERROR,
                    "discarding %d junk bits at end, next would be %X\n",
-                   left, show_bits(&h->c.gb, 24));
+                   left, show_bits(&h->gb, 24));
         else if (left < 0)
             av_log(h->c.avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
         else
@@ -410,7 +410,7 @@ static int decode_slice(H263DecContext *const h)
 
     av_log(h->c.avctx, AV_LOG_ERROR,
            "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
-           get_bits_left(&h->c.gb), show_bits(&h->c.gb, 24), h->c.padding_bug_score);
+           get_bits_left(&h->gb), show_bits(&h->gb, 24), h->c.padding_bug_score);
 
     ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, h->c.mb_x, h->c.mb_y,
                     ER_MB_END & part_mask);
@@ -452,8 +452,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
         return 0;
     }
 
-    // h->c.gb might be overridden in ff_mpeg4_decode_picture_header() below.
-    ret = init_get_bits8(&h->c.gb, buf, buf_size);
+    // h->gb might be overridden in ff_mpeg4_decode_picture_header() below.
+    ret = init_get_bits8(&h->gb, buf, buf_size);
     if (ret < 0)
         return ret;
 
@@ -504,7 +504,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
     avctx->has_b_frames = !h->c.low_delay;
 
     if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-        if (h->c.pict_type != AV_PICTURE_TYPE_B && h->c.mb_num/2 > get_bits_left(&h->c.gb))
+        if (h->c.pict_type != AV_PICTURE_TYPE_B && h->c.mb_num/2 > get_bits_left(&h->gb))
             return AVERROR_INVALIDDATA;
         ff_mpeg4_workaround_bugs(avctx);
         if (h->c.studio_profile != (h->c.idsp.idct == NULL))
@@ -556,7 +556,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
 
     if (avctx->hwaccel) {
         ret = FF_HW_CALL(avctx, start_frame, NULL,
-                         h->c.gb.buffer, h->c.gb.buffer_end - h->c.gb.buffer);
+                         h->gb.buffer, h->gb.buffer_end - h->gb.buffer);
         if (ret < 0 )
             return ret;
     }
@@ -584,7 +584,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
     while (h->c.mb_y < h->c.mb_height) {
         if (h->c.msmpeg4_version != MSMP4_UNUSED) {
             if (h->c.slice_height == 0 || h->c.mb_x != 0 || slice_ret < 0 ||
-                (h->c.mb_y % h->c.slice_height) != 0 || get_bits_left(&h->c.gb) < 0)
+                (h->c.mb_y % h->c.slice_height) != 0 || get_bits_left(&h->gb) < 0)
                 break;
         } else {
             int prev_x = h->c.mb_x, prev_y = h->c.mb_y;
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index dd5e37a719..dfa056f08e 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -20,6 +20,7 @@
 #ifndef AVCODEC_H263DEC_H
 #define AVCODEC_H263DEC_H
 
+#include "get_bits.h"
 #include "mpegvideo.h"
 #include "vlc.h"
 #include "libavutil/mem_internal.h"
@@ -47,8 +48,12 @@ extern VLCElem ff_h263_mv_vlc[];
 typedef struct H263DecContext {
     MPVContext c;
 
+    GetBitContext gb;
+
     int (*decode_mb)(struct H263DecContext *h);
 
+    GetBitContext last_resync_gb;    ///< used to search for the next resync marker
+
     DECLARE_ALIGNED_32(int16_t, block)[6][64];
 } H263DecContext;
 
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index d7242f4922..3800e6f1cc 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -30,44 +30,44 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h)
 {
     int format;
 
-    if (get_bits_left(&h->c.gb) == 64) { /* special dummy frames */
+    if (get_bits_left(&h->gb) == 64) { /* special dummy frames */
         return FRAME_SKIPPED;
     }
 
     /* picture header */
-    if (get_bits(&h->c.gb, 22) != 0x20) {
+    if (get_bits(&h->gb, 22) != 0x20) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
         return -1;
     }
-    h->c.picture_number = get_bits(&h->c.gb, 8); /* picture timestamp */
+    h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
 
-    if (check_marker(h->c.avctx, &h->c.gb, "after picture_number") != 1) {
+    if (check_marker(h->c.avctx, &h->gb, "after picture_number") != 1) {
         return -1;      /* marker */
     }
-    if (get_bits1(&h->c.gb) != 0) {
+    if (get_bits1(&h->gb) != 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Bad H.263 id\n");
         return -1;      /* H.263 id */
     }
-    skip_bits1(&h->c.gb);         /* split screen off */
-    skip_bits1(&h->c.gb);         /* camera  off */
-    skip_bits1(&h->c.gb);         /* freeze picture release off */
+    skip_bits1(&h->gb);         /* split screen off */
+    skip_bits1(&h->gb);         /* camera  off */
+    skip_bits1(&h->gb);         /* freeze picture release off */
 
-    format = get_bits(&h->c.gb, 3);
+    format = get_bits(&h->gb, 3);
     if (format == 0 || format == 6) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Intel H.263 free format not supported\n");
         return -1;
     }
 
-    h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->c.gb);
+    h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
 
-    h->c.h263_long_vectors = get_bits1(&h->c.gb);
+    h->c.h263_long_vectors = get_bits1(&h->gb);
 
-    if (get_bits1(&h->c.gb) != 0) {
+    if (get_bits1(&h->gb) != 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "SAC not supported\n");
         return -1;      /* SAC: off */
     }
-    h->c.obmc     = get_bits1(&h->c.gb);
-    h->c.pb_frame = get_bits1(&h->c.gb);
+    h->c.obmc     = get_bits1(&h->gb);
+    h->c.pb_frame = get_bits1(&h->gb);
 
     if (format < 6) {
         h->c.width  = ff_h263_format[format][0];
@@ -75,31 +75,31 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h)
         h->c.avctx->sample_aspect_ratio.num = 12;
         h->c.avctx->sample_aspect_ratio.den = 11;
     } else {
-        format = get_bits(&h->c.gb, 3);
+        format = get_bits(&h->gb, 3);
         if(format == 0 || format == 7){
             av_log(h->c.avctx, AV_LOG_ERROR, "Wrong Intel H.263 format\n");
             return -1;
         }
-        if (get_bits(&h->c.gb, 2))
+        if (get_bits(&h->gb, 2))
             av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
-        h->c.loop_filter = get_bits1(&h->c.gb) * !h->c.avctx->lowres;
-        if (get_bits1(&h->c.gb))
+        h->c.loop_filter = get_bits1(&h->gb) * !h->c.avctx->lowres;
+        if (get_bits1(&h->gb))
             av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
-        if (get_bits1(&h->c.gb))
+        if (get_bits1(&h->gb))
             h->c.pb_frame = 2;
-        if (get_bits(&h->c.gb, 5))
+        if (get_bits(&h->gb, 5))
             av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
-        if (get_bits(&h->c.gb, 5) != 1)
+        if (get_bits(&h->gb, 5) != 1)
             av_log(h->c.avctx, AV_LOG_ERROR, "Invalid marker\n");
     }
     if(format == 6){
-        int ar = get_bits(&h->c.gb, 4);
-        skip_bits(&h->c.gb, 9); // display width
-        check_marker(h->c.avctx, &h->c.gb, "in dimensions");
-        skip_bits(&h->c.gb, 9); // display height
+        int ar = get_bits(&h->gb, 4);
+        skip_bits(&h->gb, 9); // display width
+        check_marker(h->c.avctx, &h->gb, "in dimensions");
+        skip_bits(&h->gb, 9); // display height
         if (ar == 15) {
-            h->c.avctx->sample_aspect_ratio.num = get_bits(&h->c.gb, 8); // aspect ratio - width
-            h->c.avctx->sample_aspect_ratio.den = get_bits(&h->c.gb, 8); // aspect ratio - height
+            h->c.avctx->sample_aspect_ratio.num = get_bits(&h->gb, 8); // aspect ratio - width
+            h->c.avctx->sample_aspect_ratio.den = get_bits(&h->gb, 8); // aspect ratio - height
         } else {
             h->c.avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
         }
@@ -107,16 +107,16 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h)
             av_log(h->c.avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
     }
 
-    h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
-    skip_bits1(&h->c.gb); /* Continuous Presence Multipoint mode: off */
+    h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
+    skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
 
     if (h->c.pb_frame) {
-        skip_bits(&h->c.gb, 3); //temporal reference for B-frame
-        skip_bits(&h->c.gb, 2); //dbquant
+        skip_bits(&h->gb, 3); //temporal reference for B-frame
+        skip_bits(&h->gb, 2); //dbquant
     }
 
     /* PEI */
-    if (skip_1stop_8data_bits(&h->c.gb) < 0)
+    if (skip_1stop_8data_bits(&h->gb) < 0)
         return AVERROR_INVALIDDATA;
 
     h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 0c8531dea9..c19134b0d4 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -82,7 +82,7 @@ void ff_h263_show_pict_info(H263DecContext *const h, int h263_plus)
     if (h->c.avctx->debug&FF_DEBUG_PICT_INFO) {
         av_log(h->c.avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
                h->c.qscale, av_get_picture_type_char(h->c.pict_type),
-               h->c.gb.size_in_bits, 1-h->c.no_rounding,
+               h->gb.size_in_bits, 1-h->c.no_rounding,
                h->c.obmc ? " AP" : "",
                h->c.umvplus ? " UMV" : "",
                h->c.h263_long_vectors ? " LONG" : "",
@@ -146,7 +146,7 @@ int ff_h263_decode_mba(H263DecContext *const h)
     for (i = 0; i < 6; i++)
         if (h->c.mb_num - 1 <= ff_mba_max[i])
             break;
-    mb_pos  = get_bits(&h->c.gb, ff_mba_length[i]);
+    mb_pos    = get_bits(&h->gb, ff_mba_length[i]);
     h->c.mb_x = mb_pos % h->c.mb_width;
     h->c.mb_y = mb_pos / h->c.mb_width;
 
@@ -163,41 +163,42 @@ static int h263_decode_gob_header(H263DecContext *const h)
     int left;
 
     /* Check for GOB Start Code */
-    val = show_bits(&h->c.gb, 16);
+    val = show_bits(&h->gb, 16);
     if(val)
         return -1;
 
         /* We have a GBSC probably with GSTUFF */
-    skip_bits(&h->c.gb, 16); /* Drop the zeros */
-    left = get_bits_left(&h->c.gb);
+    skip_bits(&h->gb, 16); /* Drop the zeros */
+    left = get_bits_left(&h->gb);
     left = FFMIN(left, 32);
     //MN: we must check the bits left or we might end in an infinite loop (or segfault)
     for(;left>13; left--){
-        if (get_bits1(&h->c.gb)) break; /* Seek the '1' bit */
+        if (get_bits1(&h->gb))
+            break; /* Seek the '1' bit */
     }
     if(left<=13)
         return -1;
 
     if (h->c.h263_slice_structured) {
-        if (check_marker(h->c.avctx, &h->c.gb, "before MBA")==0)
+        if (check_marker(h->c.avctx, &h->gb, "before MBA")==0)
             return -1;
 
         ff_h263_decode_mba(h);
 
         if (h->c.mb_num > 1583)
-            if (check_marker(h->c.avctx, &h->c.gb, "after MBA")==0)
+            if (check_marker(h->c.avctx, &h->gb, "after MBA")==0)
                 return -1;
 
-        h->c.qscale = get_bits(&h->c.gb, 5); /* SQUANT */
-        if (check_marker(h->c.avctx, &h->c.gb, "after SQUANT")==0)
+        h->c.qscale = get_bits(&h->gb, 5); /* SQUANT */
+        if (check_marker(h->c.avctx, &h->gb, "after SQUANT")==0)
             return -1;
-        skip_bits(&h->c.gb, 2); /* GFID */
+        skip_bits(&h->gb, 2); /* GFID */
     }else{
-        gob_number = get_bits(&h->c.gb, 5); /* GN */
+        gob_number = get_bits(&h->gb, 5); /* GN */
         h->c.mb_x = 0;
         h->c.mb_y = h->c.gob_index* gob_number;
-        skip_bits(&h->c.gb, 2); /* GFID */
-        h->c.qscale = get_bits(&h->c.gb, 5); /* GQUANT */
+        skip_bits(&h->gb, 2); /* GFID */
+        h->c.qscale = get_bits(&h->gb, 5); /* GQUANT */
     }
 
     if (h->c.mb_y >= h->c.mb_height)
@@ -220,25 +221,25 @@ int ff_h263_resync(H263DecContext *const h)
     /* In MPEG-4 studio mode look for a new slice startcode
      * and decode slice header */
     if (h->c.codec_id==AV_CODEC_ID_MPEG4 && h->c.studio_profile) {
-        align_get_bits(&h->c.gb);
+        align_get_bits(&h->gb);
 
-        while (get_bits_left(&h->c.gb) >= 32 && show_bits_long(&h->c.gb, 32) != SLICE_STARTCODE) {
-            get_bits(&h->c.gb, 8);
+        while (get_bits_left(&h->gb) >= 32 && show_bits_long(&h->gb, 32) != SLICE_STARTCODE) {
+            get_bits(&h->gb, 8);
         }
 
-        if (get_bits_left(&h->c.gb) >= 32 && show_bits_long(&h->c.gb, 32) == SLICE_STARTCODE)
-            return get_bits_count(&h->c.gb);
+        if (get_bits_left(&h->gb) >= 32 && show_bits_long(&h->gb, 32) == SLICE_STARTCODE)
+            return get_bits_count(&h->gb);
         else
             return -1;
     }
 
     if (h->c.codec_id==AV_CODEC_ID_MPEG4){
-        skip_bits1(&h->c.gb);
-        align_get_bits(&h->c.gb);
+        skip_bits1(&h->gb);
+        align_get_bits(&h->gb);
     }
 
-    if (show_bits(&h->c.gb, 16) ==0) {
-        pos = get_bits_count(&h->c.gb);
+    if (show_bits(&h->gb, 16) ==0) {
+        pos = get_bits_count(&h->gb);
         if(CONFIG_MPEG4_DECODER && h->c.codec_id==AV_CODEC_ID_MPEG4)
             ret = ff_mpeg4_decode_video_packet_header(h);
         else
@@ -247,15 +248,15 @@ int ff_h263_resync(H263DecContext *const h)
             return pos;
     }
     //OK, it's not where it is supposed to be ...
-    h->c.gb = h->c.last_resync_gb;
-    align_get_bits(&h->c.gb);
-    left = get_bits_left(&h->c.gb);
+    h->gb = h->last_resync_gb;
+    align_get_bits(&h->gb);
+    left = get_bits_left(&h->gb);
 
     for(;left>16+1+5+5; left-=8){
-        if (show_bits(&h->c.gb, 16) == 0){
-            GetBitContext bak = h->c.gb;
+        if (show_bits(&h->gb, 16) == 0){
+            GetBitContext bak = h->gb;
 
-            pos = get_bits_count(&h->c.gb);
+            pos = get_bits_count(&h->gb);
             if(CONFIG_MPEG4_DECODER && h->c.codec_id==AV_CODEC_ID_MPEG4)
                 ret = ff_mpeg4_decode_video_packet_header(h);
             else
@@ -263,9 +264,9 @@ int ff_h263_resync(H263DecContext *const h)
             if(ret>=0)
                 return pos;
 
-            h->c.gb = bak;
+            h->gb = bak;
         }
-        skip_bits(&h->c.gb, 8);
+        skip_bits(&h->gb, 8);
     }
 
     return -1;
@@ -274,19 +275,19 @@ int ff_h263_resync(H263DecContext *const h)
 int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code)
 {
     int code, val, sign, shift;
-    code = get_vlc2(&h->c.gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
+    code = get_vlc2(&h->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
 
     if (code == 0)
         return pred;
     if (code < 0)
         return 0xffff;
 
-    sign = get_bits1(&h->c.gb);
+    sign = get_bits1(&h->gb);
     shift = f_code - 1;
     val = code;
     if (shift) {
         val = (val - 1) << shift;
-        val |= get_bits(&h->c.gb, shift);
+        val |= get_bits(&h->gb, shift);
         val++;
     }
     if (sign)
@@ -313,15 +314,15 @@ static int h263p_decode_umotion(H263DecContext *const h, int pred)
 {
    int code = 0, sign;
 
-   if (get_bits1(&h->c.gb)) /* Motion difference = 0 */
+   if (get_bits1(&h->gb)) /* Motion difference = 0 */
       return pred;
 
-   code = 2 + get_bits1(&h->c.gb);
+   code = 2 + get_bits1(&h->gb);
 
-   while (get_bits1(&h->c.gb))
+   while (get_bits1(&h->gb))
    {
       code <<= 1;
-      code += get_bits1(&h->c.gb);
+      code += get_bits1(&h->gb);
       if (code >= 32768) {
           avpriv_request_sample(h->c.avctx, "Huge DMV");
           return 0xffff;
@@ -341,7 +342,7 @@ static int h263p_decode_umotion(H263DecContext *const h, int pred)
  */
 static void preview_obmc(H263DecContext *const h)
 {
-    GetBitContext gb = h->c.gb;
+    GetBitContext gb = h->gb;
 
     int cbpc, i, pred_x, pred_y, mx, my;
     int16_t *mot_val;
@@ -357,7 +358,7 @@ static void preview_obmc(H263DecContext *const h)
     av_assert2(h->c.pict_type == AV_PICTURE_TYPE_P);
 
     do{
-        if (get_bits1(&h->c.gb)) {
+        if (get_bits1(&h->gb)) {
             /* skip mb */
             mot_val = h->c.cur_pic.motion_val[0][h->c.block_index[0]];
             mot_val[0       ]= mot_val[2       ]=
@@ -368,15 +369,15 @@ static void preview_obmc(H263DecContext *const h)
             h->c.cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
             goto end;
         }
-        cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
+        cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
     }while(cbpc == 20);
 
     if(cbpc & 4){
         h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
     }else{
-        get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+        get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
         if (cbpc & 8) {
-            skip_bits(&h->c.gb, h->c.modified_quant ? (get_bits1(&h->c.gb) ? 1 : 5) : 2);
+            skip_bits(&h->gb, h->c.modified_quant ? (get_bits1(&h->gb) ? 1 : 5) : 2);
         }
 
         if ((cbpc & 16) == 0) {
@@ -411,7 +412,7 @@ static void preview_obmc(H263DecContext *const h)
                 else
                     my = ff_h263_decode_motion(h, pred_y, 1);
                 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                    skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
+                    skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
                 mot_val[0] = mx;
                 mot_val[1] = my;
             }
@@ -425,7 +426,7 @@ end:
         h->c.block_index[i] -= 1;
     h->c.mb_x--;
 
-    h->c.gb = gb;
+    h->gb = gb;
 }
 
 static void h263_decode_dquant(H263DecContext *const h)
@@ -434,12 +435,12 @@ static void h263_decode_dquant(H263DecContext *const h)
     int qscale;
 
     if (h->c.modified_quant) {
-        if (get_bits1(&h->c.gb))
-            qscale = ff_modified_quant_tab[get_bits1(&h->c.gb)][h->c.qscale];
+        if (get_bits1(&h->gb))
+            qscale = ff_modified_quant_tab[get_bits1(&h->gb)][h->c.qscale];
         else
-            qscale = get_bits(&h->c.gb, 5);
+            qscale = get_bits(&h->gb, 5);
     }else
-        qscale = h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)];
+        qscale = h->c.qscale + quant_tab[get_bits(&h->gb, 2)];
     ff_set_qscale(&h->c, qscale);
 }
 
@@ -527,7 +528,7 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64],
     int level, i, j, run;
     const RLTable *rl = &ff_h263_rl_inter;
     const uint8_t *scan_table;
-    GetBitContext gb = h->c.gb;
+    GetBitContext gb = h->gb;
 
     scan_table = h->c.intra_scantable.permutated;
     if (h->c.h263_aic && h->c.mb_intra) {
@@ -558,12 +559,12 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64],
                     h->c.rv10_first_dc_coded[component] = 1;
                 }
             } else {
-                level = get_bits(&h->c.gb, 8);
+                level = get_bits(&h->gb, 8);
                 if (level == 255)
                     level = 128;
             }
         }else{
-            level = get_bits(&h->c.gb, 8);
+            level = get_bits(&h->gb, 8);
             if((level&0x7F) == 0){
                 av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
                        level, h->c.mb_x, h->c.mb_y);
@@ -584,60 +585,60 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64],
     }
 retry:
     {
-    OPEN_READER(re, &h->c.gb);
+    OPEN_READER(re, &h->gb);
     i--; // offset by -1 to allow direct indexing of scan_table
     for(;;) {
-        UPDATE_CACHE(re, &h->c.gb);
-        GET_RL_VLC(level, run, re, &h->c.gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+        UPDATE_CACHE(re, &h->gb);
+        GET_RL_VLC(level, run, re, &h->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
         if (run == 66) {
             if (level){
-                CLOSE_READER(re, &h->c.gb);
+                CLOSE_READER(re, &h->gb);
                 av_log(h->c.avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n",
                        h->c.mb_x, h->c.mb_y);
                 return -1;
             }
             /* escape */
             if (CONFIG_FLV_DECODER && h->c.h263_flv > 1) {
-                int is11 = SHOW_UBITS(re, &h->c.gb, 1);
-                SKIP_CACHE(re, &h->c.gb, 1);
-                run = SHOW_UBITS(re, &h->c.gb, 7) + 1;
+                int is11 = SHOW_UBITS(re, &h->gb, 1);
+                SKIP_CACHE(re, &h->gb, 1);
+                run = SHOW_UBITS(re, &h->gb, 7) + 1;
                 if (is11) {
-                    SKIP_COUNTER(re, &h->c.gb, 1 + 7);
-                    UPDATE_CACHE(re, &h->c.gb);
-                    level = SHOW_SBITS(re, &h->c.gb, 11);
-                    SKIP_COUNTER(re, &h->c.gb, 11);
+                    SKIP_COUNTER(re, &h->gb, 1 + 7);
+                    UPDATE_CACHE(re, &h->gb);
+                    level = SHOW_SBITS(re, &h->gb, 11);
+                    SKIP_COUNTER(re, &h->gb, 11);
                 } else {
-                    SKIP_CACHE(re, &h->c.gb, 7);
-                    level = SHOW_SBITS(re, &h->c.gb, 7);
-                    SKIP_COUNTER(re, &h->c.gb, 1 + 7 + 7);
+                    SKIP_CACHE(re, &h->gb, 7);
+                    level = SHOW_SBITS(re, &h->gb, 7);
+                    SKIP_COUNTER(re, &h->gb, 1 + 7 + 7);
                 }
             } else {
-                run = SHOW_UBITS(re, &h->c.gb, 7) + 1;
-                SKIP_CACHE(re, &h->c.gb, 7);
-                level = (int8_t)SHOW_UBITS(re, &h->c.gb, 8);
-                SKIP_COUNTER(re, &h->c.gb, 7 + 8);
+                run = SHOW_UBITS(re, &h->gb, 7) + 1;
+                SKIP_CACHE(re, &h->gb, 7);
+                level = (int8_t)SHOW_UBITS(re, &h->gb, 8);
+                SKIP_COUNTER(re, &h->gb, 7 + 8);
                 if(level == -128){
-                    UPDATE_CACHE(re, &h->c.gb);
+                    UPDATE_CACHE(re, &h->gb);
                     if (h->c.codec_id == AV_CODEC_ID_RV10) {
                         /* XXX: should patch encoder too */
-                        level = SHOW_SBITS(re, &h->c.gb, 12);
-                        SKIP_COUNTER(re, &h->c.gb, 12);
+                        level = SHOW_SBITS(re, &h->gb, 12);
+                        SKIP_COUNTER(re, &h->gb, 12);
                     }else{
-                        level = SHOW_UBITS(re, &h->c.gb, 5);
-                        SKIP_CACHE(re, &h->c.gb, 5);
-                        level |= SHOW_SBITS(re, &h->c.gb, 6) * (1<<5);
-                        SKIP_COUNTER(re, &h->c.gb, 5 + 6);
+                        level = SHOW_UBITS(re, &h->gb, 5);
+                        SKIP_CACHE(re, &h->gb, 5);
+                        level |= SHOW_SBITS(re, &h->gb, 6) * (1<<5);
+                        SKIP_COUNTER(re, &h->gb, 5 + 6);
                     }
                 }
             }
         } else {
-            if (SHOW_UBITS(re, &h->c.gb, 1))
+            if (SHOW_UBITS(re, &h->gb, 1))
                 level = -level;
-            SKIP_COUNTER(re, &h->c.gb, 1);
+            SKIP_COUNTER(re, &h->gb, 1);
         }
         i += run;
         if (i >= 64){
-            CLOSE_READER(re, &h->c.gb);
+            CLOSE_READER(re, &h->gb);
             // redo update without last flag, revert -1 offset
             i = i - run + ((run-1)&63) + 1;
             if (i < 64) {
@@ -649,7 +650,7 @@ retry:
                 //Looks like a hack but no, it's the way it is supposed to work ...
                 rl = &ff_rl_intra_aic;
                 i = 0;
-                h->c.gb = gb;
+                h->gb = gb;
                 h->c.bdsp.clear_block(block);
                 goto retry;
             }
@@ -787,7 +788,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
 
     if (h->c.pict_type == AV_PICTURE_TYPE_P) {
         do{
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 /* skip mb */
                 h->c.mb_intra = 0;
                 for(i=0;i<6;i++)
@@ -800,7 +801,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
                 h->c.mb_skipped = !(h->c.obmc | h->c.loop_filter);
                 goto end;
             }
-            cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
+            cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
             if (cbpc < 0){
                 av_log(h->c.avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n",
                        h->c.mb_x, h->c.mb_y);
@@ -815,9 +816,9 @@ int ff_h263_decode_mb(H263DecContext *const h)
         if (h->c.mb_intra)
             goto intra;
 
-        if(h->c.pb_frame && get_bits1(&h->c.gb))
-            pb_mv_count = h263_get_modb(&h->c.gb, h->c.pb_frame, &cbpb);
-        cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+        if (h->c.pb_frame && get_bits1(&h->gb))
+            pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);
+        cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
 
         if (cbpy < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "cbpy damaged at %d %d\n",
@@ -858,7 +859,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
             h->c.mv[0][0][1] = my;
 
             if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-               skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
+                skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
         } else {
             h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
             h->c.mv_type = MV_TYPE_8X8;
@@ -880,7 +881,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
                 h->c.mv[0][i][0] = mx;
                 h->c.mv[0][i][1] = my;
                 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                  skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
+                    skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
                 mot_val[0] = mx;
                 mot_val[1] = my;
             }
@@ -899,7 +900,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
         mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
 
         do{
-            mb_type = get_vlc2(&h->c.gb, h263_mbtype_b_vlc,
+            mb_type = get_vlc2(&h->gb, h263_mbtype_b_vlc,
                                H263_MBTYPE_B_VLC_BITS, 2);
             if (mb_type < 0){
                 av_log(h->c.avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n",
@@ -911,13 +912,13 @@ int ff_h263_decode_mb(H263DecContext *const h)
         h->c.mb_intra = IS_INTRA(mb_type);
         if(HAS_CBP(mb_type)){
             h->c.bdsp.clear_blocks(h->block[0]);
-            cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
+            cbpc = get_vlc2(&h->gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
             if (h->c.mb_intra) {
                 dquant = IS_QUANT(mb_type);
                 goto intra;
             }
 
-            cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+            cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
 
             if (cbpy < 0){
                 av_log(h->c.avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n",
@@ -965,7 +966,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
                     return SLICE_ERROR;
 
                 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                    skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
+                    skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
 
                 h->c.mv[0][0][0] = mx;
                 h->c.mv[0][0][1] = my;
@@ -992,7 +993,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
                     return SLICE_ERROR;
 
                 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                    skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
+                    skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
 
                 h->c.mv[1][0][0] = mx;
                 h->c.mv[1][0][1] = my;
@@ -1004,7 +1005,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
         h->c.cur_pic.mb_type[xy] = mb_type;
     } else { /* I-Frame */
         do{
-            cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
+            cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
             if (cbpc < 0){
                 av_log(h->c.avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n",
                        h->c.mb_x, h->c.mb_y);
@@ -1019,18 +1020,18 @@ int ff_h263_decode_mb(H263DecContext *const h)
 intra:
         h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
         if (h->c.h263_aic) {
-            h->c.ac_pred = get_bits1(&h->c.gb);
+            h->c.ac_pred = get_bits1(&h->gb);
             if (h->c.ac_pred) {
                 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
 
-                h->c.h263_aic_dir = get_bits1(&h->c.gb);
+                h->c.h263_aic_dir = get_bits1(&h->gb);
             }
         }else
             h->c.ac_pred = 0;
 
-        if (h->c.pb_frame && get_bits1(&h->c.gb))
-            pb_mv_count = h263_get_modb(&h->c.gb, h->c.pb_frame, &cbpb);
-        cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+        if (h->c.pb_frame && get_bits1(&h->gb))
+            pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);
+        cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
         if(cbpy<0){
             av_log(h->c.avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n",
                    h->c.mb_x, h->c.mb_y);
@@ -1065,15 +1066,15 @@ intra:
     }
 end:
 
-    if (get_bits_left(&h->c.gb) < 0)
+    if (get_bits_left(&h->gb) < 0)
         return AVERROR_INVALIDDATA;
 
         /* per-MB end of slice check */
     {
-        int v = show_bits(&h->c.gb, 16);
+        int v = show_bits(&h->gb, 16);
 
-        if (get_bits_left(&h->c.gb) < 16) {
-            v >>= 16 - get_bits_left(&h->c.gb);
+        if (get_bits_left(&h->gb) < 16) {
+            v >>= 16 - get_bits_left(&h->gb);
         }
 
         if(v==0)
@@ -1089,16 +1090,16 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
     int width, height, i, ret;
     int h263_plus;
 
-    align_get_bits(&h->c.gb);
+    align_get_bits(&h->gb);
 
-    if (show_bits(&h->c.gb, 2) == 2 && h->c.avctx->frame_num == 0) {
+    if (show_bits(&h->gb, 2) == 2 && h->c.avctx->frame_num == 0) {
          av_log(h->c.avctx, AV_LOG_WARNING, "Header looks like RTP instead of H.263\n");
     }
 
-    uint32_t startcode = get_bits(&h->c.gb, 22-8);
+    uint32_t startcode = get_bits(&h->gb, 22-8);
 
-    for (i = get_bits_left(&h->c.gb); i>24; i -= 8) {
-        startcode = ((startcode << 8) | get_bits(&h->c.gb, 8)) & 0x003FFFFF;
+    for (i = get_bits_left(&h->gb); i>24; i -= 8) {
+        startcode = ((startcode << 8) | get_bits(&h->gb, 8)) & 0x003FFFFF;
 
         if(startcode == 0x20)
             break;
@@ -1109,25 +1110,25 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
         return -1;
     }
     /* temporal reference */
-    i = get_bits(&h->c.gb, 8); /* picture timestamp */
+    i = get_bits(&h->gb, 8); /* picture timestamp */
 
     i -= (i - (h->c.picture_number & 0xFF) + 128) & ~0xFF;
 
     h->c.picture_number = (h->c.picture_number&~0xFF) + i;
 
     /* PTYPE starts here */
-    if (check_marker(h->c.avctx, &h->c.gb, "in PTYPE") != 1) {
+    if (check_marker(h->c.avctx, &h->gb, "in PTYPE") != 1) {
         return -1;
     }
-    if (get_bits1(&h->c.gb) != 0) {
+    if (get_bits1(&h->gb) != 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Bad H.263 id\n");
         return -1;      /* H.263 id */
     }
-    skip_bits1(&h->c.gb);         /* split screen off */
-    skip_bits1(&h->c.gb);         /* camera  off */
-    skip_bits1(&h->c.gb);         /* freeze picture release off */
+    skip_bits1(&h->gb);         /* split screen off */
+    skip_bits1(&h->gb);         /* camera  off */
+    skip_bits1(&h->gb);         /* freeze picture release off */
 
-    int format = get_bits(&h->c.gb, 3);
+    int format = get_bits(&h->gb, 3);
     /*
         0    forbidden
         1    sub-QCIF
@@ -1143,19 +1144,19 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
         if (!width)
             return -1;
 
-        h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->c.gb);
+        h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
 
-        h->c.h263_long_vectors = get_bits1(&h->c.gb);
+        h->c.h263_long_vectors = get_bits1(&h->gb);
 
-        if (get_bits1(&h->c.gb) != 0) {
+        if (get_bits1(&h->gb) != 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
             return -1; /* SAC: off */
         }
-        h->c.obmc = get_bits1(&h->c.gb); /* Advanced prediction mode */
+        h->c.obmc = get_bits1(&h->gb); /* Advanced prediction mode */
 
-        h->c.pb_frame = get_bits1(&h->c.gb);
-        h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
-        skip_bits1(&h->c.gb); /* Continuous Presence Multipoint mode: off */
+        h->c.pb_frame = get_bits1(&h->gb);
+        h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
+        skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
 
         h->c.width = width;
         h->c.height = height;
@@ -1166,46 +1167,46 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
 
         /* H.263v2 */
         h263_plus = 1;
-        ufep = get_bits(&h->c.gb, 3); /* Update Full Extended PTYPE */
+        ufep = get_bits(&h->gb, 3); /* Update Full Extended PTYPE */
 
         /* ufep other than 0 and 1 are reserved */
         if (ufep == 1) {
             /* OPPTYPE */
-            format = get_bits(&h->c.gb, 3);
+            format = get_bits(&h->gb, 3);
             ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);
-            h->c.custom_pcf = get_bits1(&h->c.gb);
-            h->c.umvplus = get_bits1(&h->c.gb); /* Unrestricted Motion Vector */
-            if (get_bits1(&h->c.gb) != 0) {
+            h->c.custom_pcf = get_bits1(&h->gb);
+            h->c.umvplus    = get_bits1(&h->gb); /* Unrestricted Motion Vector */
+            if (get_bits1(&h->gb) != 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
             }
-            h->c.obmc = get_bits1(&h->c.gb); /* Advanced prediction mode */
-            h->c.h263_aic = get_bits1(&h->c.gb); /* Advanced Intra Coding (AIC) */
-            h->c.loop_filter = get_bits1(&h->c.gb);
+            h->c.obmc        = get_bits1(&h->gb); /* Advanced prediction mode */
+            h->c.h263_aic    = get_bits1(&h->gb); /* Advanced Intra Coding (AIC) */
+            h->c.loop_filter = get_bits1(&h->gb);
             if (h->c.avctx->lowres)
                 h->c.loop_filter = 0;
 
-            h->c.h263_slice_structured= get_bits1(&h->c.gb);
-            if (get_bits1(&h->c.gb) != 0) {
+            h->c.h263_slice_structured = get_bits1(&h->gb);
+            if (get_bits1(&h->gb) != 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
             }
-            if (get_bits1(&h->c.gb) != 0) {
+            if (get_bits1(&h->gb) != 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
             }
-            h->c.alt_inter_vlc  = get_bits1(&h->c.gb);
-            h->c.modified_quant = get_bits1(&h->c.gb);
+            h->c.alt_inter_vlc  = get_bits1(&h->gb);
+            h->c.modified_quant = get_bits1(&h->gb);
             if (h->c.modified_quant)
                 h->c.chroma_qscale_table= ff_h263_chroma_qscale_table;
 
-            skip_bits(&h->c.gb, 1); /* Prevent start code emulation */
+            skip_bits(&h->gb, 1); /* Prevent start code emulation */
 
-            skip_bits(&h->c.gb, 3); /* Reserved */
+            skip_bits(&h->gb, 3); /* Reserved */
         } else if (ufep != 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
             return -1;
         }
 
         /* MPPTYPE */
-        h->c.pict_type = get_bits(&h->c.gb, 3);
+        h->c.pict_type = get_bits(&h->gb, 3);
         switch (h->c.pict_type) {
         case 0: h->c.pict_type = AV_PICTURE_TYPE_I; break;
         case 1: h->c.pict_type = AV_PICTURE_TYPE_P; break;
@@ -1215,15 +1216,15 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
         default:
             return -1;
         }
-        skip_bits(&h->c.gb, 2);
-        h->c.no_rounding = get_bits1(&h->c.gb);
-        skip_bits(&h->c.gb, 4);
+        skip_bits(&h->gb, 2);
+        h->c.no_rounding = get_bits1(&h->gb);
+        skip_bits(&h->gb, 4);
 
         /* Get the picture dimensions */
         if (ufep) {
             if (format == 6) {
                 /* Custom Picture Format (CPFMT) */
-                int aspect_ratio_info = get_bits(&h->c.gb, 4);
+                int aspect_ratio_info = get_bits(&h->gb, 4);
                 ff_dlog(h->c.avctx, "aspect: %d\n", aspect_ratio_info);
                 /* aspect ratios:
                 0 - forbidden
@@ -1234,14 +1235,14 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
                 5 - 40:33 (525-type 16:9)
                 6-14 - reserved
                 */
-                width = (get_bits(&h->c.gb, 9) + 1) * 4;
-                check_marker(h->c.avctx, &h->c.gb, "in dimensions");
-                height = get_bits(&h->c.gb, 9) * 4;
+                width = (get_bits(&h->gb, 9) + 1) * 4;
+                check_marker(h->c.avctx, &h->gb, "in dimensions");
+                height = get_bits(&h->gb, 9) * 4;
                 ff_dlog(h->c.avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
                 if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
                     /* expected dimensions */
-                    h->c.avctx->sample_aspect_ratio.num = get_bits(&h->c.gb, 8);
-                    h->c.avctx->sample_aspect_ratio.den = get_bits(&h->c.gb, 8);
+                    h->c.avctx->sample_aspect_ratio.num = get_bits(&h->gb, 8);
+                    h->c.avctx->sample_aspect_ratio.den = get_bits(&h->gb, 8);
                 }else{
                     h->c.avctx->sample_aspect_ratio= ff_h263_pixel_aspect[aspect_ratio_info];
                 }
@@ -1258,8 +1259,8 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
 
             if (h->c.custom_pcf) {
                 h->c.avctx->framerate.num  = 1800000;
-                h->c.avctx->framerate.den  = 1000 + get_bits1(&h->c.gb);
-                h->c.avctx->framerate.den *= get_bits(&h->c.gb, 7);
+                h->c.avctx->framerate.den  = 1000 + get_bits1(&h->gb);
+                h->c.avctx->framerate.den *= get_bits(&h->gb, 7);
                 if (h->c.avctx->framerate.den == 0) {
                     av_log(h->c.avctx, AV_LOG_ERROR, "zero framerate\n");
                     return -1;
@@ -1273,30 +1274,30 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
         }
 
         if (h->c.custom_pcf)
-            skip_bits(&h->c.gb, 2); //extended Temporal reference
+            skip_bits(&h->gb, 2); //extended Temporal reference
 
         if (ufep) {
             if (h->c.umvplus) {
-                if(get_bits1(&h->c.gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
-                    skip_bits1(&h->c.gb);
+                if (get_bits1(&h->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
+                    skip_bits1(&h->gb);
             }
             if (h->c.h263_slice_structured) {
-                if (get_bits1(&h->c.gb) != 0) {
+                if (get_bits1(&h->gb) != 0) {
                     av_log(h->c.avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
                 }
-                if (get_bits1(&h->c.gb) != 0) {
+                if (get_bits1(&h->gb) != 0) {
                     av_log(h->c.avctx, AV_LOG_ERROR, "unordered slices not supported\n");
                 }
             }
             if (h->c.pict_type == AV_PICTURE_TYPE_B) {
-                skip_bits(&h->c.gb, 4); //ELNUM
+                skip_bits(&h->gb, 4); //ELNUM
                 if (ufep == 1) {
-                    skip_bits(&h->c.gb, 4); // RLNUM
+                    skip_bits(&h->gb, 4); // RLNUM
                 }
             }
         }
 
-        h->c.qscale = get_bits(&h->c.gb, 5);
+        h->c.qscale = get_bits(&h->gb, 5);
     }
 
     ret = av_image_check_size(h->c.width, h->c.height, 0, h->c.avctx);
@@ -1304,7 +1305,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
         return ret;
 
     if (!(h->c.avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
-        if ((h->c.width * h->c.height / 256 / 8) > get_bits_left(&h->c.gb))
+        if ((h->c.width * h->c.height / 256 / 8) > get_bits_left(&h->gb))
             return AVERROR_INVALIDDATA;
     }
 
@@ -1315,10 +1316,10 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
     h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
 
     if (h->c.pb_frame) {
-        skip_bits(&h->c.gb, 3); /* Temporal reference for B-pictures */
+        skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */
         if (h->c.custom_pcf)
-            skip_bits(&h->c.gb, 2); //extended Temporal reference
-        skip_bits(&h->c.gb, 2); /* Quantization information for B-pictures */
+            skip_bits(&h->gb, 2); //extended Temporal reference
+        skip_bits(&h->gb, 2); /* Quantization information for B-pictures */
     }
 
     if (h->c.pict_type!=AV_PICTURE_TYPE_B) {
@@ -1338,17 +1339,17 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
     }
 
     /* PEI */
-    if (skip_1stop_8data_bits(&h->c.gb) < 0)
+    if (skip_1stop_8data_bits(&h->gb) < 0)
         return AVERROR_INVALIDDATA;
 
     if (h->c.h263_slice_structured) {
-        if (check_marker(h->c.avctx, &h->c.gb, "SEPB1") != 1) {
+        if (check_marker(h->c.avctx, &h->gb, "SEPB1") != 1) {
             return -1;
         }
 
         ff_h263_decode_mba(h);
 
-        if (check_marker(h->c.avctx, &h->c.gb, "SEPB2") != 1) {
+        if (check_marker(h->c.avctx, &h->gb, "SEPB2") != 1) {
             return -1;
         }
     }
@@ -1366,19 +1367,19 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
 
     ff_h263_show_pict_info(h, h263_plus);
 
-    if (h->c.pict_type == AV_PICTURE_TYPE_I && h->c.codec_tag == AV_RL32("ZYGO") && get_bits_left(&h->c.gb) >= 85 + 13*3*16 + 50){
+    if (h->c.pict_type == AV_PICTURE_TYPE_I && h->c.codec_tag == AV_RL32("ZYGO") && get_bits_left(&h->gb) >= 85 + 13*3*16 + 50){
         int i,j;
-        for(i=0; i<85; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->c.gb));
+        for(i=0; i<85; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->gb));
         av_log(h->c.avctx, AV_LOG_DEBUG, "\n");
         for(i=0; i<13; i++){
             for(j=0; j<3; j++){
-                int v= get_bits(&h->c.gb, 8);
-                v |= get_sbits(&h->c.gb, 8) * (1 << 8);
+                int v= get_bits(&h->gb, 8);
+                v |= get_sbits(&h->gb, 8) * (1 << 8);
                 av_log(h->c.avctx, AV_LOG_DEBUG, " %5d", v);
             }
             av_log(h->c.avctx, AV_LOG_DEBUG, "\n");
         }
-        for(i=0; i<50; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->c.gb));
+        for(i=0; i<50; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->gb));
     }
 
     return 0;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index cba57369cd..15bfab9623 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -479,7 +479,7 @@ static int mpeg_decode_mb(MPVContext *const s)
             s->interlaced_dct = get_bits1(&s->gb);
 
         if (IS_QUANT(mb_type))
-            s->qscale = mpeg_get_qscale(s);
+            s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
 
         if (s->concealment_motion_vectors) {
             /* just parse them */
@@ -537,7 +537,7 @@ static int mpeg_decode_mb(MPVContext *const s)
             }
 
             if (IS_QUANT(mb_type))
-                s->qscale = mpeg_get_qscale(s);
+                s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
 
             s->last_mv[0][0][0] = 0;
             s->last_mv[0][0][1] = 0;
@@ -558,7 +558,7 @@ static int mpeg_decode_mb(MPVContext *const s)
             }
 
             if (IS_QUANT(mb_type))
-                s->qscale = mpeg_get_qscale(s);
+                s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
 
             /* motion vectors */
             s->mv_dir = MB_TYPE_MV_2_MV_DIR(mb_type);
@@ -1370,7 +1370,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
     ff_mpeg1_clean_buffers(s);
     s->interlaced_dct = 0;
 
-    s->qscale = mpeg_get_qscale(s);
+    s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
 
     if (s->qscale == 0) {
         av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
@@ -2805,7 +2805,7 @@ static int ipu_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                 skip_bits1(gb);
 
             if (intraquant)
-                m->qscale = mpeg_get_qscale(m);
+                m->qscale = mpeg_get_qscale(&m->gb, m->q_scale_type);
 
             memset(s->block, 0, sizeof(s->block));
 
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 88ddacc87f..c6ed9d31bb 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -383,8 +383,8 @@ void ff_mpeg4_pred_ac(H263DecContext *const h, int16_t *block, int n, int dir)
 static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
 {
     H263DecContext *const h = &ctx->h;
-    int bits_count = get_bits_count(&h->c.gb);
-    int v          = show_bits(&h->c.gb, 16);
+    int bits_count = get_bits_count(&h->gb);
+    int v          = show_bits(&h->gb, 16);
 
     if (h->c.workaround_bugs & FF_BUG_NO_PADDING && !ctx->resync_marker)
         return 0;
@@ -393,12 +393,12 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
         if (h->c.pict_type == AV_PICTURE_TYPE_B ||
             (v >> (8 - h->c.pict_type) != 1) || h->c.partitioned_frame)
             break;
-        skip_bits(&h->c.gb, 8 + h->c.pict_type);
+        skip_bits(&h->gb, 8 + h->c.pict_type);
         bits_count += 8 + h->c.pict_type;
-        v = show_bits(&h->c.gb, 16);
+        v = show_bits(&h->gb, 16);
     }
 
-    if (bits_count + 8 >= h->c.gb.size_in_bits) {
+    if (bits_count + 8 >= h->gb.size_in_bits) {
         v >>= 8;
         v  |= 0x7F >> (7 - (bits_count & 7));
 
@@ -412,20 +412,20 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
         if (v == mpeg4_resync_prefix[bits_count & 7]) {
             int len, mb_num;
             int mb_num_bits = av_log2(h->c.mb_num - 1) + 1;
-            GetBitContext gb = h->c.gb;
+            GetBitContext gb = h->gb;
 
-            skip_bits(&h->c.gb, 1);
-            align_get_bits(&h->c.gb);
+            skip_bits(&h->gb, 1);
+            align_get_bits(&h->gb);
 
             for (len = 0; len < 32; len++)
-                if (get_bits1(&h->c.gb))
+                if (get_bits1(&h->gb))
                     break;
 
-            mb_num = get_bits(&h->c.gb, mb_num_bits);
-            if (!mb_num || mb_num > h->c.mb_num || get_bits_count(&h->c.gb) + 6 > h->c.gb.size_in_bits)
+            mb_num = get_bits(&h->gb, mb_num_bits);
+            if (!mb_num || mb_num > h->c.mb_num || get_bits_count(&h->gb) + 6 > h->gb.size_in_bits)
                 mb_num= -1;
 
-            h->c.gb = gb;
+            h->gb = gb;
 
             if (len >= ff_mpeg4_get_video_packet_prefix_length(h->c.pict_type, ctx->f_code, ctx->b_code))
                 return mb_num;
@@ -713,11 +713,11 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h)
     int header_extension = 0, mb_num, len;
 
     /* is there enough space left for a video packet + header */
-    if (get_bits_count(&h->c.gb) > h->c.gb.size_in_bits - 20)
+    if (get_bits_count(&h->gb) > h->gb.size_in_bits - 20)
         return AVERROR_INVALIDDATA;
 
     for (len = 0; len < 32; len++)
-        if (get_bits1(&h->c.gb))
+        if (get_bits1(&h->gb))
             break;
 
     if (len != ff_mpeg4_get_video_packet_prefix_length(h->c.pict_type, ctx->f_code, ctx->b_code)) {
@@ -726,11 +726,11 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h)
     }
 
     if (ctx->shape != RECT_SHAPE) {
-        header_extension = get_bits1(&h->c.gb);
+        header_extension = get_bits1(&h->gb);
         // FIXME more stuff here
     }
 
-    mb_num = get_bits(&h->c.gb, mb_num_bits);
+    mb_num = get_bits(&h->gb, mb_num_bits);
     if (mb_num >= h->c.mb_num || !mb_num) {
         av_log(h->c.avctx, AV_LOG_ERROR,
                "illegal mb_num in video packet (%d %d) \n", mb_num, h->c.mb_num);
@@ -741,31 +741,31 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h)
     h->c.mb_y = mb_num / h->c.mb_width;
 
     if (ctx->shape != BIN_ONLY_SHAPE) {
-        int qscale = get_bits(&h->c.gb, ctx->quant_precision);
+        int qscale = get_bits(&h->gb, ctx->quant_precision);
         if (qscale)
             h->c.chroma_qscale = h->c.qscale = qscale;
     }
 
     if (ctx->shape == RECT_SHAPE)
-        header_extension = get_bits1(&h->c.gb);
+        header_extension = get_bits1(&h->gb);
 
     if (header_extension) {
-        while (get_bits1(&h->c.gb) != 0)
+        while (get_bits1(&h->gb) != 0)
             ;
 
-        check_marker(h->c.avctx, &h->c.gb, "before time_increment in video packed header");
-        skip_bits(&h->c.gb, ctx->time_increment_bits);      /* time_increment */
-        check_marker(h->c.avctx, &h->c.gb, "before vop_coding_type in video packed header");
+        check_marker(h->c.avctx, &h->gb, "before time_increment in video packed header");
+        skip_bits(&h->gb, ctx->time_increment_bits);      /* time_increment */
+        check_marker(h->c.avctx, &h->gb, "before vop_coding_type in video packed header");
 
-        skip_bits(&h->c.gb, 2); /* vop coding type */
+        skip_bits(&h->gb, 2); /* vop coding type */
         // FIXME not rect stuff here
 
         if (ctx->shape != BIN_ONLY_SHAPE) {
-            skip_bits(&h->c.gb, 3); /* intra dc vlc threshold */
+            skip_bits(&h->gb, 3); /* intra dc vlc threshold */
             // FIXME don't just ignore everything
             if (h->c.pict_type == AV_PICTURE_TYPE_S &&
                 ctx->vol_sprite_usage == GMC_SPRITE) {
-                if (mpeg4_decode_sprite_trajectory(ctx, &h->c.gb) < 0)
+                if (mpeg4_decode_sprite_trajectory(ctx, &h->gb) < 0)
                     return AVERROR_INVALIDDATA;
                 av_log(h->c.avctx, AV_LOG_ERROR, "untested\n");
             }
@@ -773,13 +773,13 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h)
             // FIXME reduced res stuff here
 
             if (h->c.pict_type != AV_PICTURE_TYPE_I) {
-                int f_code = get_bits(&h->c.gb, 3);       /* fcode_for */
+                int f_code = get_bits(&h->gb, 3);       /* fcode_for */
                 if (f_code == 0)
                     av_log(h->c.avctx, AV_LOG_ERROR,
                            "Error, video packet header damaged (f_code=0)\n");
             }
             if (h->c.pict_type == AV_PICTURE_TYPE_B) {
-                int b_code = get_bits(&h->c.gb, 3);
+                int b_code = get_bits(&h->gb, 3);
                 if (b_code == 0)
                     av_log(h->c.avctx, AV_LOG_ERROR,
                            "Error, video packet header damaged (b_code=0)\n");
@@ -787,7 +787,7 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h)
         }
     }
     if (ctx->new_pred)
-        decode_new_pred(ctx, &h->c.gb);
+        decode_new_pred(ctx, &h->gb);
 
     return 0;
 }
@@ -808,7 +808,7 @@ static void reset_studio_dc_predictors(Mpeg4DecContext *const ctx)
 int ff_mpeg4_decode_studio_slice_header(H263DecContext *const h)
 {
     Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
-    GetBitContext *gb = &h->c.gb;
+    GetBitContext *gb = &h->gb;
     unsigned vlc_len;
     uint16_t mb_num;
 
@@ -823,7 +823,7 @@ int ff_mpeg4_decode_studio_slice_header(H263DecContext *const h)
         h->c.mb_y = mb_num / h->c.mb_width;
 
         if (ctx->shape != BIN_ONLY_SHAPE)
-            h->c.qscale = mpeg_get_qscale(&h->c);
+            h->c.qscale = mpeg_get_qscale(&h->gb, h->c.q_scale_type);
 
         if (get_bits1(gb)) {  /* slice_extension_flag */
             skip_bits1(gb);   /* intra_slice */
@@ -985,9 +985,9 @@ static inline int mpeg4_decode_dc(H263DecContext *const h, int n, int *dir_ptr)
     int level, code, pred;
 
     if (n < 4)
-        code = get_vlc2(&h->c.gb, dc_lum, DC_VLC_BITS, 1);
+        code = get_vlc2(&h->gb, dc_lum, DC_VLC_BITS, 1);
     else
-        code = get_vlc2(&h->c.gb, dc_chrom, DC_VLC_BITS, 1);
+        code = get_vlc2(&h->gb, dc_chrom, DC_VLC_BITS, 1);
 
     if (code < 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc vlc\n");
@@ -999,19 +999,19 @@ static inline int mpeg4_decode_dc(H263DecContext *const h, int n, int *dir_ptr)
     } else {
         if (IS_3IV1) {
             if (code == 1)
-                level = 2 * get_bits1(&h->c.gb) - 1;
+                level = 2 * get_bits1(&h->gb) - 1;
             else {
-                if (get_bits1(&h->c.gb))
-                    level = get_bits(&h->c.gb, code - 1) + (1 << (code - 1));
+                if (get_bits1(&h->gb))
+                    level = get_bits(&h->gb, code - 1) + (1 << (code - 1));
                 else
-                    level = -get_bits(&h->c.gb, code - 1) - (1 << (code - 1));
+                    level = -get_bits(&h->gb, code - 1) - (1 << (code - 1));
             }
         } else {
-            level = get_xbits(&h->c.gb, code);
+            level = get_xbits(&h->gb, code);
         }
 
         if (code > 8) {
-            if (get_bits1(&h->c.gb) == 0) { /* marker */
+            if (get_bits1(&h->gb) == 0) { /* marker */
                 if (h->c.avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)) {
                     av_log(h->c.avctx, AV_LOG_ERROR, "dc marker bit missing\n");
                     return AVERROR_INVALIDDATA;
@@ -1052,10 +1052,10 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
                 int i;
 
                 do {
-                    if (show_bits(&h->c.gb, 19) == DC_MARKER)
+                    if (show_bits(&h->gb, 19) == DC_MARKER)
                         return mb_num - 1;
 
-                    cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
+                    cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
                     if (cbpc < 0) {
                         av_log(h->c.avctx, AV_LOG_ERROR,
                                "mcbpc corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1068,7 +1068,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
                 h->c.mb_intra            = 1;
 
                 if (cbpc & 4)
-                    ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
+                    ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
 
                 h->c.cur_pic.qscale_table[xy] = h->c.qscale;
 
@@ -1092,11 +1092,11 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
                 const int stride       = h->c.b8_stride * 2;
 
 try_again:
-                bits = show_bits(&h->c.gb, 17);
+                bits = show_bits(&h->gb, 17);
                 if (bits == MOTION_MARKER)
                     return mb_num - 1;
 
-                skip_bits1(&h->c.gb);
+                skip_bits1(&h->gb);
                 if (bits & 0x10000) {
                     /* skip mb */
                     if (h->c.pict_type == AV_PICTURE_TYPE_S &&
@@ -1126,7 +1126,7 @@ try_again:
                     continue;
                 }
 
-                cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
+                cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
                 if (cbpc < 0) {
                     av_log(h->c.avctx, AV_LOG_ERROR,
                            "mcbpc corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1156,7 +1156,7 @@ try_again:
                     if (h->c.pict_type == AV_PICTURE_TYPE_S &&
                         ctx->vol_sprite_usage == GMC_SPRITE &&
                         (cbpc & 16) == 0)
-                        h->c.mcsel = get_bits1(&h->c.gb);
+                        h->c.mcsel = get_bits1(&h->gb);
                     else
                         h->c.mcsel = 0;
 
@@ -1238,8 +1238,8 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count)
                 h->c.first_slice_line = 0;
 
             if (h->c.pict_type == AV_PICTURE_TYPE_I) {
-                int ac_pred = get_bits1(&h->c.gb);
-                int cbpy    = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+                int ac_pred = get_bits1(&h->gb);
+                int cbpy    = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
                 if (cbpy < 0) {
                     av_log(h->c.avctx, AV_LOG_ERROR,
                            "cbpy corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1252,8 +1252,8 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count)
                 if (IS_INTRA(h->c.cur_pic.mb_type[xy])) {
                     int i;
                     int dir     = 0;
-                    int ac_pred = get_bits1(&h->c.gb);
-                    int cbpy    = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+                    int ac_pred = get_bits1(&h->gb);
+                    int cbpy    = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
 
                     if (cbpy < 0) {
                         av_log(h->c.avctx, AV_LOG_ERROR,
@@ -1262,7 +1262,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count)
                     }
 
                     if (h->c.cbp_table[xy] & 8)
-                        ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
+                        ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
                     h->c.cur_pic.qscale_table[xy] = h->c.qscale;
 
                     for (i = 0; i < 6; i++) {
@@ -1285,7 +1285,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count)
                     h->c.cur_pic.qscale_table[xy] = h->c.qscale;
                     h->c.cbp_table[xy]            = 0;
                 } else {
-                    int cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+                    int cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
 
                     if (cbpy < 0) {
                         av_log(h->c.avctx, AV_LOG_ERROR,
@@ -1294,7 +1294,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count)
                     }
 
                     if (h->c.cbp_table[xy] & 8)
-                        ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
+                        ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
                     h->c.cur_pic.qscale_table[xy] = h->c.qscale;
 
                     h->c.cbp_table[xy] &= 3;  // remove dquant
@@ -1338,18 +1338,18 @@ int ff_mpeg4_decode_partitions(H263DecContext *const h)
     h->c.mb_num_left = mb_num;
 
     if (h->c.pict_type == AV_PICTURE_TYPE_I) {
-        while (show_bits(&h->c.gb, 9) == 1)
-            skip_bits(&h->c.gb, 9);
-        if (get_bits(&h->c.gb, 19) != DC_MARKER) {
+        while (show_bits(&h->gb, 9) == 1)
+            skip_bits(&h->gb, 9);
+        if (get_bits(&h->gb, 19) != DC_MARKER) {
             av_log(h->c.avctx, AV_LOG_ERROR,
                    "marker missing after first I partition at %d %d\n",
                    h->c.mb_x, h->c.mb_y);
             return AVERROR_INVALIDDATA;
         }
     } else {
-        while (show_bits(&h->c.gb, 10) == 1)
-            skip_bits(&h->c.gb, 10);
-        if (get_bits(&h->c.gb, 17) != MOTION_MARKER) {
+        while (show_bits(&h->gb, 10) == 1)
+            skip_bits(&h->gb, 10);
+        if (get_bits(&h->gb, 17) != MOTION_MARKER) {
             av_log(h->c.avctx, AV_LOG_ERROR,
                    "marker missing after first P partition at %d %d\n",
                    h->c.mb_x, h->c.mb_y);
@@ -1463,52 +1463,52 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
         }
     }
     {
-        OPEN_READER(re, &h->c.gb);
+        OPEN_READER(re, &h->gb);
         for (;;) {
-            UPDATE_CACHE(re, &h->c.gb);
-            GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 0);
+            UPDATE_CACHE(re, &h->gb);
+            GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
             if (level == 0) {
                 /* escape */
                 if (rvlc) {
-                    if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
+                    if (SHOW_UBITS(re, &h->gb, 1) == 0) {
                         av_log(h->c.avctx, AV_LOG_ERROR,
                                "1. marker bit missing in rvlc esc\n");
                         return AVERROR_INVALIDDATA;
                     }
-                    SKIP_CACHE(re, &h->c.gb, 1);
+                    SKIP_CACHE(re, &h->gb, 1);
 
-                    last = SHOW_UBITS(re, &h->c.gb, 1);
-                    SKIP_CACHE(re, &h->c.gb, 1);
-                    run = SHOW_UBITS(re, &h->c.gb, 6);
-                    SKIP_COUNTER(re, &h->c.gb, 1 + 1 + 6);
-                    UPDATE_CACHE(re, &h->c.gb);
+                    last = SHOW_UBITS(re, &h->gb, 1);
+                    SKIP_CACHE(re, &h->gb, 1);
+                    run = SHOW_UBITS(re, &h->gb, 6);
+                    SKIP_COUNTER(re, &h->gb, 1 + 1 + 6);
+                    UPDATE_CACHE(re, &h->gb);
 
-                    if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
+                    if (SHOW_UBITS(re, &h->gb, 1) == 0) {
                         av_log(h->c.avctx, AV_LOG_ERROR,
                                "2. marker bit missing in rvlc esc\n");
                         return AVERROR_INVALIDDATA;
                     }
-                    SKIP_CACHE(re, &h->c.gb, 1);
+                    SKIP_CACHE(re, &h->gb, 1);
 
-                    level = SHOW_UBITS(re, &h->c.gb, 11);
-                    SKIP_CACHE(re, &h->c.gb, 11);
+                    level = SHOW_UBITS(re, &h->gb, 11);
+                    SKIP_CACHE(re, &h->gb, 11);
 
-                    if (SHOW_UBITS(re, &h->c.gb, 5) != 0x10) {
+                    if (SHOW_UBITS(re, &h->gb, 5) != 0x10) {
                         av_log(h->c.avctx, AV_LOG_ERROR, "reverse esc missing\n");
                         return AVERROR_INVALIDDATA;
                     }
-                    SKIP_CACHE(re, &h->c.gb, 5);
+                    SKIP_CACHE(re, &h->gb, 5);
 
                     level = level * qmul + qadd;
-                    level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                    SKIP_COUNTER(re, &h->c.gb, 1 + 11 + 5 + 1);
+                    level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                    SKIP_COUNTER(re, &h->gb, 1 + 11 + 5 + 1);
 
                     i += run + 1;
                     if (last)
                         i += 192;
                 } else {
                     int cache;
-                    cache = GET_CACHE(re, &h->c.gb);
+                    cache = GET_CACHE(re, &h->gb);
 
                     if (IS_3IV1)
                         cache ^= 0xC0000000;
@@ -1516,36 +1516,36 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
                     if (cache & 0x80000000) {
                         if (cache & 0x40000000) {
                             /* third escape */
-                            SKIP_CACHE(re, &h->c.gb, 2);
-                            last = SHOW_UBITS(re, &h->c.gb, 1);
-                            SKIP_CACHE(re, &h->c.gb, 1);
-                            run = SHOW_UBITS(re, &h->c.gb, 6);
-                            SKIP_COUNTER(re, &h->c.gb, 2 + 1 + 6);
-                            UPDATE_CACHE(re, &h->c.gb);
+                            SKIP_CACHE(re, &h->gb, 2);
+                            last = SHOW_UBITS(re, &h->gb, 1);
+                            SKIP_CACHE(re, &h->gb, 1);
+                            run = SHOW_UBITS(re, &h->gb, 6);
+                            SKIP_COUNTER(re, &h->gb, 2 + 1 + 6);
+                            UPDATE_CACHE(re, &h->gb);
 
                             if (IS_3IV1) {
-                                level = SHOW_SBITS(re, &h->c.gb, 12);
-                                LAST_SKIP_BITS(re, &h->c.gb, 12);
+                                level = SHOW_SBITS(re, &h->gb, 12);
+                                LAST_SKIP_BITS(re, &h->gb, 12);
                             } else {
-                                if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
+                                if (SHOW_UBITS(re, &h->gb, 1) == 0) {
                                     av_log(h->c.avctx, AV_LOG_ERROR,
                                            "1. marker bit missing in 3. esc\n");
-                                    if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->c.gb) <= 0)
+                                    if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->gb) <= 0)
                                         return AVERROR_INVALIDDATA;
                                 }
-                                SKIP_CACHE(re, &h->c.gb, 1);
+                                SKIP_CACHE(re, &h->gb, 1);
 
-                                level = SHOW_SBITS(re, &h->c.gb, 12);
-                                SKIP_CACHE(re, &h->c.gb, 12);
+                                level = SHOW_SBITS(re, &h->gb, 12);
+                                SKIP_CACHE(re, &h->gb, 12);
 
-                                if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
+                                if (SHOW_UBITS(re, &h->gb, 1) == 0) {
                                     av_log(h->c.avctx, AV_LOG_ERROR,
                                            "2. marker bit missing in 3. esc\n");
-                                    if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->c.gb) <= 0)
+                                    if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->gb) <= 0)
                                         return AVERROR_INVALIDDATA;
                                 }
 
-                                SKIP_COUNTER(re, &h->c.gb, 1 + 12 + 1);
+                                SKIP_COUNTER(re, &h->gb, 1 + 12 + 1);
                             }
 
 #if 0
@@ -1592,26 +1592,26 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
                                 i += 192;
                         } else {
                             /* second escape */
-                            SKIP_BITS(re, &h->c.gb, 2);
-                            GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
+                            SKIP_BITS(re, &h->gb, 2);
+                            GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
                             i    += run + rl->max_run[run >> 7][level / qmul] + 1;  // FIXME opt indexing
-                            level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                            LAST_SKIP_BITS(re, &h->c.gb, 1);
+                            level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                            LAST_SKIP_BITS(re, &h->gb, 1);
                         }
                     } else {
                         /* first escape */
-                        SKIP_BITS(re, &h->c.gb, 1);
-                        GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
+                        SKIP_BITS(re, &h->gb, 1);
+                        GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
                         i    += run;
                         level = level + rl->max_level[run >> 7][(run - 1) & 63] * qmul;  // FIXME opt indexing
-                        level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                        LAST_SKIP_BITS(re, &h->c.gb, 1);
+                        level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                        LAST_SKIP_BITS(re, &h->gb, 1);
                     }
                 }
             } else {
                 i    += run;
-                level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                LAST_SKIP_BITS(re, &h->c.gb, 1);
+                level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                LAST_SKIP_BITS(re, &h->gb, 1);
             }
             ff_tlog(h->c.avctx, "dct[%d][%d] = %- 4d end?:%d\n", scan_table[i&63]&7, scan_table[i&63] >> 3, level, i>62);
             if (i > 62) {
@@ -1628,7 +1628,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
 
             block[scan_table[i]] = level;
         }
-        CLOSE_READER(re, &h->c.gb);
+        CLOSE_READER(re, &h->gb);
     }
 
 not_coded:
@@ -1751,7 +1751,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
     if (h->c.pict_type == AV_PICTURE_TYPE_P ||
         h->c.pict_type == AV_PICTURE_TYPE_S) {
         do {
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 /* skip mb */
                 h->c.mb_intra = 0;
                 for (i = 0; i < 6; i++)
@@ -1780,7 +1780,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
                 }
                 goto end;
             }
-            cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
+            cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
             if (cbpc < 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR,
                        "mcbpc damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1796,10 +1796,10 @@ static int mpeg4_decode_mb(H263DecContext *const h)
 
         if (h->c.pict_type == AV_PICTURE_TYPE_S &&
             ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0)
-            h->c.mcsel = get_bits1(&h->c.gb);
+            h->c.mcsel = get_bits1(&h->gb);
         else
             h->c.mcsel = 0;
-        cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F;
+        cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F;
         if (cbpy < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR,
                    "P cbpy damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1808,10 +1808,10 @@ static int mpeg4_decode_mb(H263DecContext *const h)
 
         cbp = (cbpc & 3) | (cbpy << 2);
         if (dquant)
-            ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
+            ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
         if ((!h->c.progressive_sequence) &&
             (cbp || (h->c.workaround_bugs & FF_BUG_XVID_ILACE)))
-            h->c.interlaced_dct = get_bits1(&h->c.gb);
+            h->c.interlaced_dct = get_bits1(&h->gb);
 
         h->c.mv_dir = MV_DIR_FORWARD;
         if ((cbpc & 16) == 0) {
@@ -1824,14 +1824,14 @@ static int mpeg4_decode_mb(H263DecContext *const h)
                 my             = get_amv(ctx, 1);
                 h->c.mv[0][0][0] = mx;
                 h->c.mv[0][0][1] = my;
-            } else if ((!h->c.progressive_sequence) && get_bits1(&h->c.gb)) {
+            } else if ((!h->c.progressive_sequence) && get_bits1(&h->gb)) {
                 h->c.cur_pic.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_FORWARD_MV |
                                                  MB_TYPE_INTERLACED;
                 /* 16x8 field motion prediction */
                 h->c.mv_type = MV_TYPE_FIELD;
 
-                h->c.field_select[0][0] = get_bits1(&h->c.gb);
-                h->c.field_select[0][1] = get_bits1(&h->c.gb);
+                h->c.field_select[0][0] = get_bits1(&h->gb);
+                h->c.field_select[0][1] = get_bits1(&h->gb);
 
                 ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
 
@@ -1921,14 +1921,14 @@ static int mpeg4_decode_mb(H263DecContext *const h)
             goto end;
         }
 
-        modb1 = get_bits1(&h->c.gb);
+        modb1 = get_bits1(&h->gb);
         if (modb1) {
             // like MB_TYPE_B_DIRECT but no vectors coded
             mb_type = MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_BIDIR_MV;
             cbp     = 0;
         } else {
-            modb2   = get_bits1(&h->c.gb);
-            mb_type = get_vlc2(&h->c.gb, mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 1);
+            modb2   = get_bits1(&h->gb);
+            mb_type = get_vlc2(&h->gb, mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 1);
             if (mb_type < 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "illegal MB_type\n");
                 return AVERROR_INVALIDDATA;
@@ -1937,29 +1937,29 @@ static int mpeg4_decode_mb(H263DecContext *const h)
                 cbp = 0;
             } else {
                 h->c.bdsp.clear_blocks(h->block[0]);
-                cbp = get_bits(&h->c.gb, 6);
+                cbp = get_bits(&h->gb, 6);
             }
 
             if ((!IS_DIRECT(mb_type)) && cbp) {
-                if (get_bits1(&h->c.gb))
-                    ff_set_qscale(&h->c, h->c.qscale + get_bits1(&h->c.gb) * 4 - 2);
+                if (get_bits1(&h->gb))
+                    ff_set_qscale(&h->c, h->c.qscale + get_bits1(&h->gb) * 4 - 2);
             }
 
             if (!h->c.progressive_sequence) {
                 if (cbp)
-                    h->c.interlaced_dct = get_bits1(&h->c.gb);
+                    h->c.interlaced_dct = get_bits1(&h->gb);
 
-                if (!IS_DIRECT(mb_type) && get_bits1(&h->c.gb)) {
+                if (!IS_DIRECT(mb_type) && get_bits1(&h->gb)) {
                     mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
                     mb_type &= ~MB_TYPE_16x16;
 
                     if (HAS_FORWARD_MV(mb_type)) {
-                        h->c.field_select[0][0] = get_bits1(&h->c.gb);
-                        h->c.field_select[0][1] = get_bits1(&h->c.gb);
+                        h->c.field_select[0][0] = get_bits1(&h->gb);
+                        h->c.field_select[0][1] = get_bits1(&h->gb);
                     }
                     if (HAS_BACKWARD_MV(mb_type)) {
-                        h->c.field_select[1][0] = get_bits1(&h->c.gb);
-                        h->c.field_select[1][1] = get_bits1(&h->c.gb);
+                        h->c.field_select[1][0] = get_bits1(&h->gb);
+                        h->c.field_select[1][1] = get_bits1(&h->gb);
                     }
                 }
             }
@@ -2039,7 +2039,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
         int use_intra_dc_vlc;
 
         do {
-            cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
+            cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
             if (cbpc < 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR,
                        "I cbpc damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -2051,13 +2051,13 @@ static int mpeg4_decode_mb(H263DecContext *const h)
         h->c.mb_intra = 1;
 
 intra:
-        h->c.ac_pred = get_bits1(&h->c.gb);
+        h->c.ac_pred = get_bits1(&h->gb);
         if (h->c.ac_pred)
             h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
         else
             h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
 
-        cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+        cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
         if (cbpy < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR,
                    "I cbpy damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -2068,10 +2068,10 @@ intra:
         use_intra_dc_vlc = h->c.qscale < ctx->intra_dc_threshold;
 
         if (dquant)
-            ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
+            ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
 
         if (!h->c.progressive_sequence)
-            h->c.interlaced_dct = get_bits1(&h->c.gb);
+            h->c.interlaced_dct = get_bits1(&h->gb);
 
         h->c.bdsp.clear_blocks(h->block[0]);
         /* decode each block */
@@ -2173,24 +2173,24 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6
 
     if (n < 4) {
         cc = 0;
-        dct_dc_size = get_vlc2(&h->c.gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
+        dct_dc_size = get_vlc2(&h->gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
         quant_matrix = h->c.intra_matrix;
     } else {
         cc = (n & 1) + 1;
         if (ctx->rgb)
-            dct_dc_size = get_vlc2(&h->c.gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
+            dct_dc_size = get_vlc2(&h->gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
         else
-            dct_dc_size = get_vlc2(&h->c.gb, studio_chroma_dc, STUDIO_INTRA_BITS, 2);
+            dct_dc_size = get_vlc2(&h->gb, studio_chroma_dc, STUDIO_INTRA_BITS, 2);
         quant_matrix = h->c.chroma_intra_matrix;
     }
 
     if (dct_dc_size == 0) {
         dct_diff = 0;
     } else {
-        dct_diff = get_xbits(&h->c.gb, dct_dc_size);
+        dct_diff = get_xbits(&h->gb, dct_dc_size);
 
         if (dct_dc_size > 8) {
-            if(!check_marker(h->c.avctx, &h->c.gb, "dct_dc_size > 8"))
+            if(!check_marker(h->c.avctx, &h->gb, "dct_dc_size > 8"))
                 return AVERROR_INVALIDDATA;
         }
 
@@ -2209,7 +2209,7 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6
 
     /* AC Coefficients */
     while (1) {
-        group = get_vlc2(&h->c.gb, cur_vlc, STUDIO_INTRA_BITS, 2);
+        group = get_vlc2(&h->gb, cur_vlc, STUDIO_INTRA_BITS, 2);
 
         if (group < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "illegal ac coefficient group vlc\n");
@@ -2226,12 +2226,12 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6
             /* Zero run length (Table B.47) */
             run = 1 << additional_code_len;
             if (additional_code_len)
-                run += get_bits(&h->c.gb, additional_code_len);
+                run += get_bits(&h->gb, additional_code_len);
             idx += run;
             continue;
         } else if (group >= 7 && group <= 12) {
             /* Zero run length and +/-1 level (Table B.48) */
-            code = get_bits(&h->c.gb, additional_code_len);
+            code = get_bits(&h->gb, additional_code_len);
             sign = code & 1;
             code >>= 1;
             run = (1 << (additional_code_len - 1)) + code;
@@ -2245,14 +2245,14 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6
             if (idx > 63)
                 return AVERROR_INVALIDDATA;
             j = scantable[idx++];
-            block[j] = get_xbits(&h->c.gb, additional_code_len);
+            block[j] = get_xbits(&h->gb, additional_code_len);
         } else if (group == 21) {
             /* Escape */
             if (idx > 63)
                 return AVERROR_INVALIDDATA;
             j = scantable[idx++];
             additional_code_len = h->c.avctx->bits_per_raw_sample + ctx->dct_precision + 4;
-            flc = get_bits(&h->c.gb, additional_code_len);
+            flc = get_bits(&h->gb, additional_code_len);
             if (flc >> (additional_code_len-1))
                 block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1);
             else
@@ -2278,14 +2278,14 @@ static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx,
     height = 16 >> (n ? h->c.chroma_y_shift : 0);
     w = 16 >> (n ? h->c.chroma_x_shift : 0);
 
-    block_mean = get_bits(&h->c.gb, h->c.avctx->bits_per_raw_sample);
+    block_mean = get_bits(&h->gb, h->c.avctx->bits_per_raw_sample);
     if (block_mean == 0){
         av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden block_mean\n");
         return AVERROR_INVALIDDATA;
     }
     h->c.last_dc[n] = block_mean * (1 << (ctx->dct_precision + h->c.intra_dc_precision));
 
-    rice_parameter = get_bits(&h->c.gb, 4);
+    rice_parameter = get_bits(&h->gb, 4);
     if (rice_parameter == 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden rice_parameter\n");
         return AVERROR_INVALIDDATA;
@@ -2307,17 +2307,17 @@ static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx,
             left = output;
             topleft = top;
 
-            rice_prefix_code = get_unary(&h->c.gb, 1, 12);
+            rice_prefix_code = get_unary(&h->gb, 1, 12);
 
             /* Escape */
             if (rice_prefix_code == 11)
-                dpcm_residual = get_bits(&h->c.gb, h->c.avctx->bits_per_raw_sample);
+                dpcm_residual = get_bits(&h->gb, h->c.avctx->bits_per_raw_sample);
             else {
                 if (rice_prefix_code == 12) {
                     av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden rice_prefix_code\n");
                     return AVERROR_INVALIDDATA;
                 }
-                rice_suffix_code = get_bitsz(&h->c.gb, rice_parameter);
+                rice_suffix_code = get_bitsz(&h->gb, rice_parameter);
                 dpcm_residual = (rice_prefix_code << rice_parameter) + rice_suffix_code;
             }
 
@@ -2363,12 +2363,12 @@ static int mpeg4_decode_studio_mb(H263DecContext *const h)
     /* StudioMacroblock */
     /* Assumes I-VOP */
     h->c.mb_intra = 1;
-    if (get_bits1(&h->c.gb)) { /* compression_mode */
+    if (get_bits1(&h->gb)) { /* compression_mode */
         /* DCT */
         /* macroblock_type, 1 or 2-bit VLC */
-        if (!get_bits1(&h->c.gb)) {
-            skip_bits1(&h->c.gb);
-            h->c.qscale = mpeg_get_qscale(&h->c);
+        if (!get_bits1(&h->gb)) {
+            skip_bits1(&h->gb);
+            h->c.qscale = mpeg_get_qscale(&h->gb, h->c.q_scale_type);
         }
 
         for (i = 0; i < mpeg4_block_count[h->c.chroma_format]; i++) {
@@ -2377,25 +2377,25 @@ static int mpeg4_decode_studio_mb(H263DecContext *const h)
         }
     } else {
         /* DPCM */
-        check_marker(h->c.avctx, &h->c.gb, "DPCM block start");
-        ctx->dpcm_direction = get_bits1(&h->c.gb) ? -1 : 1;
+        check_marker(h->c.avctx, &h->gb, "DPCM block start");
+        ctx->dpcm_direction = get_bits1(&h->gb) ? -1 : 1;
         for (i = 0; i < 3; i++) {
             if (mpeg4_decode_dpcm_macroblock(ctx, ctx->dpcm_macroblock[i], i) < 0)
                 return AVERROR_INVALIDDATA;
         }
     }
 
-    if (get_bits_left(&h->c.gb) >= 24 && show_bits(&h->c.gb, 23) == 0) {
-        next_start_code_studio(&h->c.gb);
+    if (get_bits_left(&h->gb) >= 24 && show_bits(&h->gb, 23) == 0) {
+        next_start_code_studio(&h->gb);
         return SLICE_END;
     }
 
     //vcon-stp9L1.bits (first frame)
-    if (get_bits_left(&h->c.gb) == 0)
+    if (get_bits_left(&h->gb) == 0)
         return SLICE_END;
 
     //vcon-stp2L1.bits, vcon-stp3L1.bits, vcon-stp6L1.bits, vcon-stp7L1.bits, vcon-stp8L1.bits, vcon-stp10L1.bits (first frame)
-    if (get_bits_left(&h->c.gb) < 8U && show_bits(&h->c.gb, get_bits_left(&h->c.gb)) == 0)
+    if (get_bits_left(&h->gb) < 8U && show_bits(&h->gb, get_bits_left(&h->gb)) == 0)
         return SLICE_END;
 
     return SLICE_OK;
@@ -3743,9 +3743,9 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h)
     h->c.skipped_last_frame = 0;
 
     if (ctx->bitstream_buffer) {
-        int buf_size = get_bits_left(&h->c.gb) / 8U;
+        int buf_size = get_bits_left(&h->gb) / 8U;
         int bitstream_buffer_size = ctx->bitstream_buffer->size;
-        const uint8_t *buf = h->c.gb.buffer;
+        const uint8_t *buf = h->gb.buffer;
 
         if (h->c.divx_packed) {
             for (int i = 0; i < buf_size - 3; i++) {
@@ -3760,7 +3760,7 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h)
         }
         ctx->bitstream_buffer->size = 0;
         if (bitstream_buffer_size && (h->c.divx_packed || buf_size <= MAX_NVOP_SIZE)) {// divx 5.01+/xvid frame reorder
-            int ret = init_get_bits8(&h->c.gb, ctx->bitstream_buffer->data,
+            int ret = init_get_bits8(&h->gb, ctx->bitstream_buffer->data,
                                      bitstream_buffer_size);
             if (ret < 0)
                 return ret;
@@ -3768,7 +3768,7 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h)
             av_buffer_unref(&ctx->bitstream_buffer);
     }
 
-    return ff_mpeg4_parse_picture_header(ctx, &h->c.gb, 0, 0);
+    return ff_mpeg4_parse_picture_header(ctx, &h->gb, 0, 0);
 }
 
 int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt)
@@ -3781,7 +3781,7 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt)
 
     /* divx 5.01+ bitstream reorder stuff */
     if (h->c.divx_packed) {
-        int current_pos     = ctx->bitstream_buffer && h->c.gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->c.gb) >> 3);
+        int current_pos     = ctx->bitstream_buffer && h->gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->gb) >> 3);
         int startcode_found = 0;
         uint8_t *buf = pkt->data;
         int buf_size = pkt->size;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index f76158040d..8b94cc1ff0 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -219,7 +219,6 @@ typedef struct MpegEncContext {
     /* error concealment / resync */
     int resync_mb_x;                 ///< x position of last resync marker
     int resync_mb_y;                 ///< y position of last resync marker
-    GetBitContext last_resync_gb;    ///< used to search for the next resync marker
     int mb_num_left;                 ///< number of MBs left in this video packet (for partitioned Slices only)
 
     /* H.263 specific */
diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h
index 5b2a38d1c8..16b3eb1b17 100644
--- a/libavcodec/mpegvideodec.h
+++ b/libavcodec/mpegvideodec.h
@@ -77,10 +77,10 @@ int ff_mpv_decode_close(AVCodecContext *avctx);
 
 void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict);
 
-static inline int mpeg_get_qscale(MpegEncContext *s)
+static inline int mpeg_get_qscale(GetBitContext *const gb, int q_scale_type)
 {
-    int qscale = get_bits(&s->gb, 5);
-    if (s->q_scale_type)
+    int qscale = get_bits(gb, 5);
+    if (q_scale_type)
         return ff_mpeg2_non_linear_qscale[qscale];
     else
         return qscale << 1;
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 06f6367a38..36243e14c9 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -78,7 +78,7 @@ static int msmpeg4v2_decode_motion(H263DecContext *const h, int pred, int f_code
 {
     int code, val, sign, shift;
 
-    code = get_vlc2(&h->c.gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
+    code = get_vlc2(&h->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
     ff_dlog(h->c.avctx, "MV code %d at %d %d pred: %d\n",
             code, h->c.mb_x,h->c.mb_y, pred);
     if (code < 0)
@@ -86,12 +86,12 @@ static int msmpeg4v2_decode_motion(H263DecContext *const h, int pred, int f_code
 
     if (code == 0)
         return pred;
-    sign = get_bits1(&h->c.gb);
+    sign = get_bits1(&h->gb);
     shift = f_code - 1;
     val = code;
     if (shift) {
         val = (val - 1) << shift;
-        val |= get_bits(&h->c.gb, shift);
+        val |= get_bits(&h->gb, shift);
         val++;
     }
     if (sign)
@@ -114,7 +114,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
 
     if (h->c.pict_type == AV_PICTURE_TYPE_P) {
         if (ms->use_skip_mb_code) {
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 /* skip mb */
                 h->c.mb_intra = 0;
                 for(i=0;i<6;i++)
@@ -130,9 +130,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
         }
 
         if (h->c.msmpeg4_version == MSMP4_V2)
-            code = get_vlc2(&h->c.gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
+            code = get_vlc2(&h->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
         else
-            code = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
+            code = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
         if(code<0 || code>7){
             av_log(h->c.avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n",
                    code, h->c.mb_x, h->c.mb_y);
@@ -145,9 +145,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
     } else {
         h->c.mb_intra = 1;
         if (h->c.msmpeg4_version == MSMP4_V2)
-            cbp = get_vlc2(&h->c.gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
+            cbp = get_vlc2(&h->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
         else
-            cbp = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
+            cbp = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
         if(cbp<0 || cbp>3){
             av_log(h->c.avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n",
                    cbp, h->c.mb_x, h->c.mb_y);
@@ -158,7 +158,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
     if (!h->c.mb_intra) {
         int mx, my, cbpy;
 
-        cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+        cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
         if(cbpy<0){
             av_log(h->c.avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n",
                    cbp, h->c.mb_x, h->c.mb_y);
@@ -181,8 +181,8 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
     } else {
         int v;
         if (h->c.msmpeg4_version == MSMP4_V2) {
-            h->c.ac_pred = get_bits1(&h->c.gb);
-            v = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+            h->c.ac_pred = get_bits1(&h->gb);
+            v = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
             if (v < 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
                 return -1;
@@ -190,7 +190,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h)
             cbp|= v<<2;
         } else{
             h->c.ac_pred = 0;
-            v = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
+            v = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
             if (v < 0) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
                 return -1;
@@ -220,12 +220,12 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h)
     uint8_t *coded_val;
     uint32_t * const mb_type_ptr = &h->c.cur_pic.mb_type[h->c.mb_x + h->c.mb_y*h->c.mb_stride];
 
-    if (get_bits_left(&h->c.gb) <= 0)
+    if (get_bits_left(&h->gb) <= 0)
         return AVERROR_INVALIDDATA;
 
     if (h->c.pict_type == AV_PICTURE_TYPE_P) {
         if (ms->use_skip_mb_code) {
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 /* skip mb */
                 h->c.mb_intra = 0;
                 for(i=0;i<6;i++)
@@ -241,14 +241,14 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h)
             }
         }
 
-        code = get_vlc2(&h->c.gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX], MB_NON_INTRA_VLC_BITS, 3);
+        code = get_vlc2(&h->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX], MB_NON_INTRA_VLC_BITS, 3);
         //h->c.mb_intra = (code & 0x40) ? 0 : 1;
         h->c.mb_intra = (~code & 0x40) >> 6;
 
         cbp = code & 0x3f;
     } else {
         h->c.mb_intra = 1;
-        code = get_vlc2(&h->c.gb, ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 2);
+        code = get_vlc2(&h->gb, ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 2);
         /* predict coded block pattern */
         cbp = 0;
         for(i=0;i<6;i++) {
@@ -265,7 +265,7 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h)
     if (!h->c.mb_intra) {
         int mx, my;
         if (ms->per_mb_rl_table && cbp) {
-            ms->rl_table_index = decode012(&h->c.gb);
+            ms->rl_table_index = decode012(&h->gb);
             ms->rl_chroma_table_index = ms->rl_table_index;
         }
         ff_h263_pred_motion(&h->c, 0, 0, &mx, &my);
@@ -278,16 +278,16 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h)
     } else {
         ff_dlog(h->c.avctx, "I at %d %d %d %06X\n", h->c.mb_x, h->c.mb_y,
                 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
-                show_bits(&h->c.gb, 24));
-        h->c.ac_pred = get_bits1(&h->c.gb);
+                show_bits(&h->gb, 24));
+        h->c.ac_pred = get_bits1(&h->gb);
         *mb_type_ptr = MB_TYPE_INTRA;
         if (h->c.inter_intra_pred) {
-            h->c.h263_aic_dir = get_vlc2(&h->c.gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
+            h->c.h263_aic_dir = get_vlc2(&h->gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
             ff_dlog(h->c.avctx, "%d%d %d %d/",
                     h->c.ac_pred, h->c.h263_aic_dir, h->c.mb_x, h->c.mb_y);
         }
         if (ms->per_mb_rl_table && cbp) {
-            ms->rl_table_index = decode012(&h->c.gb);
+            ms->rl_table_index = decode012(&h->gb);
             ms->rl_chroma_table_index = ms->rl_table_index;
         }
     }
@@ -409,33 +409,33 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
     // smallest "black/skip" frame generally contain not much recoverable content
     // while at the same time they have the highest computational requirements
     // per byte
-    if (get_bits_left(&h->c.gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
+    if (get_bits_left(&h->gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
         return AVERROR_INVALIDDATA;
 
     if (h->c.msmpeg4_version == MSMP4_V1) {
-        int start_code = get_bits_long(&h->c.gb, 32);
+        int start_code = get_bits_long(&h->gb, 32);
         if(start_code!=0x00000100){
             av_log(h->c.avctx, AV_LOG_ERROR, "invalid startcode\n");
             return -1;
         }
 
-        skip_bits(&h->c.gb, 5); // frame number */
+        skip_bits(&h->gb, 5); // frame number */
     }
 
-    h->c.pict_type = get_bits(&h->c.gb, 2) + 1;
+    h->c.pict_type = get_bits(&h->gb, 2) + 1;
     if (h->c.pict_type != AV_PICTURE_TYPE_I &&
         h->c.pict_type != AV_PICTURE_TYPE_P){
         av_log(h->c.avctx, AV_LOG_ERROR, "invalid picture type\n");
         return -1;
     }
-    h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
+    h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
     if (h->c.qscale == 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "invalid qscale\n");
         return -1;
     }
 
     if (h->c.pict_type == AV_PICTURE_TYPE_I) {
-        code = get_bits(&h->c.gb, 5);
+        code = get_bits(&h->gb, 5);
         if (h->c.msmpeg4_version == MSMP4_V1) {
             if(code==0 || code>h->c.mb_height) {
                 av_log(h->c.avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
@@ -462,25 +462,25 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
             ms->dc_table_index = 0; //not used
             break;
         case MSMP4_V3:
-            ms->rl_chroma_table_index = decode012(&h->c.gb);
-            ms->rl_table_index = decode012(&h->c.gb);
+            ms->rl_chroma_table_index = decode012(&h->gb);
+            ms->rl_table_index        = decode012(&h->gb);
 
-            ms->dc_table_index = get_bits1(&h->c.gb);
+            ms->dc_table_index = get_bits1(&h->gb);
             break;
         case MSMP4_WMV1:
             ff_msmpeg4_decode_ext_header(h, (2+5+5+17+7)/8);
 
             if (ms->bit_rate > MBAC_BITRATE)
-                ms->per_mb_rl_table = get_bits1(&h->c.gb);
+                ms->per_mb_rl_table = get_bits1(&h->gb);
             else
                 ms->per_mb_rl_table = 0;
 
             if (!ms->per_mb_rl_table) {
-                ms->rl_chroma_table_index = decode012(&h->c.gb);
-                ms->rl_table_index        = decode012(&h->c.gb);
+                ms->rl_chroma_table_index = decode012(&h->gb);
+                ms->rl_table_index        = decode012(&h->gb);
             }
 
-            ms->dc_table_index = get_bits1(&h->c.gb);
+            ms->dc_table_index = get_bits1(&h->gb);
             h->c.inter_intra_pred= 0;
             break;
         default:
@@ -502,37 +502,37 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
             if (h->c.msmpeg4_version == MSMP4_V1)
                 ms->use_skip_mb_code = 1;
             else
-                ms->use_skip_mb_code = get_bits1(&h->c.gb);
+                ms->use_skip_mb_code = get_bits1(&h->gb);
             ms->rl_table_index = 2;
             ms->rl_chroma_table_index = ms->rl_table_index;
             ms->dc_table_index = 0; //not used
             ms->mv_table_index = 0;
             break;
         case MSMP4_V3:
-            ms->use_skip_mb_code = get_bits1(&h->c.gb);
-            ms->rl_table_index   = decode012(&h->c.gb);
+            ms->use_skip_mb_code = get_bits1(&h->gb);
+            ms->rl_table_index   = decode012(&h->gb);
             ms->rl_chroma_table_index = ms->rl_table_index;
 
-            ms->dc_table_index = get_bits1(&h->c.gb);
+            ms->dc_table_index = get_bits1(&h->gb);
 
-            ms->mv_table_index = get_bits1(&h->c.gb);
+            ms->mv_table_index = get_bits1(&h->gb);
             break;
         case MSMP4_WMV1:
-            ms->use_skip_mb_code = get_bits1(&h->c.gb);
+            ms->use_skip_mb_code = get_bits1(&h->gb);
 
             if (ms->bit_rate > MBAC_BITRATE)
-                ms->per_mb_rl_table = get_bits1(&h->c.gb);
+                ms->per_mb_rl_table = get_bits1(&h->gb);
             else
                 ms->per_mb_rl_table = 0;
 
             if (!ms->per_mb_rl_table) {
-                ms->rl_table_index = decode012(&h->c.gb);
+                ms->rl_table_index = decode012(&h->gb);
                 ms->rl_chroma_table_index = ms->rl_table_index;
             }
 
-            ms->dc_table_index = get_bits1(&h->c.gb);
+            ms->dc_table_index = get_bits1(&h->gb);
 
-            ms->mv_table_index = get_bits1(&h->c.gb);
+            ms->mv_table_index = get_bits1(&h->gb);
             h->c.inter_intra_pred = h->c.width*h->c.height < 320*240 &&
                                   ms->bit_rate <= II_BITRATE;
             break;
@@ -568,15 +568,15 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
 int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size)
 {
     MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
-    int left= buf_size*8 - get_bits_count(&h->c.gb);
+    int left = buf_size*8 - get_bits_count(&h->gb);
     int length = h->c.msmpeg4_version >= MSMP4_V3 ? 17 : 16;
     /* the alt_bitstream reader could read over the end so we need to check it */
     if(left>=length && left<length+8)
     {
-        skip_bits(&h->c.gb, 5); /* fps */
-        ms->bit_rate = get_bits(&h->c.gb, 11) * 1024;
+        skip_bits(&h->gb, 5); /* fps */
+        ms->bit_rate = get_bits(&h->gb, 11) * 1024;
         if (h->c.msmpeg4_version >= MSMP4_V3)
-            ms->flipflop_rounding = get_bits1(&h->c.gb);
+            ms->flipflop_rounding = get_bits1(&h->gb);
         else
             ms->flipflop_rounding = 0;
     }
@@ -601,9 +601,9 @@ static int msmpeg4_decode_dc(MSMP4DecContext *const ms, int n, int *dir_ptr)
 
     if (h->c.msmpeg4_version <= MSMP4_V2) {
         if (n < 4) {
-            level = get_vlc2(&h->c.gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
+            level = get_vlc2(&h->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
         } else {
-            level = get_vlc2(&h->c.gb, v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 3);
+            level = get_vlc2(&h->gb, v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 3);
         }
         if (level < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc vlc\n");
@@ -612,15 +612,15 @@ static int msmpeg4_decode_dc(MSMP4DecContext *const ms, int n, int *dir_ptr)
         }
         level-=256;
     } else {
-        level = get_vlc2(&h->c.gb, ff_msmp4_dc_vlc[ms->dc_table_index][n >= 4],
+        level = get_vlc2(&h->gb, ff_msmp4_dc_vlc[ms->dc_table_index][n >= 4],
                          MSMP4_DC_VLC_BITS, 3);
 
         if (level == DC_MAX) {
-            level = get_bits(&h->c.gb, 8);
-            if (get_bits1(&h->c.gb))
+            level = get_bits(&h->gb, 8);
+            if (get_bits1(&h->gb))
                 level = -level;
         } else if (level != 0) {
-            if (get_bits1(&h->c.gb))
+            if (get_bits1(&h->gb))
                 level = -level;
         }
     }
@@ -721,58 +721,58 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block,
         rl_vlc= rl->rl_vlc[h->c.qscale];
     }
   {
-    OPEN_READER(re, &h->c.gb);
+    OPEN_READER(re, &h->gb);
     for(;;) {
-        UPDATE_CACHE(re, &h->c.gb);
-        GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 0);
+        UPDATE_CACHE(re, &h->gb);
+        GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
         if (level==0) {
             int cache;
-            cache= GET_CACHE(re, &h->c.gb);
+            cache= GET_CACHE(re, &h->gb);
             /* escape */
             if (h->c.msmpeg4_version == MSMP4_V1 || (cache&0x80000000)==0) {
                 if (h->c.msmpeg4_version == MSMP4_V1 || (cache&0x40000000)==0) {
                     /* third escape */
                     if (h->c.msmpeg4_version != MSMP4_V1)
-                        LAST_SKIP_BITS(re, &h->c.gb, 2);
-                    UPDATE_CACHE(re, &h->c.gb);
+                        LAST_SKIP_BITS(re, &h->gb, 2);
+                    UPDATE_CACHE(re, &h->gb);
                     if (h->c.msmpeg4_version <= MSMP4_V3) {
-                        last  = SHOW_UBITS(re, &h->c.gb, 1); SKIP_CACHE(re, &h->c.gb, 1);
-                        run   = SHOW_UBITS(re, &h->c.gb, 6); SKIP_CACHE(re, &h->c.gb, 6);
-                        level = SHOW_SBITS(re, &h->c.gb, 8);
-                        SKIP_COUNTER(re, &h->c.gb, 1 + 6 + 8);
+                        last  = SHOW_UBITS(re, &h->gb, 1); SKIP_CACHE(re, &h->gb, 1);
+                        run   = SHOW_UBITS(re, &h->gb, 6); SKIP_CACHE(re, &h->gb, 6);
+                        level = SHOW_SBITS(re, &h->gb, 8);
+                        SKIP_COUNTER(re, &h->gb, 1 + 6 + 8);
                     }else{
                         int sign;
-                        last = SHOW_UBITS(re, &h->c.gb, 1); SKIP_BITS(re, &h->c.gb, 1);
+                        last = SHOW_UBITS(re, &h->gb, 1); SKIP_BITS(re, &h->gb, 1);
                         if (!ms->esc3_level_length) {
                             int ll;
                             ff_dlog(h->c.avctx, "ESC-3 %X at %d %d\n",
-                                    show_bits(&h->c.gb, 24), h->c.mb_x, h->c.mb_y);
+                                    show_bits(&h->gb, 24), h->c.mb_x, h->c.mb_y);
                             if (h->c.qscale < 8) {
-                                ll = SHOW_UBITS(re, &h->c.gb, 3); SKIP_BITS(re, &h->c.gb, 3);
+                                ll = SHOW_UBITS(re, &h->gb, 3); SKIP_BITS(re, &h->gb, 3);
                                 if(ll==0){
-                                    ll = 8+SHOW_UBITS(re, &h->c.gb, 1); SKIP_BITS(re, &h->c.gb, 1);
+                                    ll = 8+SHOW_UBITS(re, &h->gb, 1); SKIP_BITS(re, &h->gb, 1);
                                 }
                             }else{
                                 ll=2;
-                                while (ll < 8 && SHOW_UBITS(re, &h->c.gb, 1) == 0) {
+                                while (ll < 8 && SHOW_UBITS(re, &h->gb, 1) == 0) {
                                     ll++;
-                                    SKIP_BITS(re, &h->c.gb, 1);
+                                    SKIP_BITS(re, &h->gb, 1);
                                 }
-                                if (ll<8) SKIP_BITS(re, &h->c.gb, 1);
+                                if (ll<8) SKIP_BITS(re, &h->gb, 1);
                             }
 
                             ms->esc3_level_length = ll;
-                            ms->esc3_run_length   = SHOW_UBITS(re, &h->c.gb, 2) + 3; SKIP_BITS(re, &h->c.gb, 2);
-                            UPDATE_CACHE(re, &h->c.gb);
+                            ms->esc3_run_length   = SHOW_UBITS(re, &h->gb, 2) + 3; SKIP_BITS(re, &h->gb, 2);
+                            UPDATE_CACHE(re, &h->gb);
                         }
-                        run   = SHOW_UBITS(re, &h->c.gb, ms->esc3_run_length);
-                        SKIP_BITS(re, &h->c.gb, ms->esc3_run_length);
+                        run   = SHOW_UBITS(re, &h->gb, ms->esc3_run_length);
+                        SKIP_BITS(re, &h->gb, ms->esc3_run_length);
 
-                        sign=  SHOW_UBITS(re, &h->c.gb, 1);
-                        SKIP_BITS(re, &h->c.gb, 1);
+                        sign=  SHOW_UBITS(re, &h->gb, 1);
+                        SKIP_BITS(re, &h->gb, 1);
 
-                        level = SHOW_UBITS(re, &h->c.gb, ms->esc3_level_length);
-                        SKIP_BITS(re, &h->c.gb, ms->esc3_level_length);
+                        level = SHOW_UBITS(re, &h->gb, ms->esc3_level_length);
+                        SKIP_BITS(re, &h->gb, ms->esc3_level_length);
                         if(sign) level= -level;
                     }
 
@@ -783,30 +783,30 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block,
                     if(last) i+=192;
                 } else {
                     /* second escape */
-                    SKIP_BITS(re, &h->c.gb, 2);
-                    GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
+                    SKIP_BITS(re, &h->gb, 2);
+                    GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
                     i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
-                    level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                    LAST_SKIP_BITS(re, &h->c.gb, 1);
+                    level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                    LAST_SKIP_BITS(re, &h->gb, 1);
                 }
             } else {
                 /* first escape */
-                SKIP_BITS(re, &h->c.gb, 1);
-                GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
+                SKIP_BITS(re, &h->gb, 1);
+                GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
                 i+= run;
                 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
-                level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-                LAST_SKIP_BITS(re, &h->c.gb, 1);
+                level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+                LAST_SKIP_BITS(re, &h->gb, 1);
             }
         } else {
             i+= run;
-            level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
-            LAST_SKIP_BITS(re, &h->c.gb, 1);
+            level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
+            LAST_SKIP_BITS(re, &h->gb, 1);
         }
         if (i > 62){
             i-= 192;
             if(i&(~63)){
-                const int left = get_bits_left(&h->c.gb);
+                const int left = get_bits_left(&h->gb);
                 if (((i + 192 == 64 && level / qmul == -1) ||
                      !(h->c.avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
                     left >= 0) {
@@ -827,7 +827,7 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block,
 
         block[scan_table[i]] = level;
     }
-    CLOSE_READER(re, &h->c.gb);
+    CLOSE_READER(re, &h->gb);
   }
     if (h->c.mb_intra) {
  not_coded:
@@ -844,14 +844,14 @@ void ff_msmpeg4_decode_motion(MSMP4DecContext *const ms, int *mx_ptr, int *my_pt
     H263DecContext *const h = &ms->h;
     int sym, mx, my;
 
-    sym = get_vlc2(&h->c.gb, mv_vlc, MV_VLC_BITS, 2);
+    sym = get_vlc2(&h->gb, mv_vlc, MV_VLC_BITS, 2);
     if (sym) {
         mx = sym >> 8;
         my = sym & 0xFF;
     } else {
         /* Escape */
-        mx = get_bits(&h->c.gb, 6);
-        my = get_bits(&h->c.gb, 6);
+        mx = get_bits(&h->gb, 6);
+        my = get_bits(&h->gb, 6);
     }
 
     mx += *mx_ptr - 32;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index c678851ded..01cdd1a9dc 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -85,9 +85,9 @@ int ff_rv_decode_dc(H263DecContext *const h, int n)
     int code;
 
     if (n < 4) {
-        code = get_vlc2(&h->c.gb, rv_dc_lum, DC_VLC_BITS, 2);
+        code = get_vlc2(&h->gb, rv_dc_lum, DC_VLC_BITS, 2);
     } else {
-        code = get_vlc2(&h->c.gb, rv_dc_chrom, DC_VLC_BITS, 2);
+        code = get_vlc2(&h->gb, rv_dc_chrom, DC_VLC_BITS, 2);
         if (code < 0) {
             av_log(h->c.avctx, AV_LOG_ERROR, "chroma dc error\n");
             return -1;
@@ -101,9 +101,9 @@ static int rv10_decode_picture_header(H263DecContext *const h)
 {
     int mb_count, pb_frame, marker, mb_xy;
 
-    marker = get_bits1(&h->c.gb);
+    marker = get_bits1(&h->gb);
 
-    if (get_bits1(&h->c.gb))
+    if (get_bits1(&h->gb))
         h->c.pict_type = AV_PICTURE_TYPE_P;
     else
         h->c.pict_type = AV_PICTURE_TYPE_I;
@@ -111,7 +111,7 @@ static int rv10_decode_picture_header(H263DecContext *const h)
     if (!marker)
         av_log(h->c.avctx, AV_LOG_ERROR, "marker missing\n");
 
-    pb_frame = get_bits1(&h->c.gb);
+    pb_frame = get_bits1(&h->gb);
 
     ff_dlog(h->c.avctx, "pict_type=%d pb_frame=%d\n", h->c.pict_type, pb_frame);
 
@@ -120,7 +120,7 @@ static int rv10_decode_picture_header(H263DecContext *const h)
         return AVERROR_PATCHWELCOME;
     }
 
-    h->c.qscale = get_bits(&h->c.gb, 5);
+    h->c.qscale = get_bits(&h->gb, 5);
     if (h->c.qscale == 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
         return AVERROR_INVALIDDATA;
@@ -129,9 +129,9 @@ static int rv10_decode_picture_header(H263DecContext *const h)
     if (h->c.pict_type == AV_PICTURE_TYPE_I) {
         if (h->c.rv10_version == 3) {
             /* specific MPEG like DC coding not used */
-            h->c.last_dc[0] = get_bits(&h->c.gb, 8);
-            h->c.last_dc[1] = get_bits(&h->c.gb, 8);
-            h->c.last_dc[2] = get_bits(&h->c.gb, 8);
+            h->c.last_dc[0] = get_bits(&h->gb, 8);
+            h->c.last_dc[1] = get_bits(&h->gb, 8);
+            h->c.last_dc[2] = get_bits(&h->gb, 8);
             ff_dlog(h->c.avctx, "DC:%d %d %d\n", h->c.last_dc[0],
                     h->c.last_dc[1], h->c.last_dc[2]);
         }
@@ -140,16 +140,16 @@ static int rv10_decode_picture_header(H263DecContext *const h)
      * to display the macroblocks is coded here */
 
     mb_xy = h->c.mb_x + h->c.mb_y * h->c.mb_width;
-    if (show_bits(&h->c.gb, 12) == 0 || (mb_xy && mb_xy < h->c.mb_num)) {
-        h->c.mb_x  = get_bits(&h->c.gb, 6); /* mb_x */
-        h->c.mb_y  = get_bits(&h->c.gb, 6); /* mb_y */
-        mb_count   = get_bits(&h->c.gb, 12);
+    if (show_bits(&h->gb, 12) == 0 || (mb_xy && mb_xy < h->c.mb_num)) {
+        h->c.mb_x  = get_bits(&h->gb, 6); /* mb_x */
+        h->c.mb_y  = get_bits(&h->gb, 6); /* mb_y */
+        mb_count   = get_bits(&h->gb, 12);
     } else {
         h->c.mb_x  = 0;
         h->c.mb_y  = 0;
         mb_count = h->c.mb_width * h->c.mb_height;
     }
-    skip_bits(&h->c.gb, 3);   /* ignored */
+    skip_bits(&h->gb, 3);   /* ignored */
 
     return mb_count;
 }
@@ -163,7 +163,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
     int seq, mb_pos, ret;
     int rpr_max;
 
-    h->c.pict_type = pict_types[get_bits(&h->c.gb, 2)];
+    h->c.pict_type = pict_types[get_bits(&h->gb, 2)];
 
     if (h->c.low_delay && h->c.pict_type == AV_PICTURE_TYPE_B) {
         av_log(h->c.avctx, AV_LOG_ERROR, "low delay B\n");
@@ -174,31 +174,31 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
         return AVERROR_INVALIDDATA;
     }
 
-    if (get_bits1(&h->c.gb)) {
+    if (get_bits1(&h->gb)) {
         av_log(h->c.avctx, AV_LOG_ERROR, "reserved bit set\n");
         return AVERROR_INVALIDDATA;
     }
 
-    h->c.qscale = get_bits(&h->c.gb, 5);
+    h->c.qscale = get_bits(&h->gb, 5);
     if (h->c.qscale == 0) {
         av_log(h->c.avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
         return AVERROR_INVALIDDATA;
     }
 
     if (RV_GET_MINOR_VER(rv->sub_id) >= 2)
-        h->c.loop_filter = get_bits1(&h->c.gb) && !h->c.avctx->lowres;
+        h->c.loop_filter = get_bits1(&h->gb) && !h->c.avctx->lowres;
 
     if (RV_GET_MINOR_VER(rv->sub_id) <= 1)
-        seq = get_bits(&h->c.gb, 8) << 7;
+        seq = get_bits(&h->gb, 8) << 7;
     else
-        seq = get_bits(&h->c.gb, 13) << 2;
+        seq = get_bits(&h->gb, 13) << 2;
 
     rpr_max = h->c.avctx->extradata[1] & 7;
     if (rpr_max) {
         int f, new_w, new_h;
         int rpr_bits = av_log2(rpr_max) + 1;
 
-        f = get_bits(&h->c.gb, rpr_bits);
+        f = get_bits(&h->gb, rpr_bits);
 
         if (f) {
             if (h->c.avctx->extradata_size < 8 + 2 * f) {
@@ -277,11 +277,11 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
         ff_mpeg4_init_direct_mv(&h->c);
     }
 
-    h->c.no_rounding = get_bits1(&h->c.gb);
+    h->c.no_rounding = get_bits1(&h->gb);
 
     if (RV_GET_MINOR_VER(rv->sub_id) <= 1 && h->c.pict_type == AV_PICTURE_TYPE_B)
         // binary decoder reads 3+2 bits here but they don't seem to be used
-        skip_bits(&h->c.gb, 5);
+        skip_bits(&h->gb, 5);
 
     h->c.h263_aic        = h->c.pict_type == AV_PICTURE_TYPE_I;
     if (h->c.h263_aic) {
@@ -416,7 +416,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
     int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
 
     active_bits_size = buf_size * 8;
-    init_get_bits(&h->c.gb, buf, FFMAX(buf_size, buf_size2) * 8);
+    init_get_bits(&h->gb, buf, FFMAX(buf_size, buf_size2) * 8);
     if (h->c.codec_id == AV_CODEC_ID_RV10)
         mb_count = rv10_decode_picture_header(h);
     else
@@ -492,24 +492,24 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
 
         // Repeat the slice end check from ff_h263_decode_mb with our active
         // bitstream size
-        if (ret != SLICE_ERROR && active_bits_size >= get_bits_count(&h->c.gb)) {
-            int v = show_bits(&h->c.gb, 16);
+        if (ret != SLICE_ERROR && active_bits_size >= get_bits_count(&h->gb)) {
+            int v = show_bits(&h->gb, 16);
 
-            if (get_bits_count(&h->c.gb) + 16 > active_bits_size)
-                v >>= get_bits_count(&h->c.gb) + 16 - active_bits_size;
+            if (get_bits_count(&h->gb) + 16 > active_bits_size)
+                v >>= get_bits_count(&h->gb) + 16 - active_bits_size;
 
             if (!v)
                 ret = SLICE_END;
         }
-        if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&h->c.gb) &&
-            8 * buf_size2 >= get_bits_count(&h->c.gb)) {
+        if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&h->gb) &&
+            8 * buf_size2 >= get_bits_count(&h->gb)) {
             active_bits_size = buf_size2 * 8;
             av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n",
                    8 * buf_size, active_bits_size);
             ret = SLICE_OK;
         }
 
-        if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&h->c.gb)) {
+        if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&h->gb)) {
             av_log(h->c.avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", h->c.mb_x,
                    h->c.mb_y);
             return AVERROR_INVALIDDATA;
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index cc4f6d3345..20f96f791b 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -157,8 +157,8 @@ fail:
 
 static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
-    MpegEncContext *s = avctx->priv_data;
-    VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private;
+    H263DecContext *const h = avctx->priv_data;
+    VAAPIDecodePicture *pic = h->c.cur_pic.ptr->hwaccel_picture_private;
     VASliceParameterBufferMPEG4 slice_param;
     int err;
 
@@ -166,9 +166,9 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
         .slice_data_size   = size,
         .slice_data_offset = 0,
         .slice_data_flag   = VA_SLICE_DATA_FLAG_ALL,
-        .macroblock_offset = get_bits_count(&s->gb) % 8,
+        .macroblock_offset = get_bits_count(&h->gb) % 8,
         .macroblock_number = 0,
-        .quant_scale       = s->qscale,
+        .quant_scale       = h->c.qscale,
     };
 
     err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 4eb4d00383..4ceae05bdf 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -105,7 +105,7 @@ static int parse_mb_skip(WMV2DecContext *w)
     int coded_mb_count = 0;
     uint32_t *const mb_type = h->c.cur_pic.mb_type;
 
-    w->skip_type = get_bits(&h->c.gb, 2);
+    w->skip_type = get_bits(&h->gb, 2);
     switch (w->skip_type) {
     case SKIP_TYPE_NONE:
         for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
@@ -114,40 +114,40 @@ static int parse_mb_skip(WMV2DecContext *w)
                     MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
         break;
     case SKIP_TYPE_MPEG:
-        if (get_bits_left(&h->c.gb) < h->c.mb_height * h->c.mb_width)
+        if (get_bits_left(&h->gb) < h->c.mb_height * h->c.mb_width)
             return AVERROR_INVALIDDATA;
         for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
             for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
                 mb_type[mb_y * h->c.mb_stride + mb_x] =
-                    (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
+                    (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
         break;
     case SKIP_TYPE_ROW:
         for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++) {
-            if (get_bits_left(&h->c.gb) < 1)
+            if (get_bits_left(&h->gb) < 1)
                 return AVERROR_INVALIDDATA;
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
                     mb_type[mb_y * h->c.mb_stride + mb_x] =
                         MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
             } else {
                 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
                     mb_type[mb_y * h->c.mb_stride + mb_x] =
-                        (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
+                        (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
             }
         }
         break;
     case SKIP_TYPE_COL:
         for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++) {
-            if (get_bits_left(&h->c.gb) < 1)
+            if (get_bits_left(&h->gb) < 1)
                 return AVERROR_INVALIDDATA;
-            if (get_bits1(&h->c.gb)) {
+            if (get_bits1(&h->gb)) {
                 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
                     mb_type[mb_y * h->c.mb_stride + mb_x] =
                         MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
             } else {
                 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
                     mb_type[mb_y * h->c.mb_stride + mb_x] =
-                        (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
+                        (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
             }
         }
         break;
@@ -157,7 +157,7 @@ static int parse_mb_skip(WMV2DecContext *w)
         for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
             coded_mb_count += !IS_SKIP(mb_type[mb_y * h->c.mb_stride + mb_x]);
 
-    if (coded_mb_count > get_bits_left(&h->c.gb))
+    if (coded_mb_count > get_bits_left(&h->gb))
         return AVERROR_INVALIDDATA;
 
     return 0;
@@ -205,17 +205,17 @@ int ff_wmv2_decode_picture_header(H263DecContext *const h)
 {
     int code;
 
-    h->c.pict_type = get_bits1(&h->c.gb) + 1;
+    h->c.pict_type = get_bits1(&h->gb) + 1;
     if (h->c.pict_type == AV_PICTURE_TYPE_I) {
-        code = get_bits(&h->c.gb, 7);
+        code = get_bits(&h->gb, 7);
         av_log(h->c.avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
     }
-    h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
+    h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
     if (h->c.qscale <= 0)
         return AVERROR_INVALIDDATA;
 
-    if (h->c.pict_type != AV_PICTURE_TYPE_I && show_bits(&h->c.gb, 1)) {
-        GetBitContext gb = h->c.gb;
+    if (h->c.pict_type != AV_PICTURE_TYPE_I && show_bits(&h->gb, 1)) {
+        GetBitContext gb = h->gb;
         int skip_type = get_bits(&gb, 2);
         int run = skip_type == SKIP_TYPE_COL ? h->c.mb_width : h->c.mb_height;
 
@@ -241,29 +241,29 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h)
         memset(h->c.cur_pic.mb_type, 0,
                sizeof(*h->c.cur_pic.mb_type) * h->c.mb_height * h->c.mb_stride);
         if (w->j_type_bit)
-            w->j_type = get_bits1(&h->c.gb);
+            w->j_type = get_bits1(&h->gb);
         else
             w->j_type = 0; // FIXME check
 
         if (!w->j_type) {
             if (w->per_mb_rl_bit)
-                w->ms.per_mb_rl_table = get_bits1(&h->c.gb);
+                w->ms.per_mb_rl_table = get_bits1(&h->gb);
             else
                 w->ms.per_mb_rl_table = 0;
 
             if (!w->ms.per_mb_rl_table) {
-                w->ms.rl_chroma_table_index = decode012(&h->c.gb);
-                w->ms.rl_table_index        = decode012(&h->c.gb);
+                w->ms.rl_chroma_table_index = decode012(&h->gb);
+                w->ms.rl_table_index        = decode012(&h->gb);
             }
 
-            w->ms.dc_table_index = get_bits1(&h->c.gb);
+            w->ms.dc_table_index = get_bits1(&h->gb);
 
             // at minimum one bit per macroblock is required at least in a valid frame,
             // we discard frames much smaller than this. Frames smaller than 1/8 of the
             // smallest "black/skip" frame generally contain not much recoverable content
             // while at the same time they have the highest computational requirements
             // per byte
-            if (get_bits_left(&h->c.gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
+            if (get_bits_left(&h->gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
                 return AVERROR_INVALIDDATA;
         }
         h->c.inter_intra_pred = 0;
@@ -282,35 +282,35 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h)
         ret = parse_mb_skip(w);
         if (ret < 0)
             return ret;
-        cbp_index = decode012(&h->c.gb);
+        cbp_index = decode012(&h->gb);
         w->cbp_table_index = wmv2_get_cbp_table_index(h->c.qscale, cbp_index);
 
         if (w->mspel_bit)
-            h->c.mspel = get_bits1(&h->c.gb);
+            h->c.mspel = get_bits1(&h->gb);
         else
             h->c.mspel = 0; // FIXME check
 
         if (w->abt_flag) {
-            w->per_mb_abt = get_bits1(&h->c.gb) ^ 1;
+            w->per_mb_abt = get_bits1(&h->gb) ^ 1;
             if (!w->per_mb_abt)
-                w->abt_type = decode012(&h->c.gb);
+                w->abt_type = decode012(&h->gb);
         }
 
         if (w->per_mb_rl_bit)
-            w->ms.per_mb_rl_table = get_bits1(&h->c.gb);
+            w->ms.per_mb_rl_table = get_bits1(&h->gb);
         else
             w->ms.per_mb_rl_table = 0;
 
         if (!w->ms.per_mb_rl_table) {
-            w->ms.rl_table_index        = decode012(&h->c.gb);
+            w->ms.rl_table_index        = decode012(&h->gb);
             w->ms.rl_chroma_table_index = w->ms.rl_table_index;
         }
 
-        if (get_bits_left(&h->c.gb) < 2)
+        if (get_bits_left(&h->gb) < 2)
             return AVERROR_INVALIDDATA;
 
-        w->ms.dc_table_index = get_bits1(&h->c.gb);
-        w->ms.mv_table_index = get_bits1(&h->c.gb);
+        w->ms.dc_table_index = get_bits1(&h->gb);
+        w->ms.mv_table_index = get_bits1(&h->gb);
 
         h->c.inter_intra_pred = 0; // (h->c.width * h->c.height < 320 * 240 && w->ms.bit_rate <= II_BITRATE);
         h->c.no_rounding     ^= 1;
@@ -331,7 +331,7 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h)
 
     if (w->j_type) {
         ff_intrax8_decode_picture(&w->x8, h->c.cur_pic.ptr,
-                                  &h->c.gb, &h->c.mb_x, &h->c.mb_y,
+                                  &h->gb, &h->c.mb_x, &h->c.mb_y,
                                   2 * h->c.qscale, (h->c.qscale - 1) | 1,
                                   h->c.loop_filter, h->c.low_delay);
 
@@ -351,7 +351,7 @@ static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_pt
     ff_msmpeg4_decode_motion(&w->ms, mx_ptr, my_ptr);
 
     if ((((*mx_ptr) | (*my_ptr)) & 1) && h->c.mspel)
-        w->common.hshift = get_bits1(&h->c.gb);
+        w->common.hshift = get_bits1(&h->gb);
     else
         w->common.hshift = 0;
 }
@@ -376,7 +376,7 @@ static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py)
         diff = 0;
 
     if (diff >= 8)
-        type = get_bits1(&h->c.gb);
+        type = get_bits1(&h->gb);
     else
         type = 2;
 
@@ -413,13 +413,13 @@ static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,
     }
 
     if (w->per_block_abt)
-        w->abt_type = decode012(&h->c.gb);
+        w->abt_type = decode012(&h->gb);
     w->abt_type_table[n] = w->abt_type;
 
     if (w->abt_type) {
         const uint8_t *scantable = w->abt_type == 1 ? ff_wmv2_scantableA : ff_wmv2_scantableB;
 
-        sub_cbp = sub_cbp_table[decode012(&h->c.gb)];
+        sub_cbp = sub_cbp_table[decode012(&h->gb)];
 
         if (sub_cbp & 1) {
             ret = ff_msmpeg4_decode_block(&w->ms, block, n, 1, scantable);
@@ -468,19 +468,19 @@ static int wmv2_decode_mb(H263DecContext *const h)
             w->common.hshift      = 0;
             return 0;
         }
-        if (get_bits_left(&h->c.gb) <= 0)
+        if (get_bits_left(&h->gb) <= 0)
             return AVERROR_INVALIDDATA;
 
-        code = get_vlc2(&h->c.gb, ff_mb_non_intra_vlc[w->cbp_table_index],
+        code = get_vlc2(&h->gb, ff_mb_non_intra_vlc[w->cbp_table_index],
                         MB_NON_INTRA_VLC_BITS, 3);
         h->c.mb_intra = (~code & 0x40) >> 6;
 
         cbp = code & 0x3f;
     } else {
         h->c.mb_intra = 1;
-        if (get_bits_left(&h->c.gb) <= 0)
+        if (get_bits_left(&h->gb) <= 0)
             return AVERROR_INVALIDDATA;
-        code = get_vlc2(&h->c.gb, ff_msmp4_mb_i_vlc,
+        code = get_vlc2(&h->gb, ff_msmp4_mb_i_vlc,
                         MSMP4_MB_INTRA_VLC_BITS, 2);
         /* predict coded block pattern */
         cbp = 0;
@@ -502,14 +502,14 @@ static int wmv2_decode_mb(H263DecContext *const h)
         if (cbp) {
             h->c.bdsp.clear_blocks(h->block[0]);
             if (ms->per_mb_rl_table) {
-                ms->rl_table_index        = decode012(&h->c.gb);
+                ms->rl_table_index        = decode012(&h->gb);
                 ms->rl_chroma_table_index = ms->rl_table_index;
             }
 
             if (w->abt_flag && w->per_mb_abt) {
-                w->per_block_abt = get_bits1(&h->c.gb);
+                w->per_block_abt = get_bits1(&h->gb);
                 if (!w->per_block_abt)
-                    w->abt_type = decode012(&h->c.gb);
+                    w->abt_type = decode012(&h->gb);
             } else
                 w->per_block_abt = 0;
         }
@@ -534,16 +534,16 @@ static int wmv2_decode_mb(H263DecContext *const h)
             ff_dlog(h->c.avctx, "%d%d ", h->c.inter_intra_pred, cbp);
         ff_dlog(h->c.avctx, "I at %d %d %d %06X\n", h->c.mb_x, h->c.mb_y,
                 ((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
-                show_bits(&h->c.gb, 24));
-        h->c.ac_pred = get_bits1(&h->c.gb);
+                show_bits(&h->gb, 24));
+        h->c.ac_pred = get_bits1(&h->gb);
         if (h->c.inter_intra_pred) {
-            h->c.h263_aic_dir = get_vlc2(&h->c.gb, ff_inter_intra_vlc,
+            h->c.h263_aic_dir = get_vlc2(&h->gb, ff_inter_intra_vlc,
                                        INTER_INTRA_VLC_BITS, 1);
             ff_dlog(h->c.avctx, "%d%d %d %d/",
                     h->c.ac_pred, h->c.h263_aic_dir, h->c.mb_x, h->c.mb_y);
         }
         if (ms->per_mb_rl_table && cbp) {
-            ms->rl_table_index        = decode012(&h->c.gb);
+            ms->rl_table_index        = decode012(&h->gb);
             ms->rl_chroma_table_index = ms->rl_table_index;
         }
 
-- 
ffmpeg-codebot

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2025-06-23 13:43 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 13:36 [FFmpeg-devel] [PATCH 00/48] H263DecContext ffmpegagent
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 01/48] avcodec/ituh263dec: Use correct logcontext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 02/48] avcodec/rl: Avoid branch in index lookup Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 03/48] avcodec/ituh263enc: Simplify creating LUT Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 04/48] avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 05/48] avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 06/48] avcodec/mpegvideo: Add MPVContext typedef Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 07/48] avcodec/mpegvideo_dec: Factor debugging dct coefficients out Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 08/48] avcodec/mpegvideo_dec: Reindent after the previous commit Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 09/48] avcodec/mpeg_er: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 10/48] avcodec/mpegvideodec: Remove size expectation from ff_mpv_reconstruct_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 11/48] avcodec/h261dec: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 12/48] avcodec/h261dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 13/48] avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 14/48] avcodec/mpeg12dec: Remove unused function parameter Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 15/48] avcodec/rv34: Don't use MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 16/48] avcodec/rv34: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 17/48] avcodec/intrax8: Don't pretend to need more than one int16_t[64] Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 18/48] avcodec/vc1: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 19/48] avcodec/vc1: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 20/48] avcodec/mpeg12dec: Deduplicate variables Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 21/48] avcodec/mpegvideo: Move flipflop_rounding to {MSMPEG4Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 22/48] avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 23/48] avcodec/mpeg4videodec: Avoid unnecessary indirections Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 24/48] avcodec/{h263, mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext* Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 25/48] avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 26/48] avcodec/h263dec: Add H263DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 27/48] avcodec/h263dec: Remove redundant block parameter from decode_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 28/48] avcodec/h263dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` Andreas Rheinhardt [this message]
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 30/48] avcodec/mpeg12dec: Add Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 31/48] avcodec/mpegvideo: Add missing headers Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 32/48] avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 33/48] avcodec/mpeg12dec: Don't use MPVContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 34/48] avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 35/48] avcodec/mpegvideo: Move mb_num_left to {H263, RV34}DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 36/48] avcodec/mpeg12dec: Put mb_skip_run on the stack Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 37/48] avcodec/mpegvideo: Move mb_skip_run to {RV34Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 38/48] avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 39/48] avcodec/msmpeg4dec: Move ff_msmpeg4_decode_init() down Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 40/48] avcodec/h263dec: Use function ptr for decode_picture_header Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 41/48] avcodec/ituh263enc: Inline value of h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 42/48] avcodec/flvdec: Binarize h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 43/48] avcodec/mpegvideo: Move fields to {H263Dec, MPVEnc}Context when possible Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 44/48] avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 45/48] avcodec/mpegvideo: Move partitioned_frame to {H263Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 46/48] avcodec/mpegvideo: Move loop_filter to {H263Dec, MPVEnc, VC1}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 47/48] avcodec/rv34: Don't report progress unnecessarily Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 48/48] avcodec/rv34: Fix spelling mistake Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae7ab847c80220767effe9c3be7067e9663507fd.1750685809.git.ffmpegagent@gmail.com \
    --to=ffmpegagent-at-gmail.com@ffmpeg.org \
    --cc=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git