summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKishore Arepalli <kishore.arepalli@gmail.com>2013-06-21 18:10:28 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-01 13:08:39 +0200
commit5d98c9d50047972de1286d5d4fd2b2b7fad94e94 (patch)
tree162447c6bad4b6dcc2c005539522500d71a71b4f /ext
parent4053e1d6acc241d7690c7b1325d3b43775b83e48 (diff)
gdkpixbufoverlay: Allow negative offsets to specify offset from bottom/right
https://bugzilla.gnome.org/show_bug.cgi?id=702826
Diffstat (limited to 'ext')
-rw-r--r--ext/gdk_pixbuf/gstgdkpixbufoverlay.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/ext/gdk_pixbuf/gstgdkpixbufoverlay.c b/ext/gdk_pixbuf/gstgdkpixbufoverlay.c
index b011b850d..46adfb65a 100644
--- a/ext/gdk_pixbuf/gstgdkpixbufoverlay.c
+++ b/ext/gdk_pixbuf/gstgdkpixbufoverlay.c
@@ -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);