From ab7d52c0536d91dd0b208541da43e800f340c692 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 29 Mar 2009 12:01:33 +0200 Subject: [PATCH] videoscale: Fix linear scaling for one byte components Fixes bug #577054. --- gst/videoscale/vs_scanline.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/gst/videoscale/vs_scanline.c b/gst/videoscale/vs_scanline.c index 99e309b..7cebef5 100644 --- a/gst/videoscale/vs_scanline.c +++ b/gst/videoscale/vs_scanline.c @@ -61,27 +61,29 @@ vs_scanline_resample_nearest_Y (uint8_t * dest, uint8_t * src, int src_width, *accumulator = acc; } +#include void vs_scanline_resample_linear_Y (uint8_t * dest, uint8_t * src, int src_width, int n, int *accumulator, int increment) { - uint32_t vals[2]; + int acc = *accumulator; + int i; + int j; + int x; - vals[0] = *accumulator; - vals[1] = increment; + for (i = 0; i < n; i++) { + j = acc >> 16; + x = acc & 0xffff; - if (src_width % 2 == 0) { - oil_resample_linear_u8 (dest, src, n, vals); - } else if (src_width > 1) { - if (n > 1) - oil_resample_linear_u8 (dest, src, n - 1, vals); - dest[n - 1] = src[vals[0] >> 16]; - vals[0] += increment; - } else { - oil_splat_u8 (dest, 1, &src[0], n); + if (j + 1 < src_width) + dest[i] = (src[j] * (65536 - x) + src[j + 1] * x) >> 16; + else + dest[i] = src[j]; + + acc += increment; } - *accumulator = vals[0]; + *accumulator = acc; } void -- 2.7.4