cast to reference
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Wed, 31 Jul 2013 12:19:40 +0000 (16:19 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 1 Oct 2013 08:18:38 +0000 (12:18 +0400)
modules/cudaarithm/src/cuda/minmax.cu
modules/cudaarithm/src/cuda/sum.cu

index eec861b..084bed8 100644 (file)
@@ -64,8 +64,8 @@ namespace
                 typename SelectIf<TypesEquals<T, float>::value, float, int>::type
                 >::type work_type;
 
-        GpuMat_<T> src(_src);
-        GpuMat_<work_type> buf(_buf);
+        const GpuMat_<T>& src = (const GpuMat_<T>&) _src;
+        GpuMat_<work_type>& buf = (GpuMat_<work_type>&) _buf;
 
         if (mask.empty())
             gridFindMinMaxVal(src, buf);
@@ -103,11 +103,6 @@ void cv::cuda::minMax(InputArray _src, double* minVal, double* maxVal, InputArra
     CV_Assert( src.channels() == 1 );
     CV_DbgAssert( mask.empty() || (mask.size() == src.size() && mask.type() == CV_8U) );
 
-    const int depth = src.depth();
-
-    const int work_type = depth == CV_64F ? CV_64F : depth == CV_32F ? CV_32F : CV_32S;
-    ensureSizeIsEnough(1, 2, work_type, buf);
-
     const func_t func = funcs[src.depth()];
 
     func(src, mask, buf, minVal, maxVal);
index ab90050..cced9c5 100644 (file)
@@ -61,8 +61,8 @@ namespace
         typedef typename MakeVec<T, cn>::type src_type;
         typedef typename MakeVec<R, cn>::type res_type;
 
-        GpuMat_<src_type> src(_src);
-        GpuMat_<res_type> buf(_buf);
+        const GpuMat_<src_type>& src = (const GpuMat_<src_type>&) _src;
+        GpuMat_<res_type>& buf = (GpuMat_<res_type>&) _buf;
 
         if (mask.empty())
             gridCalcSum(src, buf);
@@ -82,8 +82,8 @@ namespace
         typedef typename MakeVec<T, cn>::type src_type;
         typedef typename MakeVec<R, cn>::type res_type;
 
-        GpuMat_<src_type> src(_src);
-        GpuMat_<res_type> buf(_buf);
+        const GpuMat_<src_type>& src = (const GpuMat_<src_type>&) _src;
+        GpuMat_<res_type>& buf = (GpuMat_<res_type>&) _buf;
 
         if (mask.empty())
             gridCalcSum(abs_(cvt_<res_type>(src)), buf);
@@ -103,8 +103,8 @@ namespace
         typedef typename MakeVec<T, cn>::type src_type;
         typedef typename MakeVec<R, cn>::type res_type;
 
-        GpuMat_<src_type> src(_src);
-        GpuMat_<res_type> buf(_buf);
+        const GpuMat_<src_type>& src = (const GpuMat_<src_type>&) _src;
+        GpuMat_<res_type>& buf = (GpuMat_<res_type>&) _buf;
 
         if (mask.empty())
             gridCalcSum(sqr_(cvt_<res_type>(src)), buf);
@@ -138,9 +138,6 @@ cv::Scalar cv::cuda::sum(InputArray _src, InputArray _mask, GpuMat& buf)
 
     CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) );
 
-    const int res_depth = std::max(src.depth(), CV_32F);
-    cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf);
-
     const func_t func = funcs[src.depth()][src.channels() - 1];
 
     return func(src, mask, buf);
@@ -165,9 +162,6 @@ cv::Scalar cv::cuda::absSum(InputArray _src, InputArray _mask, GpuMat& buf)
 
     CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) );
 
-    const int res_depth = std::max(src.depth(), CV_32F);
-    cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf);
-
     const func_t func = funcs[src.depth()][src.channels() - 1];
 
     return func(src, mask, buf);
@@ -192,9 +186,6 @@ cv::Scalar cv::cuda::sqrSum(InputArray _src, InputArray _mask, GpuMat& buf)
 
     CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) );
 
-    const int res_depth = CV_64F;
-    cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf);
-
     const func_t func = funcs[src.depth()][src.channels() - 1];
 
     return func(src, mask, buf);