mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 04:52:28 +00:00
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
This commit is contained in:
parent
c6f19511b5
commit
969089f7a8
1 changed files with 14 additions and 12 deletions
|
@ -570,6 +570,7 @@ struct _GstGLVideoMixerPad
|
||||||
|
|
||||||
gboolean geometry_change;
|
gboolean geometry_change;
|
||||||
GLuint vertex_buffer;
|
GLuint vertex_buffer;
|
||||||
|
gfloat m_matrix[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstGLVideoMixerPadClass
|
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_src_alpha = DEFAULT_PAD_BLEND_FUNCTION_SRC_ALPHA;
|
||||||
pad->blend_function_dst_rgb = DEFAULT_PAD_BLEND_FUNCTION_DST_RGB;
|
pad->blend_function_dst_rgb = DEFAULT_PAD_BLEND_FUNCTION_DST_RGB;
|
||||||
pad->blend_function_dst_alpha = DEFAULT_PAD_BLEND_FUNCTION_DST_ALPHA;
|
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
|
static void
|
||||||
|
@ -1547,16 +1553,11 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
||||||
w = ((gfloat) pad_width / (gfloat) out_width);
|
w = ((gfloat) pad_width / (gfloat) out_width);
|
||||||
h = ((gfloat) pad_height / (gfloat) out_height);
|
h = ((gfloat) pad_height / (gfloat) out_height);
|
||||||
|
|
||||||
/* top-left */
|
pad->m_matrix[0] = w;
|
||||||
v_vertices[0] = v_vertices[15] =
|
pad->m_matrix[5] = h;
|
||||||
2.0f * (gfloat) pad->xpos / (gfloat) out_width - 1.0f;
|
pad->m_matrix[12] = (gfloat) pad->xpos / (gfloat) out_width;
|
||||||
/* bottom-left */
|
pad->m_matrix[13] = (gfloat) pad->ypos / (gfloat) out_height;
|
||||||
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;
|
|
||||||
GST_TRACE ("processing texture:%u dimensions:%ux%u, at %f,%f %fx%f with "
|
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],
|
"alpha:%f", in_tex, in_width, in_height, v_vertices[0], v_vertices[1],
|
||||||
v_vertices[5], v_vertices[11], pad->alpha);
|
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->GenBuffers (1, &pad->vertex_buffer);
|
||||||
|
|
||||||
gl->BindBuffer (GL_ARRAY_BUFFER, pad->vertex_buffer);
|
gl->BindBuffer (GL_ARRAY_BUFFER, pad->vertex_buffer);
|
||||||
|
|
||||||
gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), v_vertices,
|
gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), v_vertices,
|
||||||
GL_STATIC_DRAW);
|
GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
@ -1583,11 +1583,13 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
||||||
{
|
{
|
||||||
GstVideoAffineTransformationMeta *af_meta;
|
GstVideoAffineTransformationMeta *af_meta;
|
||||||
gfloat matrix[16];
|
gfloat matrix[16];
|
||||||
|
gfloat af_matrix[16];
|
||||||
GstBuffer *buffer =
|
GstBuffer *buffer =
|
||||||
gst_video_aggregator_pad_get_current_buffer (vagg_pad);
|
gst_video_aggregator_pad_get_current_buffer (vagg_pad);
|
||||||
|
|
||||||
af_meta = gst_buffer_get_video_affine_transformation_meta (buffer);
|
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,
|
gst_gl_shader_set_uniform_matrix_4fv (video_mixer->shader,
|
||||||
"u_transformation", 1, FALSE, matrix);
|
"u_transformation", 1, FALSE, matrix);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue