added ipp threshold inplace
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Thu, 8 May 2014 09:49:44 +0000 (13:49 +0400)
committerIlya Lavrenov <ilya.lavrenov@itseez.com>
Thu, 8 May 2014 09:51:25 +0000 (13:51 +0400)
modules/imgproc/src/thresh.cpp

index 08241d050b5791c6f1768a9b0e7d8b285aaec237..e6a55d700dc82ecd9703c96b469de3c5effa40b6 100644 (file)
@@ -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 )