From 6bbf5c05b155463f0b6c21b8ab6c0f078131f9c1 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Wed, 25 Jan 2012 19:40:41 +0100 Subject: [PATCH] dxva2_mpeg2: prevent calling end_frame without start_frame --- libavcodec/dxva2_mpeg2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index d31a8bb872..02a8520219 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -38,6 +38,7 @@ struct dxva2_picture_context { const uint8_t *bitstream; unsigned bitstream_size; + int frame_start; }; void ff_dxva2_mpeg2_fill_picture_parameters(AVCodecContext *avctx, @@ -272,6 +273,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, ctx_pic->slice_count = 0; ctx_pic->bitstream_size = 0; ctx_pic->bitstream = NULL; + ctx_pic->frame_start = 1; return 0; } @@ -305,8 +307,9 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx) s->current_picture_ptr->hwaccel_picture_private; int ret; - if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) + if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0 || !ctx_pic->frame_start) return -1; + ctx_pic->frame_start = 0; ret = ff_dxva2_common_end_frame(avctx, s->current_picture_ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), &ctx_pic->qm, sizeof(ctx_pic->qm),