[vlc-commits] opengl: expose opengl_interop_init()

Romain Vimont git at videolan.org
Mon Jan 13 11:44:18 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Wed Dec  4 15:24:52 2019 +0100| [f8910954daaacb5fe7959399cb11576abba4097f] | committer: Thomas Guillem

opengl: expose opengl_interop_init()

This function is intended to be called from "glconv" modules, instead of
opengl_fragment_shader_init().

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

 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 2eed0eb02f..069bc623ef 100644
--- a/modules/video_output/opengl/interop.h
+++ b/modules/video_output/opengl/interop.h
@@ -134,6 +134,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 9b5e807d8c..a4c351b46a 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;



More information about the vlc-commits mailing list