From 51e2a8ec968b319de5c024a1600d8bcd58c41386 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 18 Apr 2014 14:25:38 +0400 Subject: [PATCH] fixes --- modules/calib3d/src/stereosgbm.cpp | 20 +++++++++------- modules/core/src/arithm.cpp | 38 ++++++++++++++++++++---------- modules/core/src/copy.cpp | 19 +++++++++++---- modules/core/src/matrix.cpp | 1 + modules/imgproc/src/accum.cpp | 1 + modules/imgproc/src/corner.cpp | 3 +++ 6 files changed, 58 insertions(+), 24 deletions(-) diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index e8916f52a9..a1db5c4ffc 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -1089,20 +1089,24 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi IppiSize roisize = { img.cols, img.rows }; IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s; - if (!__buf.needed() && ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize)) + if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1)) { + IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize); Ipp8u * buffer = ippsMalloc_8u(bufsize); - IppStatus status = (IppStatus)-1; - if (type == CV_8UC1) - status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, - (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer); - else if (type == CV_16SC1) - status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, - (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer); + if ((int)status >= 0) + { + if (type == CV_8UC1) + status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, + (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer); + else + status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, + (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer); + } if (status >= 0) return; + setIppErrorStatus(); } #endif diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 7ba9f098ff..009b4e4219 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -721,6 +721,7 @@ static void max64f( const double* src1, size_t step1, } if (i == sz.height) return; + setIppErrorStatus(); #endif vBinOp64, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -841,6 +842,7 @@ static void min64f( const double* src1, size_t step1, } if (i == sz.height) return; + setIppErrorStatus(); #endif vBinOp64, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -2013,9 +2015,12 @@ static void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t st { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2031,9 +2036,12 @@ static void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2043,9 +2051,12 @@ static void mul16s( const short* src1, size_t step1, const short* src2, size_t s { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2061,9 +2072,12 @@ static void mul32f( const float* src1, size_t step1, const float* src2, size_t s { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 86223f6564..713725ea42 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -84,6 +84,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mste #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_8u_C1MR(_src, (int)sstep, _dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) return; + setIppErrorStatus(); #endif for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) @@ -119,6 +120,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mst #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_16u_C1MR((const Ipp16u *)_src, (int)sstep, (Ipp16u *)_dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) return; + setIppErrorStatus(); #endif for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) @@ -182,6 +184,7 @@ static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, { \ if (ippiCopy_##ippfavor((const ipptype *)src, (int)sstep, (ipptype *)dst, (int)dstep, ippiSize(size), (const Ipp8u *)mask, (int)mstep) >= 0) \ return; \ + setIppErrorStatus(); \ copyMask_(src, sstep, mask, mstep, dst, dstep, size); \ } #else @@ -281,6 +284,7 @@ void Mat::copyTo( OutputArray _dst ) const #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_8u_C1R(sptr, (int)step, dptr, (int)dst.step, ippiSize((int)len, sz.height)) >= 0) return; + setIppErrorStatus(); #endif for( ; sz.height--; sptr += step, dptr += dst.step ) @@ -367,11 +371,13 @@ Mat& Mat::operator = (const Scalar& s) if (ippsZero_8u(data, static_cast(roisize.width * elemSize())) >= 0) return *this; + setIppErrorStatus(); } roisize.width *= (int)elemSize(); if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0) return *this; + setIppErrorStatus(); } #endif @@ -414,13 +420,16 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) ); #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous()))) + int cn = channels(), depth0 = depth(); + + if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) && + (depth0 == CV_8U || depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) && + (cn == 1 || cn == 3 || cn == 4)) { uchar _buf[32]; void * buf = _buf; convertAndUnrollScalar( value, type(), _buf, 1 ); - int cn = channels(), depth0 = depth(); IppStatus status = (IppStatus)-1; IppiSize roisize = { cols, rows }; int mstep = (int)mask.step, dstep = (int)step; @@ -444,13 +453,13 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) else if (depth0 == CV_32F) status = ippiSet_32f_C1MR(*(Ipp32f *)buf, (Ipp32f *)data, dstep, roisize, mask.data, mstep); } - else if (cn == 3 || cn == 3) + else if (cn == 3 || cn == 4) { #define IPP_SET(ippfavor, ippcn) \ do \ { \ typedef Ipp##ippfavor ipptype; \ - ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[4] }; \ + ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \ status = ippiSet_##ippfavor##_C##ippcn##MR(ippvalue, (ipptype *)data, dstep, roisize, mask.data, mstep); \ } while ((void)0, 0) @@ -481,6 +490,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) if (status >= 0) return *this; + setIppErrorStatus(); } #endif @@ -733,6 +743,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) return; setIppErrorStatus(); } +#endif if( flip_mode <= 0 ) flipVert( src.data, src.step, dst.data, dst.step, src.size(), esz ); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index aa935b36f6..ff7abf16c6 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3079,6 +3079,7 @@ void cv::transpose( InputArray _src, OutputArray _dst ) return; setIppErrorStatus(); } +#endif if( dst.data == src.data ) { diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index e218fc6936..e0cce1f594 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -479,6 +479,7 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) if (status >= 0) return; + setIppErrorStatus(); } } #endif diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index b2adea4962..edc3504fb1 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -510,7 +510,10 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi if (status >= 0) return; + setIppErrorStatus(); } + else + setIppErrorStatus(); } #endif