summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2015-07-21 23:48:25 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2015-07-22 13:17:18 -0400
commit17788157a10f3834f603af3697f9174b9048ce2d (patch)
tree4ffb521c9df8e2be3cdd4365a02b18ae513effdb /gst-libs
parentb155f5d73e2aafd6b8b3118538fd896e66671937 (diff)
downloadgstreamer-plugins-bad-17788157a10f3834f603af3697f9174b9048ce2d.tar.gz
composition-overlay: Positions are relative to texture
The coordinate are relative to the texture dimension and not the window dimension now. There is no need to pass the window dimension or to update the overlay if the dimension changes. https://bugzilla.gnome.org/show_bug.cgi?id=745107
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/gl/gstglcompositionoverlay.c33
-rw-r--r--gst-libs/gst/gl/gstglcompositionoverlay.h2
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.c13
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.h2
4 files changed, 12 insertions, 38 deletions
diff --git a/gst-libs/gst/gl/gstglcompositionoverlay.c b/gst-libs/gst/gl/gstglcompositionoverlay.c
index e1268cb3f..181db4aa5 100644
--- a/gst-libs/gst/gl/gstglcompositionoverlay.c
+++ b/gst-libs/gst/gl/gstglcompositionoverlay.c
@@ -42,7 +42,7 @@ G_DEFINE_TYPE_WITH_CODE (GstGLCompositionOverlay, gst_gl_composition_overlay,
static void gst_gl_composition_overlay_finalize (GObject * object);
static void
gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
- overlay, GstBuffer * video_buffer, guint window_width, guint window_height);
+ overlay, GstBuffer * video_buffer);
static void
gst_gl_composition_overlay_class_init (GstGLCompositionOverlayClass * klass)
@@ -204,7 +204,7 @@ gst_gl_composition_overlay_init_vertex_buffer (GstGLContext * context,
static void
gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
- overlay, GstBuffer * video_buffer, guint window_width, guint window_height)
+ overlay, GstBuffer * video_buffer)
{
gint comp_x, comp_y;
guint comp_width, comp_height;
@@ -213,19 +213,13 @@ gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
float rel_x, rel_y, rel_w, rel_h;
- gfloat window_aspect = 1.0;
- gfloat video_aspect = 1.0;
-
meta = gst_buffer_get_video_meta (video_buffer);
gst_video_overlay_rectangle_get_render_rectangle (overlay->rectangle,
&comp_x, &comp_y, &comp_width, &comp_height);
- width = window_width;
- height = window_height;
-
- window_aspect = (float) width / (float) height;
- video_aspect = (float) meta->width / (float) meta->height;
+ width = meta->width;
+ height = meta->height;
/* calculate relative position */
rel_x = (float) comp_x / (float) width;
@@ -234,15 +228,6 @@ gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
rel_w = (float) comp_width / (float) width;
rel_h = (float) comp_height / (float) height;
- /* transform to window aspect ratio */
- if (window_aspect <= video_aspect) {
- rel_y *= video_aspect / window_aspect;
- rel_h *= video_aspect / window_aspect;
- } else {
- rel_x *= window_aspect / video_aspect;
- rel_w *= window_aspect / video_aspect;
- }
-
/* transform from [0,1] to [-1,1], invert y axis */
rel_x = rel_x * 2.0 - 1.0;
rel_y = (1.0 - rel_y) * 2.0 - 1.0;
@@ -274,14 +259,13 @@ gst_gl_composition_overlay_add_transformation (GstGLCompositionOverlay *
gst_gl_composition_overlay_init_vertex_buffer, overlay);
GST_DEBUG
- ("overlay position: (%d,%d) size: %dx%d video size: %dx%d, sink window %dx%d",
- comp_x, comp_y, comp_width, comp_height, meta->width, meta->height,
- window_width, window_height);
+ ("overlay position: (%d,%d) size: %dx%d video size: %dx%d",
+ comp_x, comp_y, comp_width, comp_height, meta->width, meta->height);
}
void
gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
- GstBuffer * buf, guint window_width, guint window_height)
+ GstBuffer * buf)
{
GstMapInfo info;
GstVideoMeta *vmeta;
@@ -306,8 +290,7 @@ gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
meta = gst_buffer_get_video_meta (comp_buffer);
- gst_gl_composition_overlay_add_transformation (overlay, buf, window_width,
- window_height);
+ gst_gl_composition_overlay_add_transformation (overlay, buf);
gst_video_info_init (&text_info);
gst_video_info_set_format (&text_info, meta->format, meta->width,
diff --git a/gst-libs/gst/gl/gstglcompositionoverlay.h b/gst-libs/gst/gl/gstglcompositionoverlay.h
index a7a7ccb10..005ef2f6e 100644
--- a/gst-libs/gst/gl/gstglcompositionoverlay.h
+++ b/gst-libs/gst/gl/gstglcompositionoverlay.h
@@ -74,7 +74,7 @@ GstGLCompositionOverlay *gst_gl_composition_overlay_new (GstGLContext * context,
GLint texcoord_attrib);
void gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
- GstBuffer * buf, guint window_width, guint window_height);
+ GstBuffer * buf);
void gst_gl_composition_overlay_draw (GstGLCompositionOverlay * overlay,
GstGLShader * shader);
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.c b/gst-libs/gst/gl/gstgloverlaycompositor.c
index 9b164abb3..dfafdb2db 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.c
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.c
@@ -153,18 +153,10 @@ gst_gl_overlay_compositor_free_overlays (GstGLOverlayCompositor * compositor)
void
gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor,
- GstBuffer * buf, guint window_width, guint window_height)
+ GstBuffer * buf)
{
GstVideoOverlayCompositionMeta *composition_meta;
- if (compositor->last_window_width != window_width ||
- compositor->last_window_height != window_height) {
- gst_gl_overlay_compositor_free_overlays (compositor);
- compositor->last_window_width = window_width;
- compositor->last_window_height = window_height;
- GST_DEBUG ("window size changed, freeing overlays");
- }
-
composition_meta = gst_buffer_get_video_overlay_composition_meta (buf);
if (composition_meta) {
GstVideoOverlayComposition *composition = NULL;
@@ -186,8 +178,7 @@ gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor,
gst_gl_composition_overlay_new (compositor->context, rectangle,
compositor->position_attrib, compositor->texcoord_attrib);
- gst_gl_composition_overlay_upload (overlay, buf, window_width,
- window_height);
+ gst_gl_composition_overlay_upload (overlay, buf);
compositor->overlays = g_list_append (compositor->overlays, overlay);
}
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.h b/gst-libs/gst/gl/gstgloverlaycompositor.h
index cd8ae858d..d35a5c0d0 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.h
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.h
@@ -69,7 +69,7 @@ GstGLOverlayCompositor *gst_gl_overlay_compositor_new (GstGLContext * context);
void gst_gl_overlay_compositor_free_overlays (GstGLOverlayCompositor * compositor);
void gst_gl_overlay_compositor_upload_overlays (GstGLOverlayCompositor * compositor,
- GstBuffer * buf, guint window_width, guint window_height);
+ GstBuffer * buf);
void gst_gl_overlay_compositor_draw_overlays (GstGLOverlayCompositor * compositor);