From bbdc60fbcb0b41c144e4036173f9fa7ebe1993d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 17 Mar 2010 16:46:32 +0100 Subject: [PATCH] videoscale: Use correct boundary checks for YUY2/UYVY Fixes bug #613093. --- gst/videoscale/vs_4tap.c | 8 ++++---- gst/videoscale/vs_scanline.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gst/videoscale/vs_4tap.c b/gst/videoscale/vs_4tap.c index ffe96aae82..8dc1044bd4 100644 --- a/gst/videoscale/vs_4tap.c +++ b/gst/videoscale/vs_4tap.c @@ -612,7 +612,7 @@ vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src, j = acc >> 17; x = (acc & 0x1ffff) >> 9; - if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) { + if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 1 - 4, 1)]; y += vs_4tap_taps[x][1] * src[j * 4 + 1]; y += vs_4tap_taps[x][2] * src[j * 4 + 1 + 4]; @@ -627,7 +627,7 @@ vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src, dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255); if (2 * i + 1 < n) { - if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) { + if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 3 - 4, 3)]; y += vs_4tap_taps[x][1] * src[j * 4 + 3]; y += vs_4tap_taps[x][2] * src[j * 4 + 3 + 4]; @@ -810,7 +810,7 @@ vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src, j = acc >> 17; x = (acc & 0x1ffff) >> 9; - if (2 * (j - 2) >= 0 && 2 * (j + 4) < src_width) { + if (2 * j - 2 >= 0 && 2 * j + 4 < src_width) { y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 0 - 4, 0)]; y += vs_4tap_taps[x][1] * src[j * 4 + 0]; y += vs_4tap_taps[x][2] * src[j * 4 + 0 + 4]; @@ -825,7 +825,7 @@ vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src, dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255); if (2 * i + 1 < n) { - if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) { + if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 2 - 4, 2)]; y += vs_4tap_taps[x][1] * src[j * 4 + 2]; y += vs_4tap_taps[x][2] * src[j * 4 + 2 + 4]; diff --git a/gst/videoscale/vs_scanline.c b/gst/videoscale/vs_scanline.c index d524e73b26..e82e4f3705 100644 --- a/gst/videoscale/vs_scanline.c +++ b/gst/videoscale/vs_scanline.c @@ -377,11 +377,11 @@ vs_scanline_resample_nearest_YUYV (uint8_t * dest, uint8_t * src, int src_width, j = acc >> 17; x = acc & 0x1ffff; dest[i * 4 + 1] = (x < 65536 - || 2 * (j + 2) >= src_width) ? src[j * 4 + 1] : src[j * 4 + 5]; + || 2 * j + 2 >= src_width) ? src[j * 4 + 1] : src[j * 4 + 5]; - if (2 * i + 1 < n && 2 * (j + 1) < src_width) + if (2 * i + 1 < n && 2 * j + 1 < src_width) dest[i * 4 + 3] = (x < 65536 - || 2 * (j + 3) >= src_width) ? src[j * 4 + 3] : src[j * 4 + 7]; + || 2 * j + 3 >= src_width) ? src[j * 4 + 3] : src[j * 4 + 7]; acc += increment; @@ -421,14 +421,14 @@ vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int src_width, j = acc >> 17; x = acc & 0x1ffff; - if (2 * (j + 2) < src_width) + if (2 * j + 2 < src_width) dest[i * 4 + 1] = (src[j * 4 + 1] * (131072 - x) + src[j * 4 + 5] * x) >> 17; else dest[i * 4 + 1] = src[j * 4 + 1]; - if (2 * i + 1 < n && 2 * (j + 1) < src_width) { - if (2 * (j + 3) < src_width) + if (2 * i + 1 < n && 2 * j + 1 < src_width) { + if (2 * j + 3 < src_width) dest[i * 4 + 3] = (src[j * 4 + 3] * (131072 - x) + src[j * 4 + 7] * x) >> 17; else @@ -516,11 +516,11 @@ vs_scanline_resample_nearest_UYVY (uint8_t * dest, uint8_t * src, int src_width, x = acc & 0x1ffff; dest[i * 4 + 0] = (x < 65536 - || 2 * (j + 2) >= src_width) ? src[j * 4 + 0] : src[j * 4 + 4]; + || 2 * j + 2 >= src_width) ? src[j * 4 + 0] : src[j * 4 + 4]; - if (2 * i + 1 < n && 2 * (j + 1) < src_width) + if (2 * i + 1 < n && 2 * j + 1 < src_width) dest[i * 4 + 2] = (x < 65536 - || 2 * (j + 3) >= src_width) ? src[j * 4 + 2] : src[j * 4 + 6]; + || 2 * j + 3 >= src_width) ? src[j * 4 + 2] : src[j * 4 + 6]; acc += increment; @@ -559,14 +559,14 @@ vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int src_width, j = acc >> 17; x = acc & 0x1ffff; - if (2 * (j + 2) < src_width) + if (2 * j + 2 < src_width) dest[i * 4 + 0] = (src[j * 4 + 0] * (131072 - x) + src[j * 4 + 4] * x) >> 17; else dest[i * 4 + 0] = src[j * 4 + 0]; - if (i * 2 + 1 < n && 2 * (j + 1) < src_width) { - if (2 * (j + 3) < src_width) + if (i * 2 + 1 < n && 2 * j + 1 < src_width) { + if (2 * j + 3 < src_width) dest[i * 4 + 2] = (src[j * 4 + 2] * (131072 - x) + src[j * 4 + 6] * x) >> 17; else