From cc6c2d23ce1adf2235412b26f2f8637b3630f697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 12 Jul 2016 17:54:26 +0200 Subject: [PATCH] vaapidecode: delay the GstVaapiDisplay instantiating Delay the GstVaapiDisplay instantiating until when changing the state from READY to PAUSE. In this way the element has more chances to find an already created GstVaapiDisplay, or a GL context, in the pipeline. https://bugzilla.gnome.org/show_bug.cgi?id=766206 --- gst/vaapi/gstvaapidecode.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index af2a97c..5ed1c38 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -950,8 +950,6 @@ static gboolean gst_vaapidecode_open (GstVideoDecoder * vdec) { GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); - GstVaapiDisplay *const old_display = GST_VAAPI_PLUGIN_BASE_DISPLAY (decode); - gboolean success; if (!gst_vaapi_plugin_base_open (GST_VAAPI_PLUGIN_BASE (decode))) return FALSE; @@ -960,17 +958,7 @@ gst_vaapidecode_open (GstVideoDecoder * vdec) decode->display_height = 0; gst_video_info_init (&decode->decoded_info); - /* Let GstVideoContext ask for a proper display to its neighbours */ - /* Note: steal old display that may be allocated from get_caps() - so that to retain a reference to it, thus avoiding extra - initialization steps if we turn out to simply re-use the - existing (cached) VA display */ - GST_VAAPI_PLUGIN_BASE_DISPLAY (decode) = NULL; - success = gst_vaapidecode_ensure_display (decode); - if (old_display) - gst_vaapi_display_unref (old_display); - - return success; + return TRUE; } static gboolean @@ -984,6 +972,27 @@ gst_vaapidecode_close (GstVideoDecoder * vdec) } static gboolean +gst_vaapidecode_start (GstVideoDecoder * vdec) +{ + GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); + GstVaapiDisplay *const old_display = GST_VAAPI_PLUGIN_BASE_DISPLAY (decode); + gboolean success; + + /* Let GstVideoContext ask for a proper display to its neighbours */ + /* Note: steal old display that may be allocated from get_caps() + so that to retain a reference to it, thus avoiding extra + initialization steps if we turn out to simply re-use the + existing (cached) VA display */ + GST_VAAPI_PLUGIN_BASE_DISPLAY (decode) = NULL; + success = + gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (decode)); + if (old_display) + gst_vaapi_display_unref (old_display); + + return success; +} + +static gboolean gst_vaapidecode_stop (GstVideoDecoder * vdec) { GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); @@ -1280,6 +1289,7 @@ 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->start = GST_DEBUG_FUNCPTR (gst_vaapidecode_start); vdec_class->stop = GST_DEBUG_FUNCPTR (gst_vaapidecode_stop); vdec_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapidecode_set_format); vdec_class->flush = GST_DEBUG_FUNCPTR (gst_vaapidecode_flush); -- 2.7.4