From: Víctor Manuel Jáquez Leal Date: Thu, 6 Apr 2017 10:28:51 +0000 (+0200) Subject: libs: encoder: dummy context for get_surface_formats() X-Git-Tag: 1.19.3~503^2~1059 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9aa63e4595105ac035663a22360d75c52b74b4b8;p=platform%2Fupstream%2Fgstreamer.git libs: encoder: dummy context for get_surface_formats() Instead of creating (if it doesn't exist, yet) the encoder's context the method gst_vaapi_encoder_get_surface_formats() now it creates dummy contexts, unless the encoder has it already created. The purpose of this is to avoid setting a encoder's context with a wrong profile. https://bugzilla.gnome.org/show_bug.cgi?id=771291 --- diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index f4836e3..3ecd2c4 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -1160,17 +1160,18 @@ error: } } -static gboolean -gst_vaapi_encoder_ensure_context_config (GstVaapiEncoder * encoder) +static GstVaapiContext * +create_test_context_config (GstVaapiEncoder * encoder) { - GstVaapiContextInfo *const cip = &encoder->context_info; + GstVaapiContextInfo cip = { 0, }; + GstVaapiContext *ctxt; if (encoder->context) - return TRUE; + return gst_vaapi_object_ref (encoder->context); - init_context_info (encoder, cip, get_profile (encoder)); - encoder->context = gst_vaapi_context_new (encoder->display, cip); - return (encoder->context != NULL); + init_context_info (encoder, &cip, get_profile (encoder)); + ctxt = gst_vaapi_context_new (encoder->display, &cip); + return ctxt; } /** @@ -1184,9 +1185,15 @@ gst_vaapi_encoder_ensure_context_config (GstVaapiEncoder * encoder) GArray * gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder) { - if (!gst_vaapi_encoder_ensure_context_config (encoder)) + GstVaapiContext *ctxt; + GArray *formats; + + ctxt = create_test_context_config (encoder); + if (!ctxt) return NULL; - return gst_vaapi_context_get_surface_formats (encoder->context); + formats = gst_vaapi_context_get_surface_formats (ctxt); + gst_vaapi_object_unref (ctxt); + return formats; } /** Returns a GType for the #GstVaapiEncoderTune set */