[vlc-devel] [PATCH 10/18] opengl: expose opengl_importer_init()

Romain Vimont rom1v at videolabs.io
Fri Dec 20 15:48:52 CET 2019


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

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index c742690035..b9e3c6ad11 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_importer *imp,
     return VLC_SUCCESS;
 }
 
-static int
-opengl_importer_init(struct vlc_gl_importer *imp, GLenum tex_target,
-                     vlc_fourcc_t chroma, bool is_yuv,
-                     const vlc_chroma_description_t *desc,
-                     video_color_space_t yuv_space)
+int
+opengl_importer_init_impl(struct vlc_gl_importer *imp, 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(!imp->fmt.p_palette);
     imp->sw_fmt = imp->fmt;
     imp->sw_fmt.i_chroma = chroma;
@@ -574,8 +578,8 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
     if (desc == NULL)
         return 0;
 
-    ret = opengl_importer_init(&tc->importer, tex_target, chroma, is_yuv,
-                               desc, yuv_space);
+    ret = opengl_importer_init_impl(&tc->importer, tex_target, chroma,
+                                    yuv_space);
     if (ret != VLC_SUCCESS)
         return 0;
 
diff --git a/modules/video_output/opengl/importer.h b/modules/video_output/opengl/importer.h
index 22ca3b76d6..b18384fd96 100644
--- a/modules/video_output/opengl/importer.h
+++ b/modules/video_output/opengl/importer.h
@@ -148,6 +148,20 @@ struct vlc_gl_importer {
 
     void *priv;
     const struct vlc_gl_importer_ops *ops;
+
+    /* Set by the caller to opengl_importer_init_impl().
+     * This avoids each module to link against opengl_importer_init_impl()
+     * directly. */
+    int
+    (*init)(struct vlc_gl_importer *imp, GLenum tex_target,
+            vlc_fourcc_t chroma, video_color_space_t yuv_space);
 };
 
+static inline int
+opengl_importer_init(struct vlc_gl_importer *imp, GLenum tex_target,
+                     vlc_fourcc_t chroma, video_color_space_t yuv_space)
+{
+    return imp->init(imp, tex_target, chroma, yuv_space);
+}
+
 #endif
diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 9cac74bf9a..2c64a6d72e 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 "importer.h"
+
+int
+opengl_importer_init_impl(struct vlc_gl_importer *imp, 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/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 06e58bd239..8528622476 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
 
+    imp->init = opengl_importer_init_impl;
     imp->ops = NULL;
     imp->glexts = glexts;
     imp->fmt = *fmt;
-- 
2.24.1



More information about the vlc-devel mailing list