diff options
author | Daniel Klamt <d.klamt@pengutronix.de> | 2018-04-25 16:39:34 +0200 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2018-07-10 20:31:26 +1000 |
commit | 969089f7a8dc348fcdc2bf368bbc375938ea8c5f (patch) | |
tree | 17de217a8bdd87dacf480601ea49459ad42d2d9c | |
parent | c6f19511b514d4f4c8f142fb7bf6ce237eec9858 (diff) |
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
-rw-r--r-- | ext/gl/gstglvideomixer.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ext/gl/gstglvideomixer.c b/ext/gl/gstglvideomixer.c index 3879dbb07..6cb5c743b 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); } |