diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 09b2902bca6fb8c3ec2eb875ae57094d2c200de9..672031b6db90f3cd16a346fc46728cb282544bf4 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -69,6 +69,7 @@ typedef struct Mpeg1Context {
     int rc_buffer_size;
     AVRational frame_rate_ext;  /* MPEG-2 specific framerate modificator */
     int sync;                   /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */
+    int closed_gop;
     int tmpgexs;
     int first_slice;
     int extradata_decoded;
@@ -2449,7 +2450,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
 
     tc = s-> timecode_frame_start = get_bits(&s->gb, 25);
 
-    s->closed_gop = get_bits1(&s->gb);
+    s1->closed_gop = get_bits1(&s->gb);
     /* broken_link indicates that after editing the
      * reference frames of the first B-Frames after GOP I-Frame
      * are missing (open gop) */
@@ -2460,7 +2461,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
         av_timecode_make_mpeg_tc_string(tcbuf, tc);
         av_log(s->avctx, AV_LOG_DEBUG,
                "GOP (%s) closed_gop=%d broken_link=%d\n",
-               tcbuf, s->closed_gop, broken_link);
+               tcbuf, s1->closed_gop, broken_link);
     }
 }
 
@@ -2694,7 +2695,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
                     /* Skip B-frames if we do not have reference frames and
                      * GOP is not closed. */
                     if (s2->pict_type == AV_PICTURE_TYPE_B) {
-                        if (!s2->closed_gop) {
+                        if (!s->closed_gop) {
                             skip_frame = 1;
                             av_log(s2->avctx, AV_LOG_DEBUG,
                                    "Skipping B slice due to open GOP\n");
@@ -2882,6 +2883,7 @@ static void flush(AVCodecContext *avctx)
     Mpeg1Context *s = avctx->priv_data;
 
     s->sync       = 0;
+    s->closed_gop = 0;
 
     ff_mpeg_flush(avctx);
 }
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ba5b51955ea001fb53aeb2dfe738a4c574a3a05d..55399a7478acfbb693080313b66e1a4040aa7eaf 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2317,7 +2317,6 @@ void ff_mpeg_flush(AVCodecContext *avctx){
     ff_mpeg_unref_picture(s->avctx, &s->next_picture);
 
     s->mb_x= s->mb_y= 0;
-    s->closed_gop= 0;
 
 #if FF_API_FLAG_TRUNCATED
     s->parse_context.state= -1;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index e90669b776977ae3140deb5771437a348a761081..85f02b1355469447d2f7e93a63b39007714a7834 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -198,7 +198,6 @@ typedef struct MpegEncContext {
     int *lambda_table;
     int adaptive_quant;         ///< use adaptive quantization
     int dquant;                 ///< qscale difference to prev qscale
-    int closed_gop;             ///< MPEG1/2 GOP is closed
     int pict_type;              ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
     int vbv_delay;
     int last_pict_type; //FIXME removes