diff options
author | Hyunjun Ko <zzoon@igalia.com> | 2016-12-02 09:28:07 +0900 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2016-12-07 10:21:46 +0100 |
commit | 059cc59a29c5df1cba55bee8d8c4a25002e9f973 (patch) | |
tree | 2e613abee97e6315c631583788ce4b1fd06f45e3 /gst-libs | |
parent | 7aeefb09904baf807e342b30093c38f3976e593f (diff) |
libs: context: split context_create()
Split the funcion context_create() into context_create() and
config_create().
Decoupling VAConfig and VAContext during context creation, we could
query the VAConfig for the supported surface's formats without creating
a VAContext.
https://bugzilla.gnome.org/show_bug.cgi?id=769266
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapicontext.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c index bf7a915e..e6410dc1 100644 --- a/gst-libs/gst/vaapi/gstvaapicontext.c +++ b/gst-libs/gst/vaapi/gstvaapicontext.c @@ -181,13 +181,12 @@ context_create (GstVaapiContext * context) { const GstVaapiContextInfo *const cip = &context->info; GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (context); - VAConfigAttrib attribs[3], *attrib = attribs; VAContextID context_id; VASurfaceID surface_id; VAStatus status; GArray *surfaces = NULL; gboolean success = FALSE; - guint i, value, va_chroma_format; + guint i; if (!context->surfaces && !context_create_surfaces (context)) goto cleanup; @@ -207,6 +206,33 @@ context_create (GstVaapiContext * context) } g_assert (surfaces->len == context->surfaces->len); + GST_VAAPI_DISPLAY_LOCK (display); + status = vaCreateContext (GST_VAAPI_DISPLAY_VADISPLAY (display), + context->va_config, cip->width, cip->height, VA_PROGRESSIVE, + (VASurfaceID *) surfaces->data, surfaces->len, &context_id); + GST_VAAPI_DISPLAY_UNLOCK (display); + if (!vaapi_check_status (status, "vaCreateContext()")) + goto cleanup; + + GST_DEBUG ("context 0x%08x", context_id); + GST_VAAPI_OBJECT_ID (context) = context_id; + success = TRUE; + +cleanup: + if (surfaces) + g_array_free (surfaces, TRUE); + return success; +} + +static gboolean +config_create (GstVaapiContext * context) +{ + const GstVaapiContextInfo *const cip = &context->info; + GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (context); + VAConfigAttrib attribs[3], *attrib = attribs; + VAStatus status; + guint value, va_chroma_format; + /* Reset profile and entrypoint */ if (!cip->profile || !cip->entrypoint) goto cleanup; @@ -289,22 +315,10 @@ context_create (GstVaapiContext * context) if (!vaapi_check_status (status, "vaCreateConfig()")) goto cleanup; - GST_VAAPI_DISPLAY_LOCK (display); - status = vaCreateContext (GST_VAAPI_DISPLAY_VADISPLAY (display), - context->va_config, cip->width, cip->height, VA_PROGRESSIVE, - (VASurfaceID *) surfaces->data, surfaces->len, &context_id); - GST_VAAPI_DISPLAY_UNLOCK (display); - if (!vaapi_check_status (status, "vaCreateContext()")) - goto cleanup; - - GST_DEBUG ("context 0x%08x", context_id); - GST_VAAPI_OBJECT_ID (context) = context_id; - success = TRUE; - + return TRUE; cleanup: - if (surfaces) - g_array_free (surfaces, TRUE); - return success; + GST_WARNING ("Failed to create vaConfig"); + return FALSE; } /** Updates config for encoding. Returns %TRUE if config changed */ @@ -383,6 +397,10 @@ gst_vaapi_context_new (GstVaapiDisplay * display, return NULL; gst_vaapi_context_init (context, cip); + + if (!config_create (context)) + goto error; + if (!context_create (context)) goto error; return context; @@ -461,7 +479,7 @@ gst_vaapi_context_reset (GstVaapiContext * context, return FALSE; else if (grow_surfaces && !context_ensure_surfaces (context)) return FALSE; - if (reset_config && !context_create (context)) + if (reset_config && !(config_create (context) && context_create (context))) return FALSE; return TRUE; } |