#include <climits>
#include <cmath>
+#ifndef VX_VENDOR_ID
+#define VX_VENDOR_ID VX_ID_DEFAULT
+#endif
+
#if VX_VERSION == VX_VERSION_1_0
#define VX_MEMORY_TYPE_HOST VX_IMPORT_TYPE_HOST
};
#endif
+inline bool dimTooBig(int size)
+{
+ if (VX_VENDOR_ID == VX_ID_KHRONOS || VX_VENDOR_ID == VX_ID_DEFAULT)
+ {
+ //OpenVX use uint32_t for image addressing
+ return ((unsigned)size > (UINT_MAX / VX_SCALE_UNITY));
+ }
+ else
+ return false;
+}
+
//==================================================================================================
// One more OpenVX C++ binding :-)
// ...
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) \
+ if(dimTooBig(w) || dimTooBig(h)) \
return CV_HAL_ERROR_NOT_IMPLEMENTED; \
try \
{ \
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
#ifdef _MSC_VER
const float MAGIC_SCALE = 0x0.01010102;
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
inline int ovx_hal_merge8u(const uchar **src_data, uchar *dst_data, int len, int cn)
{
- if (len >= 4194304)
+ if(dimTooBig(len))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (cn != 3 && cn != 4)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
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)
+ if(dimTooBig(aw) || dimTooBig(ah) || dimTooBig(bw) || dimTooBig(bh))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
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)
+ if(dimTooBig(aw) || dimTooBig(ah) || dimTooBig(bw) || dimTooBig(bh))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
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)
+ if(dimTooBig(aw) || dimTooBig(ah) || dimTooBig(bw) || dimTooBig(bh))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
try
{
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)
+ if(dimTooBig(w) || dimTooBig(h))
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;
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (bcn != 3 && bcn != 4))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
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)
+ if(dimTooBig(w) || dimTooBig(h))
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;
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)
+ if(dimTooBig(w) || dimTooBig(h))
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;
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)
+ if(dimTooBig(w) || dimTooBig(h))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (!swapBlue || (bcn != 3 && bcn != 4) || uIdx)
return CV_HAL_ERROR_NOT_IMPLEMENTED;