Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
3ef067cc
Commit
3ef067cc
authored
Sep 10, 2015
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add extra checks to data_step_down to prevent out-of-border access
parent
f903192c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
stereobp.cu
modules/gpu/src/cuda/stereobp.cu
+9
-9
stereobp.cpp
modules/gpu/src/stereobp.cpp
+3
-3
No files found.
modules/gpu/src/cuda/stereobp.cu
View file @
3ef067cc
...
...
@@ -255,7 +255,7 @@ namespace cv { namespace gpu { namespace device
///////////////////////////////////////////////////////////////
template <typename T>
__global__ void data_step_down(int dst_cols, int dst_rows, int src_rows, const PtrStep<T> src, PtrStep<T> dst)
__global__ void data_step_down(int dst_cols, int dst_rows, int src_
cols, int src_
rows, const PtrStep<T> src, PtrStep<T> dst)
{
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
...
...
@@ -264,10 +264,10 @@ namespace cv { namespace gpu { namespace device
{
for (int d = 0; d < cndisp; ++d)
{
float dst_reg = src.ptr(d * src_rows +
(2*y+0))[(2*x+0
)];
dst_reg += src.ptr(d * src_rows +
(2*y+1))[(2*x+0
)];
dst_reg += src.ptr(d * src_rows +
(2*y+0))[(2*x+
1)];
dst_reg += src.ptr(d * src_rows +
(2*y+1))[(2*x+
1)];
float dst_reg = src.ptr(d * src_rows +
::min(2*y+0, src_rows-1))[::min(2*x+0, src_cols-1
)];
dst_reg += src.ptr(d * src_rows +
::min(2*y+1, src_rows-1))[::min(2*x+0, src_cols-1
)];
dst_reg += src.ptr(d * src_rows +
::min(2*y+0, src_rows-1))[::min(2*x+1, src_cols-
1)];
dst_reg += src.ptr(d * src_rows +
::min(2*y+1, src_rows-1))[::min(2*x+1, src_cols-
1)];
dst.ptr(d * dst_rows + y)[x] = saturate_cast<T>(dst_reg);
}
...
...
@@ -275,7 +275,7 @@ namespace cv { namespace gpu { namespace device
}
template<typename T>
void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream)
void data_step_down_gpu(int dst_cols, int dst_rows, int src_
cols, int src_
rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream)
{
dim3 threads(32, 8, 1);
dim3 grid(1, 1, 1);
...
...
@@ -283,15 +283,15 @@ namespace cv { namespace gpu { namespace device
grid.x = divUp(dst_cols, threads.x);
grid.y = divUp(dst_rows, threads.y);
data_step_down<T><<<grid, threads, 0, stream>>>(dst_cols, dst_rows, src_rows, (PtrStepSz<T>)src, (PtrStepSz<T>)dst);
data_step_down<T><<<grid, threads, 0, stream>>>(dst_cols, dst_rows, src_
cols, src_
rows, (PtrStepSz<T>)src, (PtrStepSz<T>)dst);
cudaSafeCall( cudaGetLastError() );
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
template void data_step_down_gpu<short>(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
template void data_step_down_gpu<float>(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
template void data_step_down_gpu<short>(int dst_cols, int dst_rows, int src_
cols, int src_
rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
template void data_step_down_gpu<float>(int dst_cols, int dst_rows, int src_
cols, int src_
rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
///////////////////////////////////////////////////////////////
/////////////////// level up messages ////////////////////////
...
...
modules/gpu/src/stereobp.cpp
View file @
3ef067cc
...
...
@@ -67,7 +67,7 @@ namespace cv { namespace gpu { namespace device
template
<
typename
T
,
typename
D
>
void
comp_data_gpu
(
const
PtrStepSzb
&
left
,
const
PtrStepSzb
&
right
,
const
PtrStepSzb
&
data
,
cudaStream_t
stream
);
template
<
typename
T
>
void
data_step_down_gpu
(
int
dst_cols
,
int
dst_rows
,
int
src_rows
,
const
PtrStepSzb
&
src
,
const
PtrStepSzb
&
dst
,
cudaStream_t
stream
);
void
data_step_down_gpu
(
int
dst_cols
,
int
dst_rows
,
int
src_
cols
,
int
src_
rows
,
const
PtrStepSzb
&
src
,
const
PtrStepSzb
&
dst
,
cudaStream_t
stream
);
template
<
typename
T
>
void
level_up_messages_gpu
(
int
dst_idx
,
int
dst_cols
,
int
dst_rows
,
int
src_rows
,
PtrStepSzb
*
mus
,
PtrStepSzb
*
mds
,
PtrStepSzb
*
mls
,
PtrStepSzb
*
mrs
,
cudaStream_t
stream
);
template
<
typename
T
>
...
...
@@ -253,7 +253,7 @@ namespace
void
calcBP
(
GpuMat
&
disp
,
Stream
&
stream
)
{
typedef
void
(
*
data_step_down_t
)(
int
dst_cols
,
int
dst_rows
,
int
src_rows
,
const
PtrStepSzb
&
src
,
const
PtrStepSzb
&
dst
,
cudaStream_t
stream
);
typedef
void
(
*
data_step_down_t
)(
int
dst_cols
,
int
dst_rows
,
int
src_
cols
,
int
src_
rows
,
const
PtrStepSzb
&
src
,
const
PtrStepSzb
&
dst
,
cudaStream_t
stream
);
static
const
data_step_down_t
data_step_down_callers
[
2
]
=
{
data_step_down_gpu
<
short
>
,
data_step_down_gpu
<
float
>
...
...
@@ -288,7 +288,7 @@ namespace
createContinuous
(
rows_all
[
i
]
*
rthis
.
ndisp
,
cols_all
[
i
],
rthis
.
msg_type
,
datas
[
i
]);
data_step_down_callers
[
funcIdx
](
cols_all
[
i
],
rows_all
[
i
],
rows_all
[
i
-
1
],
datas
[
i
-
1
],
datas
[
i
],
cudaStream
);
data_step_down_callers
[
funcIdx
](
cols_all
[
i
],
rows_all
[
i
],
cols_all
[
i
-
1
],
rows_all
[
i
-
1
],
datas
[
i
-
1
],
datas
[
i
],
cudaStream
);
}
PtrStepSzb
mus
[]
=
{
u
,
u2
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment