[vlc-commits] gl: vaapi: add an interop blacklist

Thomas Guillem git at videolan.org
Fri Jun 23 14:09:04 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jun 23 13:21:38 2017 +0200| [0188f10d3aa99b0122e9e05a31230756d262aa28] | committer: Thomas Guillem

gl: vaapi: add an interop blacklist

I didn't find any other way to check if a driver can do interop. Except
checking if vaDeriveImage() works (that is done in the previous commit), but
it's better to fail earlier to avoid useless surfaces allocation.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0188f10d3aa99b0122e9e05a31230756d262aa28
---

 modules/video_output/opengl/converter_vaapi.c | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index 83ef3c25d6..3f2ef14b59 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -232,6 +232,35 @@ tc_vaegl_release(const opengl_tex_converter_t *tc)
 }
 
 static int
+tc_va_check_interop_blacklist(opengl_tex_converter_t *tc, VADisplay *vadpy)
+{
+    const char *vendor = vaQueryVendorString(vadpy);
+    if (vendor == NULL)
+        return VLC_SUCCESS;
+
+#define BL_SIZE_MAX 19
+    static const char blacklist_prefix[][BL_SIZE_MAX] = {
+        /* XXX: case insensitive and alphabetical order */
+        "mesa gallium vaapi",
+    };
+
+    char vendor_prefix[BL_SIZE_MAX];
+    strncpy(vendor_prefix, vendor, BL_SIZE_MAX);
+    vendor_prefix[BL_SIZE_MAX - 1] = '\0';
+
+    const char *found = bsearch(vendor_prefix, blacklist_prefix,
+                                ARRAY_SIZE(blacklist_prefix),
+                                BL_SIZE_MAX, (void *) strcasecmp);
+    if (found != NULL)
+    {
+        msg_Warn(tc->gl, "The '%s' driver is blacklisted: no interop", found);
+        return VLC_EGENERIC;
+    }
+
+    return VLC_SUCCESS;
+}
+
+static int
 tc_vaegl_init(opengl_tex_converter_t *tc, VADisplay *vadpy)
 {
     if (vadpy == NULL)
@@ -265,6 +294,12 @@ tc_vaegl_init(opengl_tex_converter_t *tc, VADisplay *vadpy)
     if (vlc_vaapi_Initialize(VLC_OBJECT(tc->gl), priv->vadpy))
         goto error;
 
+    if (tc_va_check_interop_blacklist(tc, priv->vadpy))
+    {
+        vaTerminate(priv->vadpy);
+        goto error;
+    }
+
     if (vlc_vaapi_SetInstance(priv->vadpy))
     {
         msg_Err(tc->gl, "VAAPI instance already in use");



More information about the vlc-commits mailing list