mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gdkpixbufoverlay: Allow negative offsets to specify offset from bottom/right
https://bugzilla.gnome.org/show_bug.cgi?id=702826
This commit is contained in:
parent
4053e1d6ac
commit
5d98c9d500
1 changed files with 17 additions and 14 deletions
|
@ -138,14 +138,16 @@ gst_gdk_pixbuf_overlay_class_init (GstGdkPixbufOverlayClass * klass)
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (gobject_class, PROP_OFFSET_X,
|
g_object_class_install_property (gobject_class, PROP_OFFSET_X,
|
||||||
g_param_spec_int ("offset-x", "X Offset",
|
g_param_spec_int ("offset-x", "X Offset",
|
||||||
"Horizontal offset of overlay image in pixels from top-left corner "
|
"For positive value, horizontal offset of overlay image in pixels from"
|
||||||
"of video image", G_MININT, G_MAXINT, 0,
|
" 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
|
GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | G_PARAM_READWRITE
|
||||||
| G_PARAM_STATIC_STRINGS));
|
| G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (gobject_class, PROP_OFFSET_Y,
|
g_object_class_install_property (gobject_class, PROP_OFFSET_Y,
|
||||||
g_param_spec_int ("offset-y", "Y Offset",
|
g_param_spec_int ("offset-y", "Y Offset",
|
||||||
"Vertical offset of overlay image in pixels from top-left corner "
|
"For positive value, vertical offset of overlay image in pixels from"
|
||||||
"of video image", G_MININT, G_MAXINT, 0,
|
" 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
|
GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | G_PARAM_READWRITE
|
||||||
| G_PARAM_STATIC_STRINGS));
|
| G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (gobject_class, PROP_RELATIVE_X,
|
g_object_class_install_property (gobject_class, PROP_RELATIVE_X,
|
||||||
|
@ -436,6 +438,8 @@ gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay)
|
||||||
GstVideoOverlayRectangle *rect;
|
GstVideoOverlayRectangle *rect;
|
||||||
GstVideoMeta *overlay_meta;
|
GstVideoMeta *overlay_meta;
|
||||||
gint x, y, width, height;
|
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) {
|
if (overlay->comp) {
|
||||||
gst_video_overlay_composition_unref (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);
|
overlay_meta = gst_buffer_get_video_meta (overlay->pixels);
|
||||||
|
|
||||||
x = overlay->offset_x + (overlay->relative_x * overlay_meta->width);
|
x = overlay->offset_x < 0 ?
|
||||||
y = overlay->offset_y + (overlay->relative_y * overlay_meta->height);
|
video_width + overlay->offset_x - overlay_meta->width +
|
||||||
|
(overlay->relative_x * overlay_meta->width) :
|
||||||
/* FIXME: this should work, but seems to crash */
|
overlay->offset_x + (overlay->relative_x * overlay_meta->width);
|
||||||
if (x < 0)
|
y = overlay->offset_y < 0 ?
|
||||||
x = 0;
|
video_height + overlay->offset_y - overlay_meta->height +
|
||||||
if (y < 0)
|
(overlay->relative_y * overlay_meta->height) :
|
||||||
y = 0;
|
overlay->offset_y + (overlay->relative_y * overlay_meta->height);
|
||||||
|
|
||||||
width = overlay->overlay_width;
|
width = overlay->overlay_width;
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
|
@ -472,8 +476,7 @@ gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay)
|
||||||
overlay->overlay_height, overlay->overlay_width);
|
overlay->overlay_height, overlay->overlay_width);
|
||||||
GST_DEBUG_OBJECT (overlay, "overlay rendered: %d x %d @ %d,%d (onto %d x %d)",
|
GST_DEBUG_OBJECT (overlay, "overlay rendered: %d x %d @ %d,%d (onto %d x %d)",
|
||||||
width, height, x, y,
|
width, height, x, y,
|
||||||
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_FILTER (overlay)->in_info),
|
video_width, video_height);
|
||||||
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_FILTER (overlay)->in_info));
|
|
||||||
|
|
||||||
rect = gst_video_overlay_rectangle_new_raw (overlay->pixels,
|
rect = gst_video_overlay_rectangle_new_raw (overlay->pixels,
|
||||||
x, y, width, height, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
|
x, y, width, height, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
|
||||||
|
|
Loading…
Reference in a new issue