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
d0a83909
Commit
d0a83909
authored
Jun 08, 2016
by
Tomoaki Teshima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix run time error on Mac
* integrate HW version and SW version to same function
parent
fd76ed5c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
50 deletions
+42
-50
convert.cpp
modules/core/src/convert.cpp
+42
-50
No files found.
modules/core/src/convert.cpp
View file @
d0a83909
...
...
@@ -4540,24 +4540,9 @@ static short convertFp16SW(float fp32)
}
#endif
template
<
typename
T
,
typename
DT
>
static
void
cvtScaleHalfSW_
(
const
T
*
src
,
size_t
sstep
,
DT
*
dst
,
size_t
dstep
,
Size
size
)
{
sstep
/=
sizeof
(
src
[
0
]);
dstep
/=
sizeof
(
dst
[
0
]);
for
(
;
size
.
height
--
;
src
+=
sstep
,
dst
+=
dstep
)
{
for
(
int
x
=
0
;
x
<
size
.
width
;
x
++
)
{
dst
[
x
]
=
convertFp16SW
(
src
[
x
]);
}
}
}
// template for FP16 HW conversion function
template
<
typename
T
,
typename
DT
>
static
void
cvtScaleHalf
HW
_
(
const
T
*
src
,
size_t
sstep
,
DT
*
dst
,
size_t
dstep
,
Size
size
)
cvtScaleHalf_
(
const
T
*
src
,
size_t
sstep
,
DT
*
dst
,
size_t
dstep
,
Size
size
)
{
sstep
/=
sizeof
(
src
[
0
]);
dstep
/=
sizeof
(
dst
[
0
]);
...
...
@@ -4573,11 +4558,13 @@ cvtScaleHalfHW_( const T* src, size_t sstep, DT* dst, size_t dstep, Size size)
}
template
<>
void
cvtScaleHalf
HW
_
<
float
,
short
>
(
const
float
*
src
,
size_t
sstep
,
short
*
dst
,
size_t
dstep
,
Size
size
)
cvtScaleHalf_
<
float
,
short
>
(
const
float
*
src
,
size_t
sstep
,
short
*
dst
,
size_t
dstep
,
Size
size
)
{
sstep
/=
sizeof
(
src
[
0
]);
dstep
/=
sizeof
(
dst
[
0
]);
if
(
checkHardwareSupport
(
CV_FP16
)
)
{
for
(
;
size
.
height
--
;
src
+=
sstep
,
dst
+=
dstep
)
{
int
x
=
0
;
...
...
@@ -4608,19 +4595,33 @@ cvtScaleHalfHW_<float, short>( const float* src, size_t sstep, short* dst, size_
dst
[
x
]
=
convertFp16SW
(
src
[
x
]);
}
}
}
else
{
for
(
;
size
.
height
--
;
src
+=
sstep
,
dst
+=
dstep
)
{
int
x
=
0
;
for
(
;
x
<
size
.
width
;
x
++
)
{
dst
[
x
]
=
convertFp16SW
(
src
[
x
]);
}
}
}
}
template
<>
void
cvtScaleHalf
HW
_
<
short
,
float
>
(
const
short
*
src
,
size_t
sstep
,
float
*
dst
,
size_t
dstep
,
Size
size
)
cvtScaleHalf_
<
short
,
float
>
(
const
short
*
src
,
size_t
sstep
,
float
*
dst
,
size_t
dstep
,
Size
size
)
{
sstep
/=
sizeof
(
src
[
0
]);
dstep
/=
sizeof
(
dst
[
0
]);
if
(
checkHardwareSupport
(
CV_FP16
)
)
{
for
(
;
size
.
height
--
;
src
+=
sstep
,
dst
+=
dstep
)
{
int
x
=
0
;
if
(
(
(
intptr_t
)
dst
&
0xf
)
==
0
&&
(
(
intptr_t
)
src
&
0xf
)
==
0
)
if
(
(
(
intptr_t
)
dst
&
0xf
)
==
0
&&
(
(
intptr_t
)
src
&
0xf
)
==
0
&&
checkHardwareSupport
(
CV_CPU_FP16
)
)
{
#if CV_FP16
for
(
;
x
<=
size
.
width
-
4
;
x
+=
4
)
...
...
@@ -4646,6 +4647,18 @@ cvtScaleHalfHW_<short, float>( const short* src, size_t sstep, float* dst, size_
dst
[
x
]
=
convertFp16SW
(
src
[
x
]);
}
}
}
else
{
for
(
;
size
.
height
--
;
src
+=
sstep
,
dst
+=
dstep
)
{
int
x
=
0
;
for
(
;
x
<
size
.
width
;
x
++
)
{
dst
[
x
]
=
convertFp16SW
(
src
[
x
]);
}
}
}
}
template
<
typename
T
,
typename
DT
>
static
void
...
...
@@ -4735,11 +4748,11 @@ static void cvtScaleAbs##suffix( const stype* src, size_t sstep, const uchar*, s
tfunc(src, sstep, dst, dstep, size, (wtype)scale[0], (wtype)scale[1]); \
}
#define DEF_CVT_SCALE_FP16_FUNC(suffix, stype, dtype
, resource
) \
static void cvtScaleHalf##suffix
##resource
( const stype* src, size_t sstep, const uchar*, size_t, \
#define DEF_CVT_SCALE_FP16_FUNC(suffix, stype, dtype) \
static void cvtScaleHalf##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
{ \
cvtScaleHalf##
resource##
_<stype,dtype>(src, sstep, dst, dstep, size); \
cvtScaleHalf##_<stype,dtype>(src, sstep, dst, dstep, size); \
}
#define DEF_CVT_SCALE_FUNC(suffix, stype, dtype, wtype) \
...
...
@@ -4798,10 +4811,8 @@ DEF_CVT_SCALE_ABS_FUNC(32s8u, cvtScaleAbs_, int, uchar, float)
DEF_CVT_SCALE_ABS_FUNC
(
32
f8u
,
cvtScaleAbs_
,
float
,
uchar
,
float
)
DEF_CVT_SCALE_ABS_FUNC
(
64
f8u
,
cvtScaleAbs_
,
double
,
uchar
,
float
)
DEF_CVT_SCALE_FP16_FUNC
(
32
f16f
,
float
,
short
,
SW
)
DEF_CVT_SCALE_FP16_FUNC
(
16
f32f
,
short
,
float
,
SW
)
DEF_CVT_SCALE_FP16_FUNC
(
32
f16f
,
float
,
short
,
HW
)
DEF_CVT_SCALE_FP16_FUNC
(
16
f32f
,
short
,
float
,
HW
)
DEF_CVT_SCALE_FP16_FUNC
(
32
f16f
,
float
,
short
)
DEF_CVT_SCALE_FP16_FUNC
(
16
f32f
,
short
,
float
)
DEF_CVT_SCALE_FUNC
(
8u
,
uchar
,
uchar
,
float
)
DEF_CVT_SCALE_FUNC
(
8
s8u
,
schar
,
uchar
,
float
)
...
...
@@ -4924,28 +4935,15 @@ static BinaryFunc getCvtScaleAbsFunc(int depth)
return
cvtScaleAbsTab
[
depth
];
}
BinaryFunc
getConvertFuncFp16
(
int
ddepth
,
bool
useHW
)
BinaryFunc
getConvertFuncFp16
(
int
ddepth
)
{
static
BinaryFunc
cvtTab
HW
[]
=
static
BinaryFunc
cvtTab
[]
=
{
0
,
0
,
0
,
(
BinaryFunc
)(
cvtScaleHalf32f16f
HW
),
0
,
(
BinaryFunc
)(
cvtScaleHalf16f32fHW
),
(
BinaryFunc
)(
cvtScaleHalf32f16f
),
0
,
(
BinaryFunc
)(
cvtScaleHalf16f32f
),
0
,
0
,
};
static
BinaryFunc
cvtTabSW
[]
=
{
0
,
0
,
0
,
(
BinaryFunc
)(
cvtScaleHalf32f16fSW
),
0
,
(
BinaryFunc
)(
cvtScaleHalf16f32fSW
),
0
,
0
,
};
if
(
useHW
==
true
)
{
return
cvtTabHW
[
CV_MAT_DEPTH
(
ddepth
)];
}
else
{
return
cvtTabSW
[
CV_MAT_DEPTH
(
ddepth
)];
}
return
cvtTab
[
CV_MAT_DEPTH
(
ddepth
)];
}
BinaryFunc
getConvertFunc
(
int
sdepth
,
int
ddepth
)
...
...
@@ -5134,12 +5132,6 @@ void cv::convertScaleAbs( InputArray _src, OutputArray _dst, double alpha, doubl
void
cv
::
convertFp16
(
InputArray
_src
,
OutputArray
_dst
)
{
bool
useHW
=
true
;
if
(
checkHardwareSupport
(
CV_CPU_FP16
)
==
false
)
{
useHW
=
false
;
}
Mat
src
=
_src
.
getMat
();
int
ddepth
=
0
;
...
...
@@ -5158,7 +5150,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst)
int
type
=
CV_MAKETYPE
(
ddepth
,
src
.
channels
());
_dst
.
create
(
src
.
dims
,
src
.
size
,
type
);
Mat
dst
=
_dst
.
getMat
();
BinaryFunc
func
=
getConvertFuncFp16
(
ddepth
,
useHW
);
BinaryFunc
func
=
getConvertFuncFp16
(
ddepth
);
int
cn
=
src
.
channels
();
CV_Assert
(
func
!=
0
);
...
...
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