gloverlaycompositor: add subtitle rotate support follow video
upstream status: Pending
https://bugzilla.gnome.org/show_bug.cgi?id=790470
diff --git a/ext/gl/gstglimagesink.c b/ext/gl/gstglimagesink.c
index 102c766..37a7539 100644
--- a/ext/gl/gstglimagesink.c
+++ b/ext/gl/gstglimagesink.c
@@ -2208,6 +2208,9 @@
GstGLWindow *window = NULL;
gboolean do_redisplay = FALSE;
GstSample *sample = NULL;
+ GstVideoAffineTransformationMeta *af_meta;
+ gfloat matrix[16];
+
guint gl_target = gst_gl_texture_target_to_gl (gl_sink->texture_target);
g_return_if_fail (GST_IS_GLIMAGE_SINK (gl_sink));
@@ -2322,27 +2325,23 @@
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (gl_target, gl_sink->redisplay_texture);
gst_gl_shader_set_uniform_1i (gl_sink->redisplay_shader, "tex", 0);
- {
- GstVideoAffineTransformationMeta *af_meta;
- gfloat matrix[16];
- af_meta =
- gst_buffer_get_video_affine_transformation_meta
- (gl_sink->stored_buffer[0]);
+ af_meta =
+ gst_buffer_get_video_affine_transformation_meta
+ (gl_sink->stored_buffer[0]);
- if (gl_sink->transform_matrix) {
- gfloat tmp[16];
+ if (gl_sink->transform_matrix) {
+ gfloat tmp[16];
- gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, tmp);
- gst_gl_multiply_matrix4 (tmp, gl_sink->transform_matrix, matrix);
- } else {
- gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, matrix);
- }
-
- gst_gl_shader_set_uniform_matrix_4fv (gl_sink->redisplay_shader,
- "u_transformation", 1, FALSE, matrix);
+ gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, tmp);
+ gst_gl_multiply_matrix4 (tmp, gl_sink->transform_matrix, matrix);
+ } else {
+ gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, matrix);
}
+ gst_gl_shader_set_uniform_matrix_4fv (gl_sink->redisplay_shader,
+ "u_transformation", 1, FALSE, matrix);
+
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
gl->BindTexture (gl_target, 0);
@@ -2355,7 +2354,7 @@
if (gl_sink->ignore_alpha)
gl->Disable (GL_BLEND);
- gst_gl_overlay_compositor_draw_overlays (gl_sink->overlay_compositor);
+ gst_gl_overlay_compositor_draw_overlays (gl_sink->overlay_compositor, matrix);
}
/* end default opengl scene */
window->is_drawing = FALSE;
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.c b/gst-libs/gst/gl/gstgloverlaycompositor.c
index 05575aa..2d6b2df 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.c
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.c
@@ -38,6 +38,7 @@
#include "gstglmemory.h"
#include "gstglshader.h"
#include "gstglslstage.h"
+#include "gstglshaderstrings.h"
GST_DEBUG_CATEGORY_STATIC (gst_gl_overlay_compositor_debug);
#define GST_CAT_DEFAULT gst_gl_overlay_compositor_debug
@@ -457,7 +458,10 @@
if (!(compositor->shader =
gst_gl_shader_new_link_with_stages (context, &error,
- gst_glsl_stage_new_default_vertex (context),
+ gst_glsl_stage_new_with_string (context,
+ GL_VERTEX_SHADER, GST_GLSL_VERSION_NONE,
+ GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
+ gst_gl_shader_string_vertex_mat4_vertex_transform),
gst_glsl_stage_new_with_string (context, GL_FRAGMENT_SHADER,
GST_GLSL_VERSION_NONE,
GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
@@ -606,7 +610,7 @@
}
void
-gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor)
+gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor, gfloat *matrix)
{
const GstGLFuncs *gl = compositor->context->gl_vtable;
if (compositor->overlays != NULL) {
@@ -619,6 +623,9 @@
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (compositor->shader, "tex", 0);
+ gst_gl_shader_set_uniform_matrix_4fv (compositor->shader,
+ "u_transformation", 1, FALSE, matrix);
+
for (l = compositor->overlays; l != NULL; l = l->next) {
GstGLCompositionOverlay *overlay = (GstGLCompositionOverlay *) l->data;
gst_gl_composition_overlay_draw (overlay, compositor->shader);
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.h b/gst-libs/gst/gl/gstgloverlaycompositor.h
index d56e498..0c6672d 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.h
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.h
@@ -83,7 +83,7 @@
GstBuffer * buf);
GST_GL_API
-void gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor);
+void gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor, gfloat * matrix);
GST_GL_API
GstCaps * gst_gl_overlay_compositor_add_caps(GstCaps * caps);