[vlc-commits] [Git][videolan/vlc][master] 7 commits: opengl: interop_dxva2: move manifest to the end

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Dec 5 09:58:43 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
1446d1d8 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
opengl: interop_dxva2: move manifest to the end

Moving the manifest will allow to remove the forward declarations.

- - - - -
ad444c46 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
opengl: interop_dxva2: remove forward declaration

- - - - -
9398344e by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
opengl: interop_dxva2: use interop close callback

Use the close callback from the vlc_gl_interop operation API instead of
relying on a module_unneed call from the module, while avoiding the cast
from vlc_object_t.

- - - - -
15580132 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
nvdec_gl: move manifest to the end

Moving the manifest will allow to remove the forward declarations.

- - - - -
756f55b6 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
nvdec_gl: remove forward declaration

- - - - -
7e0ac982 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
nvdec_gl: move Close function to interop

Use the close callback from the vlc_gl_interop operation API instead of
relying on a module_unneed call from the module, while avoiding the
cast from vlc_object_t.

- - - - -
396ab4f6 by Alexandre Janniaux at 2023-12-05T09:34:29+00:00
opengl: interop: change signature

Provides the vlc_gl_interop object as parameter to the activate function
for the modules, instead of a generic vlc_object_t. This removes the
need for casting the vlc_object_t and clarify how interop modules are
loaded. The new activation function will also allow to supply new
parameters in the future.

- - - - -


10 changed files:

- include/vlc_opengl_interop.h
- modules/hw/nvdec/nvdec_gl.c
- modules/video_output/opengl/interop.c
- modules/video_output/opengl/interop_android.c
- modules/video_output/opengl/interop_cvpx.m
- modules/video_output/opengl/interop_dxva2.c
- modules/video_output/opengl/interop_gst_mem.c
- modules/video_output/opengl/interop_sw.c
- modules/video_output/opengl/interop_vaapi.c
- modules/video_output/opengl/interop_vdpau.c


Changes:

=====================================
include/vlc_opengl_interop.h
=====================================
@@ -157,6 +157,9 @@ struct vlc_gl_interop {
                            uint32_t format, int32_t internal, uint32_t type);
 };
 
+/* Activation function for the OpenGL interop implementations. */
+typedef int (*vlc_gl_interop_probe)(struct vlc_gl_interop *interop);
+
 static inline int
 vlc_gl_interop_GetTexFormatSize(struct vlc_gl_interop *interop, uint32_t target,
                                 uint32_t format, int32_t internal,


=====================================
modules/hw/nvdec/nvdec_gl.c
=====================================
@@ -41,17 +41,6 @@
 #  include <GL/glext.h>
 #endif
 
-static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
-
-vlc_module_begin ()
-    set_description("NVDEC OpenGL surface converter")
-    set_capability("glinterop", 2)
-    set_callbacks(Open, Close)
-    set_subcategory(SUBCAT_VIDEO_VOUT)
-    add_shortcut("nvdec")
-vlc_module_end ()
-
 typedef struct {
     vlc_decoder_device *device;
     CUcontext cuConverterCtx;
@@ -149,16 +138,14 @@ error:
     return result;
 }
 
-static void Close(vlc_object_t *obj)
+static void tc_nvdec_gl_close(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *)obj;
     converter_sys_t *p_sys = interop->priv;
     vlc_decoder_device_Release(p_sys->device);
 }
 
-static int Open(vlc_object_t *obj)
+static int Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     if (!is_nvdec_opaque(interop->fmt_in.i_chroma))
         return VLC_EGENERIC;
 
@@ -286,9 +273,18 @@ static int Open(vlc_object_t *obj)
     static const struct vlc_gl_interop_ops ops = {
         .allocate_textures = tc_nvdec_gl_allocate_texture,
         .update_textures = tc_nvdec_gl_update,
+        .close = tc_nvdec_gl_close,
     };
     interop->ops = &ops;
     interop->priv = p_sys;
 
     return VLC_SUCCESS;
 }
+
+vlc_module_begin ()
+    set_description("NVDEC OpenGL surface converter")
+    set_capability("glinterop", 2)
+    set_callback(Open)
+    set_subcategory(SUBCAT_VIDEO_VOUT)
+    add_shortcut("nvdec")
+vlc_module_end ()


=====================================
modules/video_output/opengl/interop.c
=====================================
@@ -150,6 +150,14 @@ static int GetTexFormatSize(struct vlc_gl_interop *interop, GLenum target,
     return size > 0 ? size * mul : size;
 }
 
+static int
+LoadInterop(void *func, bool forced, va_list args)
+{
+    vlc_gl_interop_probe start = func;
+    struct vlc_gl_interop *interop = va_arg(args, struct vlc_gl_interop *);
+    return start(interop);
+}
+
 struct vlc_gl_interop *
 vlc_gl_interop_New(struct vlc_gl_t *gl, vlc_video_context *context,
                    const video_format_t *fmt)
@@ -159,6 +167,7 @@ vlc_gl_interop_New(struct vlc_gl_t *gl, vlc_video_context *context,
         return NULL;
 
     struct vlc_gl_interop *interop = &priv->interop;
+    struct vlc_logger *logger = vlc_object_logger(interop);
 
     interop->get_tex_format_size = GetTexFormatSize;
     interop->ops = NULL;
@@ -186,12 +195,15 @@ vlc_gl_interop_New(struct vlc_gl_t *gl, vlc_video_context *context,
         /* Opaque chroma: load a module to handle it */
         assert(context);
         interop->vctx = vlc_video_context_Hold(context);
-        interop->module = module_need_var(interop, "glinterop", "glinterop");
+        char *interop_name = var_InheritString(interop, "glinterop");
+        interop->module = vlc_module_load(logger, "glinterop", interop_name,
+                                          true, LoadInterop, interop);
     }
     else
     {
         interop->vctx = NULL;
-        interop->module = module_need(interop, "opengl sw interop", NULL, false);
+        interop->module = vlc_module_load(logger, "opengl sw interop", NULL,
+                                          false, LoadInterop, interop);
     }
 
     if (interop->module == NULL)


=====================================
modules/video_output/opengl/interop_android.c
=====================================
@@ -189,10 +189,8 @@ Close(struct vlc_gl_interop *interop)
 }
 
 static int
-Open(vlc_object_t *obj)
+Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
-
     if (interop->fmt_in.i_chroma != VLC_CODEC_ANDROID_OPAQUE
      || !interop->vctx)
         return VLC_EGENERIC;


=====================================
modules/video_output/opengl/interop_cvpx.m
=====================================
@@ -174,10 +174,8 @@ Close(struct vlc_gl_interop *interop)
 }
 
 static int
-Open(vlc_object_t *obj)
+Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
-
     if (interop->fmt_in.i_chroma != VLC_CODEC_CVPX_UYVY
      && interop->fmt_in.i_chroma != VLC_CODEC_CVPX_NV12
      && interop->fmt_in.i_chroma != VLC_CODEC_CVPX_I420


=====================================
modules/video_output/opengl/interop_dxva2.c
=====================================
@@ -53,22 +53,6 @@
 #include <GL/glew.h>
 #include <GL/wglew.h>
 
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-static int  GLConvOpen(vlc_object_t *);
-static void GLConvClose(vlc_object_t *);
-
-vlc_module_begin ()
-    set_shortname("dxva2")
-    set_subcategory(SUBCAT_VIDEO_VOUT)
-    set_description("DXVA2 surface converter")
-    set_capability("glinterop", 1)
-    set_callbacks(GLConvOpen, GLConvClose)
-
-    add_bool("direct3d9-dxvahd", true, DXVAHD_TEXT, NULL)
-vlc_module_end ()
-
 struct wgl_vt {
     PFNWGLGETEXTENSIONSSTRINGEXTPROC     GetExtensionsStringEXT;
     PFNWGLGETEXTENSIONSSTRINGARBPROC     GetExtensionsStringARB;
@@ -197,9 +181,8 @@ GLConvAllocateTextures(const struct vlc_gl_interop *interop, uint32_t textures[]
 }
 
 static void
-GLConvClose(vlc_object_t *obj)
+GLConvClose(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = container_of(obj, struct vlc_gl_interop, obj);
     struct glpriv *priv = interop->priv;
 
     if (priv->gl_handle_d3d)
@@ -419,10 +402,8 @@ error:
 }
 
 static int
-GLConvOpen(vlc_object_t *obj)
+GLConvOpen(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = container_of(obj, struct vlc_gl_interop, obj);
-
     if (interop->fmt_in.i_chroma != VLC_CODEC_D3D9_OPAQUE
      && interop->fmt_in.i_chroma != VLC_CODEC_D3D9_OPAQUE_10B)
         return VLC_EGENERIC;
@@ -434,7 +415,7 @@ GLConvOpen(vlc_object_t *obj)
 
     if (!d3d9_decoder->hd3d.use_ex)
     {
-        msg_Warn(obj, "DX/GL interrop only working on d3d9x");
+        msg_Warn(interop, "DX/GL interrop only working on d3d9x");
         return VLC_EGENERIC;
     }
     HGLRC hGLRC = wglGetCurrentContext();
@@ -446,7 +427,7 @@ GLConvOpen(vlc_object_t *obj)
 #define LOAD_EXT(name, type) do { \
     vt.name = (type) vlc_gl_GetProcAddress(interop->gl, "wgl" #name); \
     if (!vt.name) { \
-        msg_Warn(obj, "'wgl " #name "' could not be loaded"); \
+        msg_Warn(interop, "'wgl " #name "' could not be loaded"); \
         return VLC_EGENERIC; \
     } \
 } while(0)
@@ -519,7 +500,7 @@ GLConvOpen(vlc_object_t *obj)
                                                &priv->dx_render, &shared_handle);
     if (FAILED(hr))
     {
-        msg_Warn(obj, "IDirect3DDevice9Ex_CreateRenderTarget failed");
+        msg_Warn(interop, "IDirect3DDevice9Ex_CreateRenderTarget failed");
         goto error;
     }
 
@@ -529,13 +510,14 @@ GLConvOpen(vlc_object_t *obj)
     priv->gl_handle_d3d = priv->vt.DXOpenDeviceNV(d3d9_decoder->d3ddev.devex);
     if (!priv->gl_handle_d3d)
     {
-        msg_Warn(obj, "DXOpenDeviceNV failed: %lu", GetLastError());
+        msg_Warn(interop, "DXOpenDeviceNV failed: %lu", GetLastError());
         goto error;
     }
 
     static const struct vlc_gl_interop_ops ops = {
         .allocate_textures = GLConvAllocateTextures,
         .update_textures = GLConvUpdate,
+        .close = GLConvClose,
     };
     interop->ops = &ops;
 
@@ -558,6 +540,16 @@ GLConvOpen(vlc_object_t *obj)
     return VLC_SUCCESS;
 
 error:
-    GLConvClose(obj);
+    GLConvClose(interop);
     return VLC_EGENERIC;
 }
+
+vlc_module_begin ()
+    set_shortname("dxva2")
+    set_subcategory(SUBCAT_VIDEO_VOUT)
+    set_description("DXVA2 surface converter")
+    set_capability("glinterop", 1)
+    set_callback(GLConvOpen)
+
+    add_bool("direct3d9-dxvahd", true, DXVAHD_TEXT, NULL)
+vlc_module_end ()


=====================================
modules/video_output/opengl/interop_gst_mem.c
=====================================
@@ -167,9 +167,8 @@ Close(struct vlc_gl_interop *interop)
 }
 
 static int
-Open(vlc_object_t *obj)
+Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     struct priv *priv = NULL;
 
     if (interop->vctx == NULL)


=====================================
modules/video_output/opengl/interop_sw.c
=====================================
@@ -821,15 +821,13 @@ error:
     return VLC_EGENERIC;
 }
 
-static int OpenInteropSW(vlc_object_t *obj)
+static int OpenInteropSW(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     return opengl_interop_generic_init(interop, false);
 }
 
-static int OpenInteropDirectRendering(vlc_object_t *obj)
+static int OpenInteropDirectRendering(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     return opengl_interop_generic_init(interop, true);
 }
 


=====================================
modules/video_output/opengl/interop_vaapi.c
=====================================
@@ -428,9 +428,8 @@ done:
 }
 
 static int
-Open(vlc_object_t *obj)
+Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     struct priv *priv = NULL;
 
     if (interop->vctx == NULL)


=====================================
modules/video_output/opengl/interop_vdpau.c
=====================================
@@ -120,9 +120,8 @@ Close(struct vlc_gl_interop *interop)
 }
 
 static int
-Open(vlc_object_t *obj)
+Open(struct vlc_gl_interop *interop)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
     if (interop->vctx == NULL)
         return VLC_EGENERIC;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1d076bd5e82b11d4f3f6027102d23ea7b129bcc4...396ab4f67cbec90f07fcc781276c7bd632ca104b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1d076bd5e82b11d4f3f6027102d23ea7b129bcc4...396ab4f67cbec90f07fcc781276c7bd632ca104b
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list