From 93e2466115172a858ec1a70a3dac2c3d13bec87f Mon Sep 17 00:00:00 2001 From: Yeongjin Jeong Date: Mon, 29 Apr 2019 15:02:06 +0900 Subject: [PATCH] avviddec: Ensure drain even if codec has not delay capabilities There are decoders that need to be drained if they work on multi-threads, even if AV_CODEC_CAP_DELAY is not set. --- ext/libav/gstavviddec.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c index 374bd9e7c3..e600b2162f 100644 --- a/ext/libav/gstavviddec.c +++ b/ext/libav/gstavviddec.c @@ -1729,28 +1729,19 @@ static GstFlowReturn gst_ffmpegviddec_drain (GstVideoDecoder * decoder) { GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder; - GstFFMpegVidDecClass *oclass; + GstFlowReturn ret; + gboolean got_frame = FALSE; if (!ffmpegdec->opened) return GST_FLOW_OK; - oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); + if (avcodec_send_packet (ffmpegdec->context, NULL)) + goto send_packet_failed; - if (oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) { - GstFlowReturn ret; - gboolean got_frame = FALSE; - - GST_LOG_OBJECT (ffmpegdec, - "codec has delay capabilities, calling until ffmpeg has drained everything"); - - if (avcodec_send_packet (ffmpegdec->context, NULL)) - goto send_packet_failed; - - do { - got_frame = gst_ffmpegviddec_frame (ffmpegdec, NULL, &ret); - } while (got_frame && ret == GST_FLOW_OK); - avcodec_flush_buffers (ffmpegdec->context); - } + do { + got_frame = gst_ffmpegviddec_frame (ffmpegdec, NULL, &ret); + } while (got_frame && ret == GST_FLOW_OK); + avcodec_flush_buffers (ffmpegdec->context); done: return GST_FLOW_OK;