[vlc-commits] opengl: vaapi: early check EGLImageKHR creation

Thomas Guillem git at videolan.org
Tue Nov 7 11:52:58 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Nov  7 08:48:37 2017 +0100| [fe784b954f6ba169a995bb3fa3deec3a3cc09e82] | committer: Thomas Guillem

opengl: vaapi: early check EGLImageKHR creation

This fixes green screen with some systems that have a working vaDeriveImage
implementation but no EGL/DMABUF (or not recent enough).

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

 modules/video_output/opengl/converter_vaapi.c | 45 ++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index 0e904e66ea..0b0f794b9c 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -244,16 +244,51 @@ tc_vaegl_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count)
     if (!pool)
         return NULL;
 
-    /* Check if a surface from the pool can be derived */
-    VAImage va_image;
+    /* Check if a surface from the pool can be derived and displayed via dmabuf
+     * */
+    bool success = false;
+    VAImage va_image = { .image_id = VA_INVALID_ID };
     if (vlc_vaapi_DeriveImage(o, priv->vadpy, priv->va_surface_ids[0],
                               &va_image))
+        goto error;
+
+    assert(va_image.format.fourcc == priv->fourcc);
+
+    VABufferInfo va_buffer_info = (VABufferInfo) {
+        .mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME
+    };
+    if (vlc_vaapi_AcquireBufferHandle(o ,priv->vadpy, va_image.buf,
+                                      &va_buffer_info))
+        goto error;
+
+    for (unsigned i = 0; i < va_image.num_planes; ++i)
     {
-        picture_pool_Release(pool);
-        return NULL;
+        EGLint w = (va_image.width * tc->texs[i].w.num) / tc->texs[i].w.den;
+        EGLint h = (va_image.height * tc->texs[i].h.num) / tc->texs[i].h.den;
+        EGLImageKHR egl_image =
+            vaegl_image_create(tc, w, h, priv->drm_fourccs[i], va_buffer_info.handle,
+                               va_image.offsets[i], va_image.pitches[i]);
+        if (egl_image == NULL)
+        {
+            msg_Warn(o, "Can't create Image KHR: kernel too old ?");
+            goto error;
+        }
+        vaegl_image_destroy(tc, egl_image);
     }
 
-    vlc_vaapi_DestroyImage(o, priv->vadpy, va_image.image_id);
+    success = true;
+error:
+    if (va_image.image_id != VA_INVALID_ID)
+    {
+        if (va_image.buf != VA_INVALID_ID)
+            vlc_vaapi_ReleaseBufferHandle(o, priv->vadpy, va_image.buf);
+        vlc_vaapi_DestroyImage(o, priv->vadpy, va_image.image_id);
+    }
+    if (!success)
+    {
+        picture_pool_Release(pool);
+        pool = NULL;
+    }
     return pool;
 }
 



More information about the vlc-commits mailing list