From 9c49ca0f19a99375dfa4fbe7cce4732667cf9ba0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 9 May 2011 22:02:44 +0200 Subject: [PATCH] swscale: factor shift out of DITHER_COPY(). Signed-off-by: Michael Niedermayer --- libswscale/swscale.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1f476ad5db..d7920bfd5a 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1859,19 +1859,20 @@ static int packedCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ #define DITHER_COPY(dst, dstStride, src, srcStride)\ for (i = 0; i < height; i++) {\ + int shift= src_depth-dst_depth;\ uint8_t *dither= dithers[src_depth-9][i&7];\ for (j = 0; j < length-7; j+=8){\ - dst[j+0] = (src[j+0] + dither[0])>>(src_depth-dst_depth);\ - dst[j+1] = (src[j+1] + dither[1])>>(src_depth-dst_depth);\ - dst[j+2] = (src[j+2] + dither[2])>>(src_depth-dst_depth);\ - dst[j+3] = (src[j+3] + dither[3])>>(src_depth-dst_depth);\ - dst[j+4] = (src[j+4] + dither[4])>>(src_depth-dst_depth);\ - dst[j+5] = (src[j+5] + dither[5])>>(src_depth-dst_depth);\ - dst[j+6] = (src[j+6] + dither[6])>>(src_depth-dst_depth);\ - dst[j+7] = (src[j+7] + dither[7])>>(src_depth-dst_depth);\ + dst[j+0] = (src[j+0] + dither[0])>>shift;\ + dst[j+1] = (src[j+1] + dither[1])>>shift;\ + dst[j+2] = (src[j+2] + dither[2])>>shift;\ + dst[j+3] = (src[j+3] + dither[3])>>shift;\ + dst[j+4] = (src[j+4] + dither[4])>>shift;\ + dst[j+5] = (src[j+5] + dither[5])>>shift;\ + dst[j+6] = (src[j+6] + dither[6])>>shift;\ + dst[j+7] = (src[j+7] + dither[7])>>shift;\ }\ for (; j < length; j++)\ - dst[j] = (src[j] + dither[j&7])>>(src_depth-dst_depth);\ + dst[j] = (src[j] + dither[j&7])>>shift;\ dst += dstStride;\ src += srcStride;\ }