diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c index e54fdf389d5ada88ef6716f45e186f49ee7e4ee2..7686512c85e3f5639bfaaf91335865c2078ae5bc 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;