From 72362e10632fe46adafa92290b2480511eaecb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 31 Oct 2017 13:10:50 +0100 Subject: [PATCH] plugins: direct rendering on memory:VASurface As buffers negotiated with memory:VASurface caps feature can also be mapped, they can also be configured to use VA derived images, in other words "direct rendering". Also, because of the changes in dmabuf allocator as default allocator, the code for configuring the direct rendering was not clear. This patch cleans up the code and enables direct rendering when the environment variable GST_VAAPI_ENABLE_DIRECT_RENDERING is defined, even then the memory:VASurface cap feature is negotiated. https://bugzilla.gnome.org/show_bug.cgi?id=786054 --- gst/vaapi/gstvaapipluginbase.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 36f8af983c..6194c3057b 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -600,8 +600,6 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo, { gboolean different_caps; const GstVideoInfo *image_info; - GstVaapiImageUsageFlags usage_flag = - GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS; if (!reset_allocator (plugin->srcpad_allocator, vinfo)) goto valid_allocator; @@ -610,10 +608,6 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo, if (caps && gst_caps_is_video_raw (caps)) { GstAllocator *allocator = create_dmabuf_srcpad_allocator (plugin, vinfo, !plugin->srcpad_can_dmabuf); - if (!allocator && plugin->enable_direct_rendering) { - usage_flag = GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER; - GST_INFO_OBJECT (plugin, "enabling direct rendering in source allocator"); - } plugin->srcpad_allocator = allocator; } else if (caps && gst_vaapi_caps_feature_contains (caps, GST_VAAPI_CAPS_FEATURE_DMABUF)) { @@ -624,6 +618,14 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo, } if (!plugin->srcpad_allocator) { + GstVaapiImageUsageFlags usage_flag = + GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS; + + if (plugin->enable_direct_rendering) { + usage_flag = GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER; + GST_INFO_OBJECT (plugin, "enabling direct rendering in source allocator"); + } + plugin->srcpad_allocator = gst_vaapi_video_allocator_new (plugin->display, vinfo, 0, usage_flag); }