From 9396d843d619560d85d6cf0f0e8f7c289c1d79b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 16 Nov 2014 16:34:31 +0000 Subject: [PATCH] video-blend: fix clipping of overlay images on the left Fix clipping of images that are partially left of the video surface, they would get clipped on the right side instead of the left side, because the video unpack functions currently ignore the x offset parameter. Work around that until that is implemented. https://bugzilla.gnome.org/show_bug.cgi?id=739281 --- gst-libs/gst/video/video-blend.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/video/video-blend.c b/gst-libs/gst/video/video-blend.c index 3c916edfc9..2632de970e 100644 --- a/gst-libs/gst/video/video-blend.c +++ b/gst-libs/gst/video/video-blend.c @@ -292,6 +292,9 @@ gst_video_blend (GstVideoFrame * dest, ensure_debug_category (); + GST_LOG ("blend src %dx%d onto dest %dx%d @ %d,%d", src_width, src_height, + dest_width, dest_height, x, y); + /* In case overlay is completely outside the video, dont render */ if (x + src_width <= 0 || y + src_height <= 0 || x >= dest_width || y >= dest_height) { @@ -334,6 +337,7 @@ gst_video_blend (GstVideoFrame * dest, /* If we're here we know that the overlay image fully or * partially overlaps with the video frame */ + /* adjust src image for negative offsets */ if (x < 0) { src_xoff = -x; @@ -347,7 +351,8 @@ gst_video_blend (GstVideoFrame * dest, y = 0; } - /* adjust width/height if the src is bigger than dest */ + /* adjust width/height to render (i.e. clip source image) if the source + * image extends beyond the right or bottom border of the video surface */ if (x + src_width > dest_width) src_width = dest_width - x; @@ -360,11 +365,13 @@ gst_video_blend (GstVideoFrame * dest, dinfo->unpack_func (dinfo, 0, tmpdestline, dest->data, dest->info.stride, 0, i, dest_width); sinfo->unpack_func (sinfo, 0, tmpsrcline, src->data, src->info.stride, - src_xoff, src_yoff, src_width); + 0, src_yoff, src_width + src_xoff); matrix (tmpsrcline, src_width); + /* FIXME: use the x parameter of the unpack func once implemented */ tmpdestline += 4 * x; + tmpsrcline += 4 * src_xoff; /* Here dest and src are both either in AYUV or ARGB * TODO: Make the orc version working properly*/ @@ -405,7 +412,9 @@ gst_video_blend (GstVideoFrame * dest, #undef BLENDLOOP + /* undo previous pointer adjustments to pass right pointer to g_free */ tmpdestline -= 4 * x; + tmpsrcline -= 4 * src_xoff; /* FIXME * #if G_BYTE_ORDER == LITTLE_ENDIAN