From bd394012e8e2df4d204668134b76723f0ad41536 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 3 Jul 2012 11:30:17 +0000 Subject: [PATCH] Eliminated discrepancy between SSE and non-SSE versions of bilinear resize --- modules/imgproc/src/imgwarp.cpp | 45 +++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index bc5477fd7..a311d5be6 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -782,19 +782,8 @@ struct VResizeCubicVec_32f } }; -typedef HResizeNoVec HResizeLinearVec_8u32s; -typedef HResizeNoVec HResizeLinearVec_16u32f; -typedef HResizeNoVec HResizeLinearVec_16s32f; -typedef HResizeNoVec HResizeLinearVec_32f; -typedef HResizeNoVec HResizeLinearVec_64f; - #else -typedef HResizeNoVec HResizeLinearVec_8u32s; -typedef HResizeNoVec HResizeLinearVec_16u32f; -typedef HResizeNoVec HResizeLinearVec_16s32f; -typedef HResizeNoVec HResizeLinearVec_32f; - typedef VResizeNoVec VResizeLinearVec_32s8u; typedef VResizeNoVec VResizeLinearVec_32f16u; typedef VResizeNoVec VResizeLinearVec_32f16s; @@ -807,6 +796,12 @@ typedef VResizeNoVec VResizeCubicVec_32f; #endif +typedef HResizeNoVec HResizeLinearVec_8u32s; +typedef HResizeNoVec HResizeLinearVec_16u32f; +typedef HResizeNoVec HResizeLinearVec_16s32f; +typedef HResizeNoVec HResizeLinearVec_32f; +typedef HResizeNoVec HResizeLinearVec_64f; + template struct HResizeLinear @@ -894,6 +889,34 @@ struct VResizeLinear } }; +template<> +struct VResizeLinear, VResizeLinearVec_32s8u> +{ + typedef uchar value_type; + typedef int buf_type; + typedef short alpha_type; + + void operator()(const buf_type** src, value_type* dst, const alpha_type* beta, int width ) const + { + alpha_type b0 = beta[0], b1 = beta[1]; + const buf_type *S0 = src[0], *S1 = src[1]; + VResizeLinearVec_32s8u vecOp; + + int x = vecOp((const uchar**)src, (uchar*)dst, (const uchar*)beta, width); + #if CV_ENABLE_UNROLLED + for( ; x <= width - 4; x += 4 ) + { + dst[x+0] = uchar(( ((b0 * (S0[x+0] >> 4)) >> 16) + ((b1 * (S1[x+0] >> 4)) >> 16) + 2)>>2); + dst[x+1] = uchar(( ((b0 * (S0[x+1] >> 4)) >> 16) + ((b1 * (S1[x+1] >> 4)) >> 16) + 2)>>2); + dst[x+2] = uchar(( ((b0 * (S0[x+2] >> 4)) >> 16) + ((b1 * (S1[x+2] >> 4)) >> 16) + 2)>>2); + dst[x+3] = uchar(( ((b0 * (S0[x+3] >> 4)) >> 16) + ((b1 * (S1[x+3] >> 4)) >> 16) + 2)>>2); + } + #endif + for( ; x < width; x++ ) + dst[x] = uchar(( ((b0 * (S0[x] >> 4)) >> 16) + ((b1 * (S1[x] >> 4)) >> 16) + 2)>>2); + } +}; + template struct HResizeCubic