From 202110bded181192c1b571d51968d2b15cbe7478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 21 Oct 2016 11:48:54 +0200 Subject: [PATCH] plugins: direct render when raw video Enable the direct rendering with linear surfaces if the negotiated src caps are video/x-raw without features. Pass also the caps, since they are needed to know the requested caps features. --- gst/vaapi/gstvaapipluginbase.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 70ebb3bfcf..00a7c204cd 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -568,14 +568,23 @@ error_create_allocator: } static gboolean -ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo) +ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo, + GstCaps * caps) { + GstVaapiImageUsageFlags usage_flag = + GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS; + if (!reset_allocator (plugin->srcpad_allocator, vinfo)) return TRUE; + /* enable direct rendering if downstream requests raw video */ + if (caps && gst_caps_is_video_raw (caps)) { + 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, - GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS); + gst_vaapi_video_allocator_new (plugin->display, vinfo, 0, usage_flag); if (!plugin->srcpad_allocator) goto error_create_allocator; return TRUE; @@ -892,7 +901,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, } if (!pool) { - if (!ensure_srcpad_allocator (plugin, &vi)) + if (!ensure_srcpad_allocator (plugin, &vi, caps)) goto error; /* Update video size with allocator's image size */ gst_allocator_get_vaapi_image_size (plugin->srcpad_allocator, &size);