[vlc-devel] [PATCH v2 10/21] opengl: expose opengl_interop_init()

Romain Vimont rom1v at videolabs.io
Tue Jan 7 12:41:46 CET 2020


This function is intended to be called from "glconv" modules, instead of
opengl_fragment_shader_init().
---
 modules/video_output/opengl/fragment_shaders.c | 17 ++++++++++-------
 modules/video_output/opengl/internal.h         |  5 +++++
 modules/video_output/opengl/interop.h          | 14 ++++++++++++++
 modules/video_output/opengl/vout_helper.c      |  1 +
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 88ab71675e..77b4e98c41 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -535,12 +535,16 @@ opengl_init_swizzle(const struct vlc_gl_interop *interop,
     return VLC_SUCCESS;
 }
 
-static int
-opengl_interop_init(struct vlc_gl_interop *interop, GLenum tex_target,
-                    vlc_fourcc_t chroma, bool is_yuv,
-                    const vlc_chroma_description_t *desc,
-                    video_color_space_t yuv_space)
+int
+opengl_interop_init_impl(struct vlc_gl_interop *interop, GLenum tex_target,
+                         vlc_fourcc_t chroma, video_color_space_t yuv_space)
 {
+    bool is_yuv = vlc_fourcc_IsYUV(chroma);
+    const vlc_chroma_description_t *desc =
+        vlc_fourcc_GetChromaDescription(chroma);
+    if (!desc)
+        return VLC_EGENERIC;
+
     assert(!interop->fmt.p_palette);
     interop->sw_fmt = interop->fmt;
     interop->sw_fmt.i_chroma = chroma;
@@ -574,8 +578,7 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
     if (desc == NULL)
         return 0;
 
-    ret = opengl_interop_init(&tc->interop, tex_target, chroma, is_yuv,
-                              desc, yuv_space);
+    ret = opengl_interop_init_impl(&tc->interop, tex_target, chroma, yuv_space);
     if (ret != VLC_SUCCESS)
         return 0;
 
diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 9cac74bf9a..7b13c4bba4 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -22,6 +22,11 @@
 #define VLC_OPENGL_INTERNAL_H
 
 #include "converter.h"
+#include "interop.h"
+
+int
+opengl_interop_init_impl(struct vlc_gl_interop *interop, GLenum tex_target,
+                         vlc_fourcc_t chroma, video_color_space_t yuv_space);
 
 GLuint
 opengl_fragment_shader_init_impl(opengl_tex_converter_t *,
diff --git a/modules/video_output/opengl/interop.h b/modules/video_output/opengl/interop.h
index 402bcd2bcc..373811cafc 100644
--- a/modules/video_output/opengl/interop.h
+++ b/modules/video_output/opengl/interop.h
@@ -148,6 +148,20 @@ struct vlc_gl_interop {
 
     void *priv;
     const struct vlc_gl_interop_ops *ops;
+
+    /* Set by the caller to opengl_interop_init_impl().
+     * This avoids each module to link against opengl_interop_init_impl()
+     * directly. */
+    int
+    (*init)(struct vlc_gl_interop *interop, GLenum tex_target,
+            vlc_fourcc_t chroma, video_color_space_t yuv_space);
 };
 
+static inline int
+opengl_interop_init(struct vlc_gl_interop *interop, GLenum tex_target,
+                     vlc_fourcc_t chroma, video_color_space_t yuv_space)
+{
+    return interop->init(interop, tex_target, chroma, yuv_space);
+}
+
 #endif
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index e06f59fd74..a46850a6f1 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -550,6 +550,7 @@ opengl_init_program(vout_display_opengl_t *vgl, vlc_video_context *context,
     tc->glsl_precision_header = "";
 #endif
 
+    interop->init = opengl_interop_init_impl;
     interop->ops = NULL;
     interop->glexts = glexts;
     interop->fmt = *fmt;
-- 
2.25.0.rc0



More information about the vlc-devel mailing list