fixed gpu::integral for Kepler
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Thu, 23 Aug 2012 13:00:12 +0000 (17:00 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Thu, 23 Aug 2012 13:12:43 +0000 (17:12 +0400)
modules/gpu/src/imgproc.cpp

index 5b8fb9c..eeaab75 100644 (file)
@@ -551,13 +551,13 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
 \r
     if (info.supports(WARP_SHUFFLE_FUNCTIONS))\r
     {\r
-        GpuMat src16;\r
+        GpuMat srcAlligned;\r
 \r
-        if (src.cols % 16 == 0)\r
-            src16 = src;\r
+        if (src.cols % 16 == 0 && src.rows % 8 == 0)\r
+            srcAlligned = src;\r
         else\r
         {\r
-            ensureSizeIsEnough(src.rows, ((src.cols + 15) / 16) * 16, src.type(), buffer);\r
+            ensureSizeIsEnough(((src.rows + 7) / 8) * 8, ((src.cols + 15) / 16) * 16, src.type(), buffer);\r
 \r
             GpuMat inner = buffer(Rect(0, 0, src.cols, src.rows));\r
 \r
@@ -572,21 +572,21 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
                 src.copyTo(inner);\r
             }\r
 \r
-            src16 = buffer;\r
+            srcAlligned = buffer;\r
         }\r
 \r
-        sum.create(src16.rows + 1, src16.cols + 1, CV_32SC1);\r
+        sum.create(srcAlligned.rows + 1, srcAlligned.cols + 1, CV_32SC1);\r
 \r
         if (s)\r
             s.enqueueMemSet(sum, Scalar::all(0));\r
         else\r
             sum.setTo(Scalar::all(0));\r
 \r
-        GpuMat inner = sum(Rect(1, 1, src16.cols, src16.rows));\r
+        GpuMat inner = sum(Rect(1, 1, srcAlligned.cols, srcAlligned.rows));\r
 \r
-        cv::gpu::device::imgproc::shfl_integral_gpu(src16, inner, stream);\r
+        cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream);\r
 \r
-        if (src16.cols != src.cols)\r
+        if (srcAlligned.data != src.data)\r
             sum = sum(Rect(0, 0, src.cols + 1, src.rows + 1));\r
     }\r
     else\r