From 11b01cd8b990f65d0f78a67471f1b96bbb661b7c Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 8 May 2014 13:49:44 +0400 Subject: [PATCH] added ipp threshold inplace --- modules/imgproc/src/thresh.cpp | 40 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 08241d050b..e6a55d700d 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -70,24 +70,38 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type ) #if defined(HAVE_IPP) IppiSize sz = { roi.width, roi.height }; + CV_SUPPRESS_DEPRECATED_START switch( type ) { case THRESH_TRUNC: - if (0 <= ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_GT_8u_C1IR(_src.data, (int)src_step, sz, thresh) >= 0) + return; +#endif + if (ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh) >= 0) return; setIppErrorStatus(); break; case THRESH_TOZERO: - if (0 <= ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_LTVal_8u_C1IR(_src.data, (int)src_step, sz, thresh+1, 0) >= 0) + return; +#endif + if (ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0) >= 0) return; setIppErrorStatus(); break; case THRESH_TOZERO_INV: - if (0 <= ippiThreshold_GTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh, 0)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_GTVal_8u_C1IR(_src.data, (int)src_step, sz, thresh, 0) >= 0) + return; +#endif + if (ippiThreshold_GTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh, 0) >= 0) return; setIppErrorStatus(); break; } + CV_SUPPRESS_DEPRECATED_END #endif switch( type ) @@ -311,24 +325,38 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type ) #if defined(HAVE_IPP) IppiSize sz = { roi.width, roi.height }; + CV_SUPPRESS_DEPRECATED_START switch( type ) { case THRESH_TRUNC: - if (0 <= ippiThreshold_GT_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_GT_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0) + return; +#endif + if (ippiThreshold_GT_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0) return; setIppErrorStatus(); break; case THRESH_TOZERO: - if (0 <= ippiThreshold_LTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_LTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh + 1, 0) >= 0) + return; +#endif + if (ippiThreshold_LTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0) >= 0) return; setIppErrorStatus(); break; case THRESH_TOZERO_INV: - if (0 <= ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0)) +#ifndef HAVE_IPP_ICV_ONLY + if (_src.data == _dst.data && ippiThreshold_GTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0) + return; +#endif + if (ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0) return; setIppErrorStatus(); break; } + CV_SUPPRESS_DEPRECATED_END #endif switch( type )