vlc | branch: master | Romain Vimont <[email protected]> | Thu Feb 6 11:22:29 2020 +0100| [69cbe5bebc062888271046765a65e9f2bf74a1df] | committer: Alexandre Janniaux
opengl: move orientation matrix init to sampler The orientation matrix is managed by the sampler. Move its initialization to opengl_fragment_shader_init() (called by the sampler). Signed-off-by: Alexandre Janniaux <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=69cbe5bebc062888271046765a65e9f2bf74a1df --- modules/video_output/opengl/fragment_shaders.c | 72 +++++++++++++++++++++++++- modules/video_output/opengl/internal.h | 3 +- modules/video_output/opengl/renderer.c | 68 ------------------------ modules/video_output/opengl/sampler.c | 3 +- 4 files changed, 75 insertions(+), 71 deletions(-) diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c index a379b9d754..eab265dce7 100644 --- a/modules/video_output/opengl/fragment_shaders.c +++ b/modules/video_output/opengl/fragment_shaders.c @@ -499,9 +499,77 @@ opengl_init_swizzle(const struct vlc_gl_interop *interop, return VLC_SUCCESS; } +static void +InitOrientationMatrix(GLfloat matrix[static 4*4], + video_orientation_t orientation) +{ + memcpy(matrix, MATRIX4_IDENTITY, sizeof(MATRIX4_IDENTITY)); + + const int k_cos_pi = -1; + const int k_cos_pi_2 = 0; + const int k_cos_n_pi_2 = 0; + + const int k_sin_pi = 0; + const int k_sin_pi_2 = 1; + const int k_sin_n_pi_2 = -1; + + switch (orientation) { + + case ORIENT_ROTATED_90: + matrix[0 * 4 + 0] = k_cos_pi_2; + matrix[0 * 4 + 1] = -k_sin_pi_2; + matrix[1 * 4 + 0] = k_sin_pi_2; + matrix[1 * 4 + 1] = k_cos_pi_2; + matrix[3 * 4 + 1] = 1; + break; + case ORIENT_ROTATED_180: + matrix[0 * 4 + 0] = k_cos_pi; + matrix[0 * 4 + 1] = -k_sin_pi; + matrix[1 * 4 + 0] = k_sin_pi; + matrix[1 * 4 + 1] = k_cos_pi; + matrix[3 * 4 + 0] = 1; + matrix[3 * 4 + 1] = 1; + break; + case ORIENT_ROTATED_270: + matrix[0 * 4 + 0] = k_cos_n_pi_2; + matrix[0 * 4 + 1] = -k_sin_n_pi_2; + matrix[1 * 4 + 0] = k_sin_n_pi_2; + matrix[1 * 4 + 1] = k_cos_n_pi_2; + matrix[3 * 4 + 0] = 1; + break; + case ORIENT_HFLIPPED: + matrix[0 * 4 + 0] = -1; + matrix[3 * 4 + 0] = 1; + break; + case ORIENT_VFLIPPED: + matrix[1 * 4 + 1] = -1; + matrix[3 * 4 + 1] = 1; + break; + case ORIENT_TRANSPOSED: + matrix[0 * 4 + 0] = 0; + matrix[1 * 4 + 1] = 0; + matrix[2 * 4 + 2] = -1; + matrix[0 * 4 + 1] = 1; + matrix[1 * 4 + 0] = 1; + break; + case ORIENT_ANTI_TRANSPOSED: + matrix[0 * 4 + 0] = 0; + matrix[1 * 4 + 1] = 0; + matrix[2 * 4 + 2] = -1; + matrix[0 * 4 + 1] = -1; + matrix[1 * 4 + 0] = -1; + matrix[3 * 4 + 0] = 1; + matrix[3 * 4 + 1] = 1; + break; + default: + break; + } +} + int opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target, - vlc_fourcc_t chroma, video_color_space_t yuv_space) + vlc_fourcc_t chroma, video_color_space_t yuv_space, + video_orientation_t orientation) { struct vlc_gl_interop *interop = sampler->interop; @@ -513,6 +581,8 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target, if (desc == NULL) return VLC_EGENERIC; + InitOrientationMatrix(sampler->var.OrientationMatrix, orientation); + if (chroma == VLC_CODEC_XYZ12) return xyz12_shader_init(sampler); diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h index 14946de3f9..a8d8975f55 100644 --- a/modules/video_output/opengl/internal.h +++ b/modules/video_output/opengl/internal.h @@ -30,7 +30,8 @@ opengl_interop_init_impl(struct vlc_gl_interop *interop, GLenum tex_target, int opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, - GLenum, vlc_fourcc_t, video_color_space_t); + GLenum, vlc_fourcc_t, video_color_space_t, + video_orientation_t); int opengl_interop_generic_init(struct vlc_gl_interop *interop, bool); diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c index a8f71fea03..983429badd 100644 --- a/modules/video_output/opengl/renderer.c +++ b/modules/video_output/opengl/renderer.c @@ -99,72 +99,6 @@ static void getViewpointMatrixes(struct vlc_gl_renderer *renderer, } -static void getOrientationTransformMatrix(video_orientation_t orientation, - GLfloat matrix[static 16]) -{ - memcpy(matrix, MATRIX4_IDENTITY, sizeof(MATRIX4_IDENTITY)); - - const int k_cos_pi = -1; - const int k_cos_pi_2 = 0; - const int k_cos_n_pi_2 = 0; - - const int k_sin_pi = 0; - const int k_sin_pi_2 = 1; - const int k_sin_n_pi_2 = -1; - - switch (orientation) { - - case ORIENT_ROTATED_90: - matrix[0 * 4 + 0] = k_cos_pi_2; - matrix[0 * 4 + 1] = -k_sin_pi_2; - matrix[1 * 4 + 0] = k_sin_pi_2; - matrix[1 * 4 + 1] = k_cos_pi_2; - matrix[3 * 4 + 1] = 1; - break; - case ORIENT_ROTATED_180: - matrix[0 * 4 + 0] = k_cos_pi; - matrix[0 * 4 + 1] = -k_sin_pi; - matrix[1 * 4 + 0] = k_sin_pi; - matrix[1 * 4 + 1] = k_cos_pi; - matrix[3 * 4 + 0] = 1; - matrix[3 * 4 + 1] = 1; - break; - case ORIENT_ROTATED_270: - matrix[0 * 4 + 0] = k_cos_n_pi_2; - matrix[0 * 4 + 1] = -k_sin_n_pi_2; - matrix[1 * 4 + 0] = k_sin_n_pi_2; - matrix[1 * 4 + 1] = k_cos_n_pi_2; - matrix[3 * 4 + 0] = 1; - break; - case ORIENT_HFLIPPED: - matrix[0 * 4 + 0] = -1; - matrix[3 * 4 + 0] = 1; - break; - case ORIENT_VFLIPPED: - matrix[1 * 4 + 1] = -1; - matrix[3 * 4 + 1] = 1; - break; - case ORIENT_TRANSPOSED: - matrix[0 * 4 + 0] = 0; - matrix[1 * 4 + 1] = 0; - matrix[2 * 4 + 2] = -1; - matrix[0 * 4 + 1] = 1; - matrix[1 * 4 + 0] = 1; - break; - case ORIENT_ANTI_TRANSPOSED: - matrix[0 * 4 + 0] = 0; - matrix[1 * 4 + 1] = 0; - matrix[2 * 4 + 2] = -1; - matrix[0 * 4 + 1] = -1; - matrix[1 * 4 + 0] = -1; - matrix[3 * 4 + 0] = 1; - matrix[3 * 4 + 1] = 1; - break; - default: - break; - } -} - static void InitStereoMatrix(GLfloat matrix_out[static 3*3], video_multiview_mode_t multiview_mode) @@ -431,8 +365,6 @@ vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api, InitStereoMatrix(renderer->var.StereoMatrix, fmt->multiview_mode); - getOrientationTransformMatrix(fmt->orientation, - sampler->var.OrientationMatrix); getViewpointMatrixes(renderer, fmt->projection_mode); renderer->fmt = *fmt; diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c index a3f1405bd7..93cc24956e 100644 --- a/modules/video_output/opengl/sampler.c +++ b/modules/video_output/opengl/sampler.c @@ -85,7 +85,8 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop) int ret = opengl_fragment_shader_init(sampler, interop->tex_target, interop->sw_fmt.i_chroma, - interop->sw_fmt.space); + interop->sw_fmt.space, + interop->sw_fmt.orientation); if (ret != VLC_SUCCESS) { free(sampler); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
