From cdcaa584a412ef1af283ce3cbab4242f289bb87e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 3 Jul 2012 17:05:17 +0200 Subject: [PATCH] avdec: handle_frame should always unref the input frame Unref the input frame in all cases. Previously it was only unreffed when the frame was used for output. When we produce an output frame, take an extra ref because the frame is now freed elsewhere. --- ext/ffmpeg/gstffmpegviddec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/ffmpeg/gstffmpegviddec.c b/ext/ffmpeg/gstffmpegviddec.c index c4e0fa1609..5532dab644 100644 --- a/ext/ffmpeg/gstffmpegviddec.c +++ b/ext/ffmpeg/gstffmpegviddec.c @@ -1091,7 +1091,7 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec, /* get the output picture timing info again */ out_dframe = ffmpegdec->picture->opaque; - out_frame = out_dframe->frame; + out_frame = gst_video_codec_frame_ref (out_dframe->frame); GST_DEBUG_OBJECT (ffmpegdec, "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT, @@ -1138,7 +1138,8 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec, gst_video_decoder_finish_frame (GST_VIDEO_DECODER (ffmpegdec), out_frame); beach: - GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, len %d", *ret, len); + GST_DEBUG_OBJECT (ffmpegdec, "return flow %s, len %d", + gst_flow_get_name (*ret), len); return len; /* special cases */ @@ -1352,6 +1353,7 @@ gst_ffmpegviddec_handle_frame (GstVideoDecoder * decoder, GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize); gst_buffer_unmap (frame->input_buffer, &minfo); + gst_video_codec_frame_unref (frame); return ret; } @@ -1448,8 +1450,8 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query) avcodec_align_dimensions2 (ffmpegdec->context, &width, &height, linesize_align); edge = - ffmpegdec-> - context->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width (); + ffmpegdec->context-> + flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width (); /* increase the size for the padding */ width += edge << 1; height += edge << 1;