[vlc-commits] opengl: extract interop initialization

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


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Mon Dec  2 17:24:50 2019 +0100| [f0c92e961312397d69ba761640f669259a7f5f78] | committer: Thomas Guillem

opengl: extract interop initialization

Move interop-specific initialization out of
opengl_fragment_shader_init_impl(), so that interops can be initialized
separately.

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

 modules/video_output/opengl/fragment_shaders.c | 53 +++++++++++++++++---------
 1 file changed, 34 insertions(+), 19 deletions(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index e54fdf389d..7686512c85 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -516,6 +516,32 @@ xyz12_shader_init(opengl_tex_converter_t *tc)
     return fragment_shader;
 }
 
+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,
+                    const char *swizzle_per_tex[])
+{
+    assert(!interop->fmt.p_palette);
+    interop->sw_fmt = interop->fmt;
+    interop->sw_fmt.i_chroma = chroma;
+    interop->sw_fmt.space = yuv_space;
+    interop->tex_target = tex_target;
+
+    if (chroma == VLC_CODEC_XYZ12)
+    {
+        interop_xyz12_init(interop);
+        return VLC_SUCCESS;
+    }
+
+    if (is_yuv)
+        return interop_yuv_base_init(interop, tex_target, chroma, desc,
+                                      swizzle_per_tex);
+
+    return interop_rgb_base_init(interop, tex_target, chroma);
+}
+
 GLuint
 opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
                                  vlc_fourcc_t chroma, video_color_space_t yuv_space)
@@ -527,33 +553,24 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
     bool yuv_swap_uv = false;
     int ret;
 
-    assert(!tc->interop.fmt.p_palette);
-    tc->interop.sw_fmt = tc->interop.fmt;
-    tc->interop.sw_fmt.i_chroma = chroma;
-    tc->interop.sw_fmt.space = yuv_space;
-
     const vlc_chroma_description_t *desc = vlc_fourcc_GetChromaDescription(chroma);
     if (desc == NULL)
         return 0;
 
+    ret = opengl_interop_init(&tc->interop, tex_target, chroma, is_yuv,
+                              desc, yuv_space, swizzle_per_tex);
+    if (ret != VLC_SUCCESS)
+        return 0;
+
     if (chroma == VLC_CODEC_XYZ12)
-    {
-        interop_xyz12_init(&tc->interop);
         return xyz12_shader_init(tc);
-    }
 
     if (is_yuv)
     {
-        ret = interop_yuv_base_init(&tc->interop, tex_target, chroma, desc,
-                                    swizzle_per_tex);
-        if (ret == VLC_SUCCESS)
-            ret = tc_yuv_base_init(tc, chroma, desc, yuv_space, &yuv_swap_uv);
+        ret = tc_yuv_base_init(tc, chroma, desc, yuv_space, &yuv_swap_uv);
+        if (ret != VLC_SUCCESS)
+            return 0;
     }
-    else
-        ret = interop_rgb_base_init(&tc->interop, tex_target, chroma);
-
-    if (ret != VLC_SUCCESS)
-        return 0;
 
     const char *sampler, *lookup, *coord_name;
     switch (tex_target)
@@ -777,8 +794,6 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
                 (const char *)&chroma, yuv_space, ms.ptr);
     free(ms.ptr);
 
-    interop->tex_target = tex_target;
-
     tc->pf_fetch_locations = tc_base_fetch_locations;
     tc->pf_prepare_shader = tc_base_prepare_shader;
 



More information about the vlc-commits mailing list