diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index e090f4b39b..7eebffc91c 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -44,6 +44,7 @@ typedef struct H263DecContext {
     MPVMainDecContext m;
 
     int (*decode_mb)(MPVDecContext *s, int16_t block[12][64]); // used to avoid a switch
+    int pb_frame;          ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
     int long_vectors;      ///< use horrible H.263v1 long vector mode
     int ehc_mode;
 } H263DecContext;
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index f621c9686c..a5cd6dd1de 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -69,7 +69,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h)
         return -1;      /* SAC: off */
     }
     s->obmc= get_bits1(&s->gb);
-    s->pb_frame = get_bits1(&s->gb);
+    h->pb_frame = get_bits1(&s->gb);
 
     if (format < 6) {
         s->width = ff_h263_format[format][0];
@@ -88,7 +88,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h)
         if(get_bits1(&s->gb))
             av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
         if(get_bits1(&s->gb))
-            s->pb_frame = 2;
+            h->pb_frame = 2;
         if(get_bits(&s->gb, 5))
             av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
         if(get_bits(&s->gb, 5) != 1)
@@ -112,7 +112,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *h)
     s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
     skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
 
-    if(s->pb_frame){
+    if (h->pb_frame) {
         skip_bits(&s->gb, 3); //temporal reference for B-frame
         skip_bits(&s->gb, 2); //dbquant
     }
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 8467746a0e..15365afebc 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -792,6 +792,9 @@ static int set_direct_mv(MPVDecContext *s)
 int ff_h263_decode_mb(MPVDecContext *s,
                       int16_t block[6][64])
 {
+    /* The following is only allowed because no h263dec-based
+     * decoder uses slice-threading. */
+    const H263DecContext *const h = (H263DecContext*)s;
     int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
     int16_t *mot_val;
     const int xy= s->mb_x + s->mb_y * s->mb_stride;
@@ -827,8 +830,8 @@ int ff_h263_decode_mb(MPVDecContext *s,
         s->mb_intra = ((cbpc & 4) != 0);
         if (s->mb_intra) goto intra;
 
-        if(s->pb_frame && get_bits1(&s->gb))
-            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
+        if (h->pb_frame && get_bits1(&s->gb))
+            pb_mv_count = h263_get_modb(&s->gb, h->pb_frame, &cbpb);
         cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
 
         if (cbpy < 0) {
@@ -1037,8 +1040,8 @@ intra:
         }else
             s->ac_pred = 0;
 
-        if(s->pb_frame && get_bits1(&s->gb))
-            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
+        if (h->pb_frame && get_bits1(&s->gb))
+            pb_mv_count = h263_get_modb(&s->gb, h->pb_frame, &cbpb);
         cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
         if(cbpy<0){
             av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
@@ -1049,7 +1052,7 @@ intra:
             h263_decode_dquant(s);
         }
 
-        pb_mv_count += !!s->pb_frame;
+        pb_mv_count += !!h->pb_frame;
     }
 
     while(pb_mv_count--){
@@ -1064,7 +1067,7 @@ intra:
         cbp+=cbp;
     }
 
-    if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
+    if (h->pb_frame && h263_skip_b_part(s, cbpb) < 0)
         return -1;
     if(s->obmc && !s->mb_intra){
         if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
@@ -1161,7 +1164,7 @@ int ff_h263_decode_picture_header(H263DecContext *h)
         }
         s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
 
-        s->pb_frame = get_bits1(&s->gb);
+        h->pb_frame = get_bits1(&s->gb);
         s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
         skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
 
@@ -1217,7 +1220,7 @@ int ff_h263_decode_picture_header(H263DecContext *h)
         switch(s->pict_type){
         case 0: s->pict_type= AV_PICTURE_TYPE_I;break;
         case 1: s->pict_type= AV_PICTURE_TYPE_P;break;
-        case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break;
+        case 2: s->pict_type= AV_PICTURE_TYPE_P; h->pb_frame = 3;break;
         case 3: s->pict_type= AV_PICTURE_TYPE_B;break;
         case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO
         default:
@@ -1321,7 +1324,7 @@ int ff_h263_decode_picture_header(H263DecContext *h)
     s->mb_height = (s->height  + 15) / 16;
     s->mb_num = s->mb_width * s->mb_height;
 
-    if (s->pb_frame) {
+    if (h->pb_frame) {
         skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */
         if (s->custom_pcf)
             skip_bits(&s->gb, 2); //extended Temporal reference
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 7be9b889ea..8697f0108c 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -87,7 +87,6 @@ typedef struct MPVContext {
     int64_t bit_rate; ///< wanted bit rate
     enum OutputFormat out_format; ///< output format
     int h263_pred;    ///< use MPEG-4/H.263 ac/dc predictions
-    int pb_frame;     ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
 
 /* the following codec id fields are deprecated in favor of codec_id */
     int h263_plus;    ///< H.263+ headers
