From 8663ad9492513f8b7715373b8bdd42670950af23 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 10 Jul 2013 13:58:55 +0200 Subject: [PATCH] surface: try to determine the underlying VA surface format. If a VA surface was allocated with the chroma-format interface, try to determine the underlying pixel format on gst_vaapi_surface_get_format(), or return GST_VIDEO_FORMAT_ENCODED if this is not a supported operation. --- gst-libs/gst/vaapi/gstvaapisurface.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapisurface.c b/gst-libs/gst/vaapi/gstvaapisurface.c index 17535164bb..0ffbc9ea21 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface.c +++ b/gst-libs/gst/vaapi/gstvaapisurface.c @@ -118,7 +118,7 @@ gst_vaapi_surface_create(GstVaapiSurface *surface, if (!vaapi_check_status(status, "vaCreateSurfaces()")) return FALSE; - surface->format = GST_VIDEO_FORMAT_ENCODED; + surface->format = GST_VIDEO_FORMAT_UNKNOWN; surface->chroma_type = chroma_type; surface->width = width; surface->height = height; @@ -318,6 +318,16 @@ gst_vaapi_surface_get_format(GstVaapiSurface *surface) { g_return_val_if_fail(surface != NULL, 0); + /* Try to determine the underlying VA surface format */ + if (surface->format == GST_VIDEO_FORMAT_UNKNOWN) { + GstVaapiImage * const image = gst_vaapi_surface_derive_image(surface); + if (image) { + surface->format = gst_vaapi_image_get_format(image); + gst_vaapi_object_unref(image); + } + if (surface->format == GST_VIDEO_FORMAT_UNKNOWN) + surface->format = GST_VIDEO_FORMAT_ENCODED; + } return GST_VAAPI_SURFACE_FORMAT(surface); }