From 058b761a4615464de286b60a7a0c47c4225a823a Mon Sep 17 00:00:00 2001
From: Andrey Kamaev <no@email>
Date: Thu, 12 May 2011 15:22:55 +0000
Subject: [PATCH] cv:threshold optimization for Tegra

---
 modules/imgproc/src/precomp.hpp |  4 ++++
 modules/imgproc/src/thresh.cpp  | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp
index dbcfe2753..32f825bb7 100644
--- a/modules/imgproc/src/precomp.hpp
+++ b/modules/imgproc/src/precomp.hpp
@@ -63,6 +63,10 @@
 #include <limits.h>
 #include <float.h>
 
+#ifdef HAVE_TEGRA_OPTIMIZATION
+#include "opencv2/imgproc/imgproc_tegra.hpp"
+#endif
+
 /* helper tables */
 extern const uchar icvSaturate8u_cv[];
 #define CV_FAST_CAST_8U(t)  (assert(-256 <= (t) || (t) <= 512), icvSaturate8u_cv[(t)+256])
diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp
index 2b0da3219..fdf92065b 100644
--- a/modules/imgproc/src/thresh.cpp
+++ b/modules/imgproc/src/thresh.cpp
@@ -58,7 +58,16 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type )
         roi.width *= roi.height;
         roi.height = 1;
     }
-    
+
+#ifdef HAVE_TEGRA_OPTIMIZATION
+#warning "TEGRA OPTIMIZED BINARY THRESHOLD (maxval == 255)"
+    if (type == THRESH_BINARY && maxval == 255)
+    {
+	if(tegra::thresh_8u_binary_256(_src, _dst, roi, thresh))
+            return;
+    }
+#endif
+  
     switch( type )
     {
     case THRESH_BINARY: