From 3282aaa1f5ba544c26611e20d31058fa2491ce96 Mon Sep 17 00:00:00 2001 From: peng xiao Date: Tue, 23 Apr 2013 15:34:40 +0800 Subject: [PATCH] Fix a bug found on Intel OpenCL SDK. --- modules/ocl/src/opencl/stereobp.cl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ocl/src/opencl/stereobp.cl b/modules/ocl/src/opencl/stereobp.cl index 3196e581a..4d13f807b 100644 --- a/modules/ocl/src/opencl/stereobp.cl +++ b/modules/ocl/src/opencl/stereobp.cl @@ -185,10 +185,10 @@ __kernel void data_step_down(__global T *src, int src_rows, for (int d = 0; d < cndisp; ++d) { float dst_reg; - dst_reg = src[(d * src_rows + (2*y+0)) * src_step + 2*x+0]; - dst_reg += src[(d * src_rows + (2*y+1)) * src_step + 2*x+0]; - dst_reg += src[(d * src_rows + (2*y+0)) * src_step + 2*x+1]; - dst_reg += src[(d * src_rows + (2*y+1)) * src_step + 2*x+1]; + dst_reg = src[(d * src_rows + min(2*y+0, src_rows-1)) * src_step + 2*x+0]; + dst_reg += src[(d * src_rows + min(2*y+1, src_rows-1)) * src_step + 2*x+0]; + dst_reg += src[(d * src_rows + min(2*y+0, src_rows-1)) * src_step + 2*x+1]; + dst_reg += src[(d * src_rows + min(2*y+1, src_rows-1)) * src_step + 2*x+1]; dst[(d * dst_rows + y) * dst_step + x] = saturate_cast(dst_reg); }