From 3ca2f6e24f4422f789e6483bb782052f7f91e4e4 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Fri, 12 Feb 2021 08:20:56 +0100
Subject: [PATCH 1/2] avcodec/mpeg12dec: don't call hw->end_frame when starting
 second field decoding

This call is unbalanced with a hwaccel->start_frame. It fixes some crashes
because this call ends up using uninitialized memory. Decoding works as
expected after this patch.
---
 libavcodec/mpeg12dec.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ac5ac4bca4..88d10e9236 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1674,15 +1674,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
             return AVERROR_INVALIDDATA;
         }
 
-        if (s->avctx->hwaccel &&
-            (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
-            if ((ret = s->avctx->hwaccel->end_frame(s->avctx)) < 0) {
-                av_log(avctx, AV_LOG_ERROR,
-                       "hardware accelerator failed to decode first field\n");
-                return ret;
-            }
-        }
-
         for (i = 0; i < 4; i++) {
             s->current_picture.f->data[i] = s->current_picture_ptr->f->data[i];
             if (s->picture_structure == PICT_BOTTOM_FIELD)
-- 
2.27.0.windows.1

