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.
This commit is contained in:
Yeongjin Jeong 2019-04-29 15:02:06 +09:00
parent 2b6e9d303d
commit 93e2466115

View file

@ -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;