From f3e989179bd32eb3615c9d0a8a124113fa09afa0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 Dec 2013 16:06:43 +0100 Subject: [PATCH] video-format: fix off-by-one for tiled coordinates https://bugzilla.gnome.org/show_bug.cgi?id=707361 --- gst-libs/gst/video/video-format.c | 6 +++--- gst-libs/gst/video/video-frame.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c index da78adb881..97070a927a 100644 --- a/gst-libs/gst/video/video-format.c +++ b/gst-libs/gst/video/video-format.c @@ -2142,7 +2142,7 @@ unpack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags, /* first x tile to convert */ tx = x >> ws; /* Last tile to convert */ - ntx = (x + width) >> ws; + ntx = ((x + width - 1) >> ws) + 1; /* The row we are going to convert */ ty = y >> hs; @@ -2151,7 +2151,7 @@ unpack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags, /* x position in a tile */ x = x & (tile_width - 1); - for (; tx <= ntx; tx++) { + for (; tx < ntx; tx++) { gpointer tdata[GST_VIDEO_MAX_PLANES]; gint tstride[GST_VIDEO_MAX_PLANES]; gint unpack_width; @@ -2200,7 +2200,7 @@ pack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags, pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0); /* Last tile to convert */ - ntx = width >> ws; + ntx = ((width - 1) >> ws) + 1; /* The row we are going to convert */ ty = y >> hs; diff --git a/gst-libs/gst/video/video-frame.c b/gst-libs/gst/video/video-frame.c index 5d3ac5ca11..cd348f2e58 100644 --- a/gst-libs/gst/video/video-frame.c +++ b/gst-libs/gst/video/video-frame.c @@ -280,8 +280,8 @@ gst_video_frame_copy_plane (GstVideoFrame * dest, const GstVideoFrame * src, dy_tiles = dinfo->stride[tidx]; /* this is the amount of tiles to copy */ - w = (w + (1 << ws) - 1) >> ws; - h = (h + (1 << hs) - 1) >> hs; + w = ((w - 1) >> ws) + 1; + h = ((h - 1) >> hs) + 1; /* FIXME can possibly do better when no retiling is needed, it depends on * the stride and the tile_size */