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
34530da6
Commit
34530da6
authored
Mar 06, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix coverity issues
parent
094a5b0c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
61 deletions
+76
-61
minmax.cpp
modules/core/src/minmax.cpp
+1
-0
norm.cpp
modules/core/src/norm.cpp
+75
-61
No files found.
modules/core/src/minmax.cpp
View file @
34530da6
...
@@ -1089,6 +1089,7 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc
...
@@ -1089,6 +1089,7 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc
getMinMaxRes
<
double
>
getMinMaxRes
<
double
>
};
};
CV_Assert
(
ddepth
<=
CV_64F
);
getMinMaxResFunc
func
=
functab
[
ddepth
];
getMinMaxResFunc
func
=
functab
[
ddepth
];
int
locTemp
[
2
];
int
locTemp
[
2
];
...
...
modules/core/src/norm.cpp
View file @
34530da6
...
@@ -710,51 +710,58 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
...
@@ -710,51 +710,58 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
result
;
result
;
result
.
d
=
0
;
result
.
d
=
0
;
NAryMatIterator
it
(
arrays
,
ptrs
);
NAryMatIterator
it
(
arrays
,
ptrs
);
int
j
,
total
=
(
int
)
it
.
size
,
blockSize
=
total
,
intSumBlockSize
=
0
,
count
=
0
;
CV_CheckLT
((
size_t
)
it
.
size
,
(
size_t
)
INT_MAX
,
""
);
bool
blockSum
=
(
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
((
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
);
int
isum
=
0
;
int
*
ibuf
=
&
result
.
i
;
size_t
esz
=
0
;
if
(
blockSum
)
{
intSumBlockSize
=
(
normType
==
NORM_L1
&&
depth
<=
CV_8S
?
(
1
<<
23
)
:
(
1
<<
15
))
/
cn
;
blockSize
=
std
::
min
(
blockSize
,
intSumBlockSize
);
ibuf
=
&
isum
;
esz
=
src
.
elemSize
();
}
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
if
((
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
((
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
))
{
{
for
(
j
=
0
;
j
<
total
;
j
+=
blockSize
)
// special case to handle "integer" overflow in accumulator
const
size_t
esz
=
src
.
elemSize
();
const
int
total
=
(
int
)
it
.
size
;
const
int
intSumBlockSize
=
(
normType
==
NORM_L1
&&
depth
<=
CV_8S
?
(
1
<<
23
)
:
(
1
<<
15
))
/
cn
;
const
int
blockSize
=
std
::
min
(
total
,
intSumBlockSize
);
int
isum
=
0
;
int
count
=
0
;
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
{
{
int
bsz
=
std
::
min
(
total
-
j
,
blockSize
);
for
(
int
j
=
0
;
j
<
total
;
j
+=
blockSize
)
func
(
ptrs
[
0
],
ptrs
[
1
],
(
uchar
*
)
ibuf
,
bsz
,
cn
);
count
+=
bsz
;
if
(
blockSum
&&
(
count
+
blockSize
>=
intSumBlockSize
||
(
i
+
1
>=
it
.
nplanes
&&
j
+
bsz
>=
total
))
)
{
{
result
.
d
+=
isum
;
int
bsz
=
std
::
min
(
total
-
j
,
blockSize
);
isum
=
0
;
func
(
ptrs
[
0
],
ptrs
[
1
],
(
uchar
*
)
&
isum
,
bsz
,
cn
);
count
=
0
;
count
+=
bsz
;
if
(
count
+
blockSize
>=
intSumBlockSize
||
(
i
+
1
>=
it
.
nplanes
&&
j
+
bsz
>=
total
))
{
result
.
d
+=
isum
;
isum
=
0
;
count
=
0
;
}
ptrs
[
0
]
+=
bsz
*
esz
;
if
(
ptrs
[
1
])
ptrs
[
1
]
+=
bsz
;
}
}
ptrs
[
0
]
+=
bsz
*
esz
;
}
if
(
ptrs
[
1
]
)
}
ptrs
[
1
]
+=
bsz
;
else
{
// generic implementation
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
{
func
(
ptrs
[
0
],
ptrs
[
1
],
(
uchar
*
)
&
result
,
(
int
)
it
.
size
,
cn
);
}
}
}
}
if
(
normType
==
NORM_INF
)
if
(
normType
==
NORM_INF
)
{
{
if
(
depth
==
CV_64F
)
if
(
depth
==
CV_64F
)
;
return
result
.
d
;
else
if
(
depth
==
CV_32F
)
else
if
(
depth
==
CV_32F
)
re
sult
.
d
=
result
.
f
;
re
turn
result
.
f
;
else
else
re
sult
.
d
=
result
.
i
;
re
turn
result
.
i
;
}
}
else
if
(
normType
==
NORM_L2
)
else
if
(
normType
==
NORM_L2
)
re
sult
.
d
=
std
::
sqrt
(
result
.
d
);
re
turn
std
::
sqrt
(
result
.
d
);
return
result
.
d
;
return
result
.
d
;
}
}
...
@@ -1170,52 +1177,59 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
...
@@ -1170,52 +1177,59 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
result
;
result
;
result
.
d
=
0
;
result
.
d
=
0
;
NAryMatIterator
it
(
arrays
,
ptrs
);
NAryMatIterator
it
(
arrays
,
ptrs
);
int
j
,
total
=
(
int
)
it
.
size
,
blockSize
=
total
,
intSumBlockSize
=
0
,
count
=
0
;
CV_CheckLT
((
size_t
)
it
.
size
,
(
size_t
)
INT_MAX
,
""
);
bool
blockSum
=
(
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
((
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
);
unsigned
isum
=
0
;
unsigned
*
ibuf
=
&
result
.
u
;
size_t
esz
=
0
;
if
(
blockSum
)
{
intSumBlockSize
=
normType
==
NORM_L1
&&
depth
<=
CV_8S
?
(
1
<<
23
)
:
(
1
<<
15
);
blockSize
=
std
::
min
(
blockSize
,
intSumBlockSize
);
ibuf
=
&
isum
;
esz
=
src1
.
elemSize
();
}
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
if
((
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
((
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
))
{
{
for
(
j
=
0
;
j
<
total
;
j
+=
blockSize
)
// special case to handle "integer" overflow in accumulator
const
size_t
esz
=
src1
.
elemSize
();
const
int
total
=
(
int
)
it
.
size
;
const
int
intSumBlockSize
=
normType
==
NORM_L1
&&
depth
<=
CV_8S
?
(
1
<<
23
)
:
(
1
<<
15
);
const
int
blockSize
=
std
::
min
(
total
,
intSumBlockSize
);
int
isum
=
0
;
int
count
=
0
;
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
{
{
int
bsz
=
std
::
min
(
total
-
j
,
blockSize
);
for
(
int
j
=
0
;
j
<
total
;
j
+=
blockSize
)
func
(
ptrs
[
0
],
ptrs
[
1
],
ptrs
[
2
],
(
uchar
*
)
ibuf
,
bsz
,
cn
);
count
+=
bsz
;
if
(
blockSum
&&
(
count
+
blockSize
>=
intSumBlockSize
||
(
i
+
1
>=
it
.
nplanes
&&
j
+
bsz
>=
total
))
)
{
{
result
.
d
+=
isum
;
int
bsz
=
std
::
min
(
total
-
j
,
blockSize
);
isum
=
0
;
func
(
ptrs
[
0
],
ptrs
[
1
],
ptrs
[
2
],
(
uchar
*
)
&
isum
,
bsz
,
cn
);
count
=
0
;
count
+=
bsz
;
if
(
count
+
blockSize
>=
intSumBlockSize
||
(
i
+
1
>=
it
.
nplanes
&&
j
+
bsz
>=
total
))
{
result
.
d
+=
isum
;
isum
=
0
;
count
=
0
;
}
ptrs
[
0
]
+=
bsz
*
esz
;
ptrs
[
1
]
+=
bsz
*
esz
;
if
(
ptrs
[
2
])
ptrs
[
2
]
+=
bsz
;
}
}
ptrs
[
0
]
+=
bsz
*
esz
;
}
ptrs
[
1
]
+=
bsz
*
esz
;
}
if
(
ptrs
[
2
]
)
else
ptrs
[
2
]
+=
bsz
;
{
// generic implementation
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
{
func
(
ptrs
[
0
],
ptrs
[
1
],
ptrs
[
2
],
(
uchar
*
)
&
result
,
(
int
)
it
.
size
,
cn
);
}
}
}
}
if
(
normType
==
NORM_INF
)
if
(
normType
==
NORM_INF
)
{
{
if
(
depth
==
CV_64F
)
if
(
depth
==
CV_64F
)
;
return
result
.
d
;
else
if
(
depth
==
CV_32F
)
else
if
(
depth
==
CV_32F
)
re
sult
.
d
=
result
.
f
;
re
turn
result
.
f
;
else
else
re
sult
.
d
=
result
.
u
;
re
turn
result
.
u
;
}
}
else
if
(
normType
==
NORM_L2
)
else
if
(
normType
==
NORM_L2
)
re
sult
.
d
=
std
::
sqrt
(
result
.
d
);
re
turn
std
::
sqrt
(
result
.
d
);
return
result
.
d
;
return
result
.
d
;
}
}
...
...
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