Fix for large image handling in OpenVX based implementation of HAL API

This commit is contained in:
Vitaly Tuzov 2016-11-09 22:32:57 +03:00
parent 67c404632a
commit ca1ce5fa5c

View File

@ -349,6 +349,8 @@ inline void setConstantBorder(vx_border_t &border, vx_uint8 val)
template <typename T> \
inline int ovx_hal_##hal_func(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h) \
{ \
if(w >= 4194304 || h >= 4194304) \
return CV_HAL_ERROR_NOT_IMPLEMENTED; \
try \
{ \
vxContext * ctx = vxContext::getContext(); \
@ -377,6 +379,8 @@ OVX_BINARY_OP(xor, {vxErr::check(vxuXor(ctx->ctx, ia.img, ib.img, ic.img));})
template <typename T>
inline int ovx_hal_mul(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h, double scale)
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
#ifdef _MSC_VER
const float MAGIC_SCALE = 0x0.01010102;
#else
@ -414,6 +418,8 @@ inline int ovx_hal_mul(const T *a, size_t astep, const T *b, size_t bstep, T *c,
inline int ovx_hal_not(const uchar *a, size_t astep, uchar *c, size_t cstep, int w, int h)
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
vxContext * ctx = vxContext::getContext();
@ -431,6 +437,8 @@ inline int ovx_hal_not(const uchar *a, size_t astep, uchar *c, size_t cstep, int
inline int ovx_hal_merge8u(const uchar **src_data, uchar *dst_data, int len, int cn)
{
if (len >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (cn != 3 && cn != 4)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
@ -454,6 +462,8 @@ inline int ovx_hal_merge8u(const uchar **src_data, uchar *dst_data, int len, int
inline int ovx_hal_resize(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, double inv_scale_x, double inv_scale_y, int interpolation)
{
if (aw >= 4194304 || ah >= 4194304 || bw >= 4194304 || bh >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
vxContext * ctx = vxContext::getContext();
@ -489,6 +499,8 @@ inline int ovx_hal_resize(int atype, const uchar *a, size_t astep, int aw, int a
inline int ovx_hal_warpAffine(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, const double M[6], int interpolation, int borderType, const double borderValue[4])
{
if (aw >= 4194304 || ah >= 4194304 || bw >= 4194304 || bh >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
vxContext * ctx = vxContext::getContext();
@ -546,6 +558,8 @@ inline int ovx_hal_warpAffine(int atype, const uchar *a, size_t astep, int aw, i
inline int ovx_hal_warpPerspectve(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, const double M[9], int interpolation, int borderType, const double borderValue[4])
{
if (aw >= 4194304 || ah >= 4194304 || bw >= 4194304 || bh >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
vxContext * ctx = vxContext::getContext();
@ -689,6 +703,8 @@ inline int ovx_hal_filterFree(cvhalFilter2D *filter_context)
inline int ovx_hal_filter(cvhalFilter2D *filter_context, uchar *a, size_t astep, uchar *b, size_t bstep, int w, int h, int , int , int , int )
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
FilterCtx* cnv = (FilterCtx*)filter_context;
@ -909,6 +925,8 @@ inline int ovx_hal_morphFree(cvhalFilter2D *filter_context)
inline int ovx_hal_morph(cvhalFilter2D *filter_context, uchar *a, size_t astep, uchar *b, size_t bstep, int w, int h, int , int , int , int , int , int , int , int )
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
MorphCtx* mat = (MorphCtx*)filter_context;
@ -939,6 +957,8 @@ inline int ovx_hal_morph(cvhalFilter2D *filter_context, uchar *a, size_t astep,
inline int ovx_hal_cvtBGRtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int depth, int acn, int bcn, bool swapBlue)
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (depth != CV_8U || swapBlue || acn == bcn || (acn != 3 && acn != 4) || (bcn != 3 && bcn != 4))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -962,6 +982,8 @@ inline int ovx_hal_cvtBGRtoBGR(const uchar * a, size_t astep, uchar * b, size_t
inline int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx)
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (bcn != 3 && bcn != 4))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -989,6 +1011,8 @@ 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 (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (bcn != 3 && bcn != 4) || uIdx || (size_t)w / 2 != astep - (size_t)w / 2)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -1016,6 +1040,8 @@ 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 (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (acn != 3 && acn != 4) || uIdx || (size_t)w / 2 != bstep - (size_t)w / 2)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -1039,6 +1065,8 @@ inline int ovx_hal_cvtBGRtoThreePlaneYUV(const uchar * a, size_t astep, uchar *
inline int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx, int ycn)
{
if (w >= 4194304 || h >= 4194304)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (bcn != 3 && bcn != 4) || uIdx)
return CV_HAL_ERROR_NOT_IMPLEMENTED;