From 925d0cc7699ea2e40d9381626bf4f85f2cc2db3d Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 8 Oct 2012 14:11:39 +0400 Subject: [PATCH] added test for box filter 16u, fixed bug #2416 --- modules/imgproc/src/smooth.cpp | 4 ++-- modules/imgproc/test/test_filter.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 836f3ddbfa..58264e2a45 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -556,7 +556,7 @@ template<> struct ColumnSum : public BaseColumnFilter __m128i _res = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0))); _res = _mm_sub_epi32(_res, delta0); - _res = _mm_add_epi16(_mm_packs_epi16(_res, _res), delta1); + _res = _mm_add_epi16(_mm_packs_epi32(_res, _res), delta1); _mm_storel_epi64((__m128i*)(D+i), _res); _mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm)); @@ -586,7 +586,7 @@ template<> struct ColumnSum : public BaseColumnFilter _mm_loadu_si128((const __m128i*)(Sp+i))); __m128i _res = _mm_sub_epi32(_s0, delta0); - _res = _mm_add_epi16(_mm_packs_epi16(_res, _res), delta1); + _res = _mm_add_epi16(_mm_packs_epi32(_res, _res), delta1); _mm_storel_epi64((__m128i*)(D+i), _res); _mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm)); diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index 0260bdf929..f348915ab7 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -110,6 +110,11 @@ void CV_FilterBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, high = Scalar::all(2); } } + else if( CV_MAT_DEPTH(type) == CV_16U ) + { + low = Scalar::all(0.); + high = Scalar::all(40000.); + } else if( CV_MAT_DEPTH(type) == CV_32F ) { low = Scalar::all(-10.); @@ -678,10 +683,13 @@ void CV_BlurTest::get_test_array_types_and_sizes( int test_case_idx, { RNG& rng = ts->get_rng(); CV_SmoothBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); + int depth = cvtest::randInt(rng) % 4; + int cn = (cvtest::randInt(rng) % 4) + 1; + depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : depth == 2 ? CV_16S : CV_32F; + types[OUTPUT][0] = types[REF_OUTPUT][0] = types[INPUT][0] = CV_MAKETYPE(depth, cn); normalize = cvtest::randInt(rng) % 2 != 0; if( !normalize ) { - int depth = CV_MAT_DEPTH(types[INPUT][0]); types[INPUT][0] = CV_MAKETYPE(depth, 1); types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth==CV_8U?CV_16S:CV_32F,1); }