From: Daniel Klamt Date: Wed, 25 Apr 2018 14:39:34 +0000 (+0200) Subject: Moved the pad offset and aspect ratio to a matrix so it will be added in view space... X-Git-Tag: 1.19.3~511^2~1294^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1bd804cb35685b29d33b4b8db71f69defed09f7;p=platform%2Fupstream%2Fgstreamer.git Moved the pad offset and aspect ratio to a matrix so it will be added in view space and not in world space https://bugzilla.gnome.org/show_bug.cgi?id=794401 --- diff --git a/ext/gl/gstglvideomixer.c b/ext/gl/gstglvideomixer.c index 3879dbb..6cb5c74 100644 --- a/ext/gl/gstglvideomixer.c +++ b/ext/gl/gstglvideomixer.c @@ -570,6 +570,7 @@ struct _GstGLVideoMixerPad gboolean geometry_change; GLuint vertex_buffer; + gfloat m_matrix[16]; }; struct _GstGLVideoMixerPadClass @@ -616,6 +617,11 @@ gst_gl_video_mixer_pad_init (GstGLVideoMixerPad * pad) pad->blend_function_src_alpha = DEFAULT_PAD_BLEND_FUNCTION_SRC_ALPHA; pad->blend_function_dst_rgb = DEFAULT_PAD_BLEND_FUNCTION_DST_RGB; pad->blend_function_dst_alpha = DEFAULT_PAD_BLEND_FUNCTION_DST_ALPHA; + memset(pad->m_matrix, 0, sizeof(gfloat) * 4 * 4); + pad->m_matrix[0] = 1.0; + pad->m_matrix[5] = 1.0; + pad->m_matrix[10] = 1.0; + pad->m_matrix[15] = 1.0; } static void @@ -1547,16 +1553,11 @@ gst_gl_video_mixer_callback (gpointer stuff) w = ((gfloat) pad_width / (gfloat) out_width); h = ((gfloat) pad_height / (gfloat) out_height); - /* top-left */ - v_vertices[0] = v_vertices[15] = - 2.0f * (gfloat) pad->xpos / (gfloat) out_width - 1.0f; - /* bottom-left */ - v_vertices[1] = v_vertices[6] = - 2.0f * (gfloat) pad->ypos / (gfloat) out_height - 1.0f; - /* top-right */ - v_vertices[5] = v_vertices[10] = v_vertices[0] + 2.0f * w; - /* bottom-right */ - v_vertices[11] = v_vertices[16] = v_vertices[1] + 2.0f * h; + pad->m_matrix[0] = w; + pad->m_matrix[5] = h; + pad->m_matrix[12] = (gfloat) pad->xpos / (gfloat) out_width; + pad->m_matrix[13] = (gfloat) pad->ypos / (gfloat) out_height; + GST_TRACE ("processing texture:%u dimensions:%ux%u, at %f,%f %fx%f with " "alpha:%f", in_tex, in_width, in_height, v_vertices[0], v_vertices[1], v_vertices[5], v_vertices[11], pad->alpha); @@ -1565,7 +1566,6 @@ gst_gl_video_mixer_callback (gpointer stuff) gl->GenBuffers (1, &pad->vertex_buffer); gl->BindBuffer (GL_ARRAY_BUFFER, pad->vertex_buffer); - gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), v_vertices, GL_STATIC_DRAW); @@ -1583,11 +1583,13 @@ gst_gl_video_mixer_callback (gpointer stuff) { GstVideoAffineTransformationMeta *af_meta; gfloat matrix[16]; + gfloat af_matrix[16]; GstBuffer *buffer = gst_video_aggregator_pad_get_current_buffer (vagg_pad); af_meta = gst_buffer_get_video_affine_transformation_meta (buffer); - gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, matrix); + gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, af_matrix); + gst_gl_multiply_matrix4(af_matrix, pad->m_matrix, matrix); gst_gl_shader_set_uniform_matrix_4fv (video_mixer->shader, "u_transformation", 1, FALSE, matrix); }