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
ba23dec7
Commit
ba23dec7
authored
Sep 29, 2016
by
Vitaly Tuzov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for OpenVX implementation of color conversion HAL API
parent
25b01469
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
38 deletions
+40
-38
openvx_hal.hpp
3rdparty/openvx/include/openvx_hal.hpp
+40
-38
No files found.
3rdparty/openvx/include/openvx_hal.hpp
View file @
ba23dec7
...
...
@@ -171,10 +171,6 @@ struct vxImage
addr
.
dim_y
=
h
;
addr
.
stride_x
=
sizeof
(
T
);
addr
.
stride_y
=
(
vx_int32
)
step
;
addr
.
scale_x
=
VX_SCALE_UNITY
;
addr
.
scale_y
=
VX_SCALE_UNITY
;
addr
.
step_x
=
1
;
addr
.
step_y
=
1
;
void
*
ptrs
[]
=
{
(
void
*
)
data
};
img
=
vxCreateImageFromHandle
(
ctx
.
ctx
,
VX_Traits
<
T
>::
ImgType
,
&
addr
,
ptrs
,
VX_MEMORY_TYPE_HOST
);
vxErr
::
check
(
img
);
...
...
@@ -200,12 +196,9 @@ struct vxImage
addr
[
0
].
dim_y
=
h
;
addr
[
0
].
stride_x
=
imgType
==
VX_DF_IMAGE_U8
?
1
:
imgType
==
VX_DF_IMAGE_RGB
?
3
:
(
imgType
==
VX_DF_IMAGE_U16
||
imgType
==
VX_DF_IMAGE_S16
)
?
2
:
4
;
(
imgType
==
VX_DF_IMAGE_U16
||
imgType
==
VX_DF_IMAGE_S16
||
imgType
==
VX_DF_IMAGE_UYVY
||
imgType
==
VX_DF_IMAGE_YUYV
)
?
2
:
4
;
addr
[
0
].
stride_y
=
(
vx_int32
)
step
;
addr
[
0
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
0
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
0
].
step_x
=
(
imgType
==
VX_DF_IMAGE_UYVY
||
imgType
==
VX_DF_IMAGE_YUYV
)
?
2
:
1
;
addr
[
0
].
step_y
=
1
;
ptrs
[
0
]
=
(
void
*
)
data
;
break
;
case
VX_DF_IMAGE_NV12
:
...
...
@@ -214,19 +207,11 @@ struct vxImage
addr
[
0
].
dim_y
=
h
;
addr
[
0
].
stride_x
=
1
;
addr
[
0
].
stride_y
=
(
vx_int32
)
step
;
addr
[
0
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
0
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
0
].
step_x
=
1
;
addr
[
0
].
step_y
=
1
;
ptrs
[
0
]
=
(
void
*
)
data
;
addr
[
1
].
dim_x
=
(
w
+
1
)
/
2
;
addr
[
1
].
dim_y
=
(
h
+
1
)
/
2
;
addr
[
1
].
dim_x
=
w
/
2
;
addr
[
1
].
dim_y
=
h
/
2
;
addr
[
1
].
stride_x
=
2
;
addr
[
1
].
stride_y
=
(
vx_int32
)
step
;
addr
[
1
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
1
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
1
].
step_x
=
2
;
addr
[
1
].
step_y
=
2
;
ptrs
[
1
]
=
(
void
*
)(
data
+
h
*
step
);
break
;
case
VX_DF_IMAGE_IYUV
:
...
...
@@ -235,29 +220,19 @@ struct vxImage
addr
[
0
].
dim_y
=
h
;
addr
[
0
].
stride_x
=
1
;
addr
[
0
].
stride_y
=
(
vx_int32
)
step
;
addr
[
0
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
0
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
0
].
step_x
=
1
;
addr
[
0
].
step_y
=
1
;
ptrs
[
0
]
=
(
void
*
)
data
;
addr
[
1
].
dim_x
=
imgType
==
VX_DF_IMAGE_YUV4
?
w
:
(
w
+
1
)
/
2
;
addr
[
1
].
dim_y
=
imgType
==
VX_DF_IMAGE_YUV4
?
h
:
(
h
+
1
)
/
2
;
addr
[
1
].
dim_x
=
imgType
==
VX_DF_IMAGE_YUV4
?
w
:
w
/
2
;
addr
[
1
].
dim_y
=
imgType
==
VX_DF_IMAGE_YUV4
?
h
:
h
/
2
;
if
(
addr
[
1
].
dim_x
!=
(
step
-
addr
[
1
].
dim_x
))
vxErr
(
VX_ERROR_INVALID_PARAMETERS
,
"UV planes use variable stride"
).
check
();
addr
[
1
].
stride_x
=
1
;
addr
[
1
].
stride_y
=
(
vx_int32
)
step
;
addr
[
1
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
1
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
1
].
step_x
=
imgType
==
VX_DF_IMAGE_YUV4
?
1
:
2
;
addr
[
1
].
step_y
=
imgType
==
VX_DF_IMAGE_YUV4
?
1
:
2
;
addr
[
1
].
stride_y
=
(
vx_int32
)
addr
[
1
].
dim_x
;
ptrs
[
1
]
=
(
void
*
)(
data
+
h
*
step
);
addr
[
2
].
dim_x
=
addr
[
1
].
dim_x
;
addr
[
2
].
dim_y
=
addr
[
1
].
dim_y
;
addr
[
2
].
stride_x
=
1
;
addr
[
2
].
stride_y
=
(
vx_int32
)
step
;
addr
[
2
].
scale_x
=
VX_SCALE_UNITY
;
addr
[
2
].
scale_y
=
VX_SCALE_UNITY
;
addr
[
2
].
step_x
=
addr
[
1
].
step_x
;
addr
[
2
].
step_y
=
addr
[
1
].
step_y
;
ptrs
[
2
]
=
(
void
*
)(
data
+
(
h
+
addr
[
1
].
dim_y
)
*
step
);
addr
[
2
].
stride_y
=
addr
[
1
].
stride_y
;
ptrs
[
2
]
=
(
void
*
)(
data
+
h
*
step
+
addr
[
1
].
dim_y
*
addr
[
1
].
stride_y
);
break
;
default
:
vxErr
(
VX_ERROR_INVALID_PARAMETERS
,
"Bad image format"
).
check
();
...
...
@@ -897,6 +872,9 @@ inline int ovx_hal_cvtBGRtoBGR(const uchar * a, size_t astep, uchar * b, size_t
if
(
depth
!=
CV_8U
||
swapBlue
||
acn
==
bcn
||
(
acn
!=
3
&&
acn
!=
4
)
||
(
bcn
!=
3
&&
bcn
!=
4
))
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
if
(
w
&
1
||
h
&
1
)
// It's strange but sample implementation unable to convert odd sized images
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
try
{
vxContext
*
ctx
=
vxContext
::
getContext
();
...
...
@@ -917,10 +895,17 @@ inline int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b,
if
(
!
swapBlue
||
(
bcn
!=
3
&&
bcn
!=
4
))
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
if
(
w
&
1
||
h
&
1
)
// It's not described in spec but sample implementation unable to convert odd sized images
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
try
{
vxContext
*
ctx
=
vxContext
::
getContext
();
vxImage
ia
(
*
ctx
,
uIdx
?
VX_DF_IMAGE_NV21
:
VX_DF_IMAGE_NV12
,
a
,
astep
,
w
,
h
);
vx_channel_range_e
cRange
;
vxErr
::
check
(
vxQueryImage
(
ia
.
img
,
VX_IMAGE_RANGE
,
&
cRange
,
sizeof
(
cRange
)));
if
(
cRange
==
VX_CHANNEL_RANGE_FULL
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
// OpenCV store NV12/NV21 as RANGE_RESTRICTED while OpenVX expect RANGE_FULL
vxImage
ib
(
*
ctx
,
bcn
==
3
?
VX_DF_IMAGE_RGB
:
VX_DF_IMAGE_RGBX
,
b
,
bstep
,
w
,
h
);
vxErr
::
check
(
vxuColorConvert
(
ctx
->
ctx
,
ia
.
img
,
ib
.
img
));
}
...
...
@@ -934,13 +919,20 @@ inline int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b,
inline
int
ovx_hal_cvtThreePlaneYUVtoBGR
(
const
uchar
*
a
,
size_t
astep
,
uchar
*
b
,
size_t
bstep
,
int
w
,
int
h
,
int
bcn
,
bool
swapBlue
,
int
uIdx
)
{
if
(
!
swapBlue
||
(
bcn
!=
3
&&
bcn
!=
4
)
||
uIdx
)
if
(
!
swapBlue
||
(
bcn
!=
3
&&
bcn
!=
4
)
||
uIdx
||
w
/
2
!=
astep
-
w
/
2
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
if
(
w
&
1
||
h
&
1
)
// It's not described in spec but sample implementation unable to convert odd sized images
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
try
{
vxContext
*
ctx
=
vxContext
::
getContext
();
vxImage
ia
(
*
ctx
,
VX_DF_IMAGE_IYUV
,
a
,
astep
,
w
,
h
);
vx_channel_range_e
cRange
;
vxErr
::
check
(
vxQueryImage
(
ia
.
img
,
VX_IMAGE_RANGE
,
&
cRange
,
sizeof
(
cRange
)));
if
(
cRange
==
VX_CHANNEL_RANGE_FULL
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
// OpenCV store NV12/NV21 as RANGE_RESTRICTED while OpenVX expect RANGE_FULL
vxImage
ib
(
*
ctx
,
bcn
==
3
?
VX_DF_IMAGE_RGB
:
VX_DF_IMAGE_RGBX
,
b
,
bstep
,
w
,
h
);
vxErr
::
check
(
vxuColorConvert
(
ctx
->
ctx
,
ia
.
img
,
ib
.
img
));
}
...
...
@@ -954,7 +946,10 @@ inline int ovx_hal_cvtThreePlaneYUVtoBGR(const uchar * a, size_t astep, uchar *
inline
int
ovx_hal_cvtBGRtoThreePlaneYUV
(
const
uchar
*
a
,
size_t
astep
,
uchar
*
b
,
size_t
bstep
,
int
w
,
int
h
,
int
acn
,
bool
swapBlue
,
int
uIdx
)
{
if
(
!
swapBlue
||
(
acn
!=
3
&&
acn
!=
4
)
||
uIdx
)
if
(
!
swapBlue
||
(
acn
!=
3
&&
acn
!=
4
)
||
uIdx
||
w
/
2
!=
bstep
-
w
/
2
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
if
(
w
&
1
||
h
&
1
)
// It's not described in spec but sample implementation unable to convert odd sized images
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
try
...
...
@@ -977,10 +972,17 @@ inline int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b,
if
(
!
swapBlue
||
(
bcn
!=
3
&&
bcn
!=
4
)
||
uIdx
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
if
(
w
&
1
)
// It's not described in spec but sample implementation unable to convert odd sized images
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
try
{
vxContext
*
ctx
=
vxContext
::
getContext
();
vxImage
ia
(
*
ctx
,
ycn
?
VX_DF_IMAGE_UYVY
:
VX_DF_IMAGE_YUYV
,
a
,
astep
,
w
,
h
);
vx_channel_range_e
cRange
;
vxErr
::
check
(
vxQueryImage
(
ia
.
img
,
VX_IMAGE_RANGE
,
&
cRange
,
sizeof
(
cRange
)));
if
(
cRange
==
VX_CHANNEL_RANGE_FULL
)
return
CV_HAL_ERROR_NOT_IMPLEMENTED
;
// OpenCV store NV12/NV21 as RANGE_RESTRICTED while OpenVX expect RANGE_FULL
vxImage
ib
(
*
ctx
,
bcn
==
3
?
VX_DF_IMAGE_RGB
:
VX_DF_IMAGE_RGBX
,
b
,
bstep
,
w
,
h
);
vxErr
::
check
(
vxuColorConvert
(
ctx
->
ctx
,
ia
.
img
,
ib
.
img
));
}
...
...
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