applied patch #1734
authorVladislav Vinogradov <no@email>
Sat, 31 Mar 2012 17:05:33 +0000 (17:05 +0000)
committerVladislav Vinogradov <no@email>
Sat, 31 Mar 2012 17:05:33 +0000 (17:05 +0000)
modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu

index 9efb80d..44e6fde 100644 (file)
@@ -551,10 +551,10 @@ template<int isBlack> __global__ void sor_pass(float *new_du,
         return;\r
 \r
     const int pos = j * stride + i;\r
-    const int pos_r = pos + 1;\r
-    const int pos_u = pos + stride;\r
-    const int pos_d = pos - stride;\r
-    const int pos_l = pos - 1;\r
+    const int pos_r = i < width - 1 ? pos + 1 : pos;\r
+    const int pos_u = j < height - 1 ? pos + stride : pos;\r
+    const int pos_d = j > 0 ? pos - stride : pos;\r
+    const int pos_l = i > 0 ? pos - 1 : pos;\r
 \r
     //load smooth term\r
     float s_up, s_left, s_right, s_down;\r