[vlc-devel] [PATCH 01/32] opengl: pass the video context rather than the decoder device

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 26 15:59:52 CEST 2019


---
 modules/hw/nvdec/nvdec_gl.c                   |  2 +-
 modules/video_output/opengl/converter.h       |  4 ++--
 modules/video_output/opengl/converter_vaapi.c | 11 +++++++----
 modules/video_output/opengl/converter_vdpau.c | 14 +++++++++-----
 modules/video_output/opengl/vout_helper.c     |  2 +-
 modules/video_output/win32/direct3d9.c        |  2 +-
 6 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/modules/hw/nvdec/nvdec_gl.c b/modules/hw/nvdec/nvdec_gl.c
index 0259ea2bb07..e9def3e54a5 100644
--- a/modules/hw/nvdec/nvdec_gl.c
+++ b/modules/hw/nvdec/nvdec_gl.c
@@ -157,7 +157,7 @@ static int Open(vlc_object_t *obj)
     if (!is_nvdec_opaque(tc->fmt.i_chroma))
         return VLC_EGENERIC;
 
-    vlc_decoder_device *device = tc->dec_device;
+    vlc_decoder_device *device = tc->vctx->device;
     if (device == NULL || device->type != VLC_DECODER_DEVICE_NVDEC)
         return VLC_EGENERIC;
     device = vlc_decoder_device_Hold(device);
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index 73dfabeb713..30d7332a85c 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -259,8 +259,8 @@ struct opengl_tex_converter_t
     /* Pointer to object gl, set by the caller */
     vlc_gl_t *gl;
 
-    /* Pointer to decoder device, set by the caller (can be NULL) */
-    vlc_decoder_device *dec_device;
+    /* Pointer to decoder video context, set by the caller (can be NULL) */
+    vlc_video_context *vctx;
 
     /* libplacebo context, created by the caller (optional) */
     struct pl_context *pl_ctx;
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index 144c3d940c1..d529d8e8e00 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -224,8 +224,9 @@ tc_vaegl_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count)
     vlc_object_t *o = VLC_OBJECT(tc->gl);
     struct priv *priv = tc->priv;
 
+    vlc_decoder_device *dec_device = tc->vctx->device;
     picture_pool_t *pool =
-        vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), tc->dec_device, priv->vadpy,
+        vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), dec_device, priv->vadpy,
                           requested_count, &priv->va_surface_ids, &tc->fmt,
                           true);
     if (!pool)
@@ -330,8 +331,10 @@ Open(vlc_object_t *obj)
 {
     opengl_tex_converter_t *tc = (void *) obj;
 
-    if (tc->dec_device == NULL
-     || tc->dec_device->type != VLC_DECODER_DEVICE_VAAPI
+    if (tc->vctx == NULL)
+        return VLC_EGENERIC;
+    vlc_decoder_device *dec_device = tc->vctx->device;
+    if (dec_device->type != VLC_DECODER_DEVICE_VAAPI
      || !vlc_vaapi_IsChromaOpaque(tc->fmt.i_chroma)
      || tc->gl->ext != VLC_GL_EXT_EGL
      || tc->gl->egl.createImageKHR == NULL
@@ -374,7 +377,7 @@ Open(vlc_object_t *obj)
     if (priv->glEGLImageTargetTexture2DOES == NULL)
         goto error;
 
-    priv->vadpy = tc->dec_device->opaque;
+    priv->vadpy = dec_device->opaque;
     assert(priv->vadpy != NULL);
 
     if (tc_va_check_interop_blacklist(tc, priv->vadpy))
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index ce43b5621d8..296c47adaf0 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -62,7 +62,8 @@ static picture_pool_t *
 tc_vdpau_gl_get_pool(opengl_tex_converter_t const *tc,
                      unsigned int requested_count)
 {
-    return vlc_vdp_output_pool_create(tc->dec_device->opaque,
+    vlc_decoder_device *dec_device = tc->vctx->device;
+    return vlc_vdp_output_pool_create(dec_device->opaque,
                                       VDP_RGBA_FORMAT_B8G8R8A8,
                                       &tc->fmt, requested_count);
 }
@@ -112,15 +113,18 @@ Close(vlc_object_t *obj)
 {
     opengl_tex_converter_t *tc = (void *)obj;
     _glVDPAUFiniNV(); assert(tc->vt->GetError() == GL_NO_ERROR);
-    vdp_release_x11(tc->dec_device->opaque);
+    vlc_decoder_device *dec_device = tc->vctx->device;
+    vdp_release_x11(dec_device->opaque);
 }
 
 static int
 Open(vlc_object_t *obj)
 {
     opengl_tex_converter_t *tc = (void *) obj;
-    if (tc->dec_device == NULL
-     || tc->dec_device->type != VLC_DECODER_DEVICE_VDPAU
+    if (tc->vctx == NULL)
+        return VLC_EGENERIC;
+    vlc_decoder_device *dec_device = tc->vctx->device;
+    if (dec_device->type != VLC_DECODER_DEVICE_VDPAU
      || (tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420
       && tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422
       && tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444)
@@ -131,7 +135,7 @@ Open(vlc_object_t *obj)
     tc->fmt.i_chroma = VLC_CODEC_VDPAU_OUTPUT;
 
     VdpDevice device;
-    vdp_t *vdp = tc->dec_device->opaque;
+    vdp_t *vdp = dec_device->opaque;
     vdp_hold_x11(vdp, &device);
 
     void *vdp_gpa;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index b37b6532572..8e692eae5a0 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -588,7 +588,7 @@ opengl_init_program(vout_display_opengl_t *vgl, vlc_video_context *context,
         if (desc->plane_count == 0)
         {
             /* Opaque chroma: load a module to handle it */
-            tc->dec_device = context ? context->device : NULL;
+            tc->vctx = context;
             tc->p_module = module_need_var(tc, "glconv", "glconv");
         }
 
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 23d2c067bb0..05b38a10e01 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1919,7 +1919,7 @@ GLConvOpen(vlc_object_t *obj)
 
     HRESULT hr;
     int adapter = -1;
-    d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueDevice( tc->dec_device );
+    d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueContext( tc->vctx );
     if ( d3d9_decoder != NULL )
     {
         D3D9_CloneExternal(&priv->hd3d, d3d9_decoder->device);
-- 
2.17.1



More information about the vlc-devel mailing list