From 847e3efb4dd6e29e90ba2897a5fd029f4d67cb50 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 9 Oct 2013 10:06:40 +0200 Subject: [PATCH] plugins: fix check for direct-rendering support. Fix check for direct-rendering if the creation of VA surfaces with an explicit pixel format is not support, e.g. VA-API < 0.34.0, and that we tried to allocate a VA surface based on the corresponding chroma type. i.e. in that particular case, we have to make sure that the derived image has actually the expected format. --- gst/vaapi/gstvaapivideomemory.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index 319d257..377ea40 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -68,18 +68,23 @@ static GstVaapiSurface * new_surface(GstVaapiDisplay *display, const GstVideoInfo *vip) { GstVaapiSurface *surface; + GstVaapiChromaType chroma_type; /* Try with explicit format first */ - surface = gst_vaapi_surface_new_with_format(display, - GST_VIDEO_INFO_FORMAT(vip), GST_VIDEO_INFO_WIDTH(vip), - GST_VIDEO_INFO_HEIGHT(vip)); - if (surface) - return surface; - - /* Try to pick something compatible. Best bet: NV12 (YUV 4:2:0) */ - if (GST_VIDEO_INFO_FORMAT(vip) != GST_VIDEO_FORMAT_NV12) + if (GST_VIDEO_INFO_FORMAT(vip) != GST_VIDEO_FORMAT_ENCODED) { + surface = gst_vaapi_surface_new_with_format(display, + GST_VIDEO_INFO_FORMAT(vip), GST_VIDEO_INFO_WIDTH(vip), + GST_VIDEO_INFO_HEIGHT(vip)); + if (surface) + return surface; + } + + /* Try to pick something compatible, i.e. with same chroma type */ + chroma_type = gst_vaapi_video_format_get_chroma_type( + GST_VIDEO_INFO_FORMAT(vip)); + if (!chroma_type) return NULL; - return gst_vaapi_surface_new(display, GST_VAAPI_CHROMA_TYPE_YUV420, + return gst_vaapi_surface_new(display, chroma_type, GST_VIDEO_INFO_WIDTH(vip), GST_VIDEO_INFO_HEIGHT(vip)); } @@ -501,6 +506,8 @@ gst_vaapi_video_allocator_new(GstVaapiDisplay *display, GstCaps *caps) image = gst_vaapi_surface_derive_image(surface); if (!image) break; + if (GST_VAAPI_IMAGE_FORMAT(image) != GST_VIDEO_INFO_FORMAT(vip)) + break; if (!gst_vaapi_image_map(image)) break; allocator->has_direct_rendering = gst_video_info_update_from_image( -- 2.7.4