From 1bd810fe99a29c869230e69ff31730e92bec9f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 16 Mar 2015 23:36:33 +0200 Subject: [PATCH] vaapidecode: handle flush() vmethod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since GStreamer 1.2 the vmethod reset() in GstVideoDecoderClass was deprecated and flush() was added. This patch set the vmethod flush() if the installed GStreamer version is 1.2 or superior. Otherwise, reset() is set. v2: 1) In order to avoid symbol collision, the old method gst_vaapidecode_flush() was renamed to gst_vaapidecode_internal_flush(). 2) The new vmethod flush() always do a hard full reset. v3: 1) Call gst_vaapidecode_internal_flush() first in flush() vmethod, in order to gather all collected data with gst_video_decoder_have_frame() https://bugzilla.gnome.org/show_bug.cgi?id=742922 Signed-off-by: Víctor Manuel Jáquez Leal Signed-off-by: Sreerenj Balachandran --- gst/vaapi/gstvaapidecode.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 164aae3399..e1c9126fce 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -482,7 +482,7 @@ not_negotiated: } static gboolean -gst_vaapidecode_flush (GstVideoDecoder * vdec) +gst_vaapidecode_internal_flush (GstVideoDecoder * vdec) { GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); GstVaapiDecoderStatus status; @@ -518,7 +518,7 @@ gst_vaapidecode_finish (GstVideoDecoder * vdec) if (!decode->decoder) return GST_FLOW_OK; - if (!gst_vaapidecode_flush (vdec)) { + if (!gst_vaapidecode_internal_flush (vdec)) { gst_vaapidecode_push_all_decoded_frames (decode); return GST_FLOW_ERROR; } @@ -736,16 +736,31 @@ gst_vaapidecode_close (GstVideoDecoder * vdec) return TRUE; } +#if GST_CHECK_VERSION(1,2,0) +static gboolean +gst_vaapidecode_flush (GstVideoDecoder * vdec) +{ + GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); + + if (decode->decoder && !gst_vaapidecode_internal_flush (vdec)) + return FALSE; + + /* There could be issues if we avoid the reset_full() while doing + * seeking: we have to reset the internal state */ + return gst_vaapidecode_reset_full (decode, decode->sinkpad_caps, TRUE); +} +#else static gboolean gst_vaapidecode_reset (GstVideoDecoder * vdec, gboolean hard) { GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); /* In GStreamer 1.0 context, this means a flush */ - if (decode->decoder && !hard && !gst_vaapidecode_flush (vdec)) + if (decode->decoder && !hard && !gst_vaapidecode_internal_flush (vdec)) return FALSE; return gst_vaapidecode_reset_full (decode, decode->sinkpad_caps, hard); } +#endif static gboolean gst_vaapidecode_set_format (GstVideoDecoder * vdec, GstVideoCodecState * state) @@ -839,7 +854,11 @@ gst_vaapidecode_class_init (GstVaapiDecodeClass * klass) vdec_class->open = GST_DEBUG_FUNCPTR (gst_vaapidecode_open); vdec_class->close = GST_DEBUG_FUNCPTR (gst_vaapidecode_close); vdec_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapidecode_set_format); +#if GST_CHECK_VERSION(1,2,0) + vdec_class->flush = GST_DEBUG_FUNCPTR (gst_vaapidecode_flush); +#else vdec_class->reset = GST_DEBUG_FUNCPTR (gst_vaapidecode_reset); +#endif vdec_class->parse = GST_DEBUG_FUNCPTR (gst_vaapidecode_parse); vdec_class->handle_frame = GST_DEBUG_FUNCPTR (gst_vaapidecode_handle_frame); vdec_class->finish = GST_DEBUG_FUNCPTR (gst_vaapidecode_finish);