Commit 5d98c9d5 authored by Kishore Arepalli's avatar Kishore Arepalli Committed by Sebastian Dröge

gdkpixbufoverlay: Allow negative offsets to specify offset from bottom/right

https://bugzilla.gnome.org/show_bug.cgi?id=702826
parent 4053e1d6
......@@ -138,14 +138,16 @@ gst_gdk_pixbuf_overlay_class_init (GstGdkPixbufOverlayClass * klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_OFFSET_X,
g_param_spec_int ("offset-x", "X Offset",
"Horizontal offset of overlay image in pixels from top-left corner "
"of video image", G_MININT, G_MAXINT, 0,
"For positive value, horizontal offset of overlay image in pixels from"
" left of video image. For negative value, horizontal offset of overlay"
" image in pixels from right of video image", G_MININT, G_MAXINT, 0,
GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_OFFSET_Y,
g_param_spec_int ("offset-y", "Y Offset",
"Vertical offset of overlay image in pixels from top-left corner "
"of video image", G_MININT, G_MAXINT, 0,
"For positive value, vertical offset of overlay image in pixels from"
" top of video image. For negative value, vertical offset of overlay"
" image in pixels from bottom of video image", G_MININT, G_MAXINT, 0,
GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_RELATIVE_X,
......@@ -436,6 +438,8 @@ gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay)
GstVideoOverlayRectangle *rect;
GstVideoMeta *overlay_meta;
gint x, y, width, height;
gint video_width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_FILTER (overlay)->in_info);
gint video_height = GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_FILTER (overlay)->in_info);
if (overlay->comp) {
gst_video_overlay_composition_unref (overlay->comp);
......@@ -447,14 +451,14 @@ gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay)
overlay_meta = gst_buffer_get_video_meta (overlay->pixels);
x = overlay->offset_x + (overlay->relative_x * overlay_meta->width);
y = overlay->offset_y + (overlay->relative_y * overlay_meta->height);
/* FIXME: this should work, but seems to crash */
if (x < 0)
x = 0;
if (y < 0)
y = 0;
x = overlay->offset_x < 0 ?
video_width + overlay->offset_x - overlay_meta->width +
(overlay->relative_x * overlay_meta->width) :
overlay->offset_x + (overlay->relative_x * overlay_meta->width);
y = overlay->offset_y < 0 ?
video_height + overlay->offset_y - overlay_meta->height +
(overlay->relative_y * overlay_meta->height) :
overlay->offset_y + (overlay->relative_y * overlay_meta->height);
width = overlay->overlay_width;
if (width == 0)
......@@ -472,8 +476,7 @@ gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay)
overlay->overlay_height, overlay->overlay_width);
GST_DEBUG_OBJECT (overlay, "overlay rendered: %d x %d @ %d,%d (onto %d x %d)",
width, height, x, y,
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_FILTER (overlay)->in_info),
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_FILTER (overlay)->in_info));
video_width, video_height);
rect = gst_video_overlay_rectangle_new_raw (overlay->pixels,
x, y, width, height, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment