From 6e85f08e33db4a227e4c9c373926a156698e5403 Mon Sep 17 00:00:00 2001 From: XuGuangxin Date: Thu, 29 Aug 2013 14:12:10 +0800 Subject: [PATCH] vaapidecode: fix hard reset for seek cases. Fix hard reset for seek cases by flushing the GstVaapiDecoder queue and completely purge any decoded output frame that may come out from it. At this stage, the GstVaapiDecoder shall be in a complete clean state to start decoding over new buffers. Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapidecode.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index d2c149f529..4f99170a58 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -639,6 +639,21 @@ gst_vaapidecode_reset_full(GstVaapiDecode *decode, GstCaps *caps, gboolean hard) /* Reset timers if hard reset was requested (e.g. seek) */ if (hard) { + GstVideoDecoder * const vdec = GST_VIDEO_DECODER(decode); + GstVideoCodecFrame *out_frame = NULL; + + gst_vaapi_decoder_flush(decode->decoder); + GST_VIDEO_DECODER_STREAM_UNLOCK(vdec); + gst_pad_stop_task(decode->srcpad); + GST_VIDEO_DECODER_STREAM_LOCK(vdec); + decode->decoder_loop_status = GST_FLOW_OK; + + /* Purge all decoded frames as we don't need them (e.g. seek) */ + while (gst_vaapi_decoder_get_frame_with_timeout(decode->decoder, + &out_frame, 0) == GST_VAAPI_DECODER_STATUS_SUCCESS) { + gst_video_codec_frame_unref(out_frame); + out_frame = NULL; + } } /* Only reset decoder if codec type changed */