From c8cbcb6f02f27d23caf3d9d6bd0370073b7cab53 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 10 Sep 2013 11:31:57 +0200 Subject: [PATCH] videoscale: pick nearest line in scaling Use rounding to pick the nearest line instead of rounding down. --- gst/videoscale/vs_image.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gst/videoscale/vs_image.c b/gst/videoscale/vs_image.c index bcd0d98925..00096fdeff 100644 --- a/gst/videoscale/vs_image.c +++ b/gst/videoscale/vs_image.c @@ -65,7 +65,7 @@ vs_image_scale_nearest_RGBA (const VSImage * dest, const VSImage * src, acc = 0; prev_j = -1; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; if (j == prev_j) { memcpy (dest->pixels + i * dest->stride, @@ -160,7 +160,7 @@ vs_image_scale_nearest_RGB (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_RGB (dest->pixels + i * dest->stride, @@ -290,7 +290,7 @@ vs_image_scale_nearest_YUYV (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_YUYV (dest->pixels + i * dest->stride, @@ -420,7 +420,7 @@ vs_image_scale_nearest_UYVY (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_UYVY (dest->pixels + i * dest->stride, @@ -550,7 +550,7 @@ vs_image_scale_nearest_NV12 (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_NV12 (dest->pixels + i * dest->stride, @@ -679,7 +679,7 @@ vs_image_scale_nearest_Y (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; video_scale_orc_resample_nearest_u8 (dest->pixels + i * dest->stride, src->pixels + j * src->stride, 0, x_increment, dest->width); @@ -806,7 +806,7 @@ vs_image_scale_nearest_Y16 (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_Y16 (dest->pixels + i * dest->stride, @@ -936,7 +936,7 @@ vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride, @@ -1066,7 +1066,7 @@ vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src, acc = 0; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; xacc = 0; vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride, @@ -1196,7 +1196,7 @@ vs_image_scale_nearest_AYUV64 (const VSImage * dest, const VSImage * src, acc = 0; prev_j = -1; for (i = 0; i < dest->height; i++) { - j = acc >> 16; + j = (acc + 0x8000) >> 16; if (j == prev_j) { memcpy (dest->pixels + i * dest->stride,