Extended restrictions for OpenVX HAL calls on small images
authorVitaly Tuzov <terfendail@mediana.jetos.com>
Wed, 29 Mar 2017 06:01:40 +0000 (09:01 +0300)
committerVitaly Tuzov <terfendail@mediana.jetos.com>
Thu, 6 Apr 2017 15:17:34 +0000 (18:17 +0300)
3rdparty/openvx/hal/openvx_hal.cpp
modules/core/include/opencv2/core/openvx/ovx_defs.hpp

index b6ff4ed..8327fc5 100644 (file)
@@ -82,7 +82,7 @@ inline bool dimTooBig(int size)
 }
 
 //OpenVX calls have essential overhead so it make sense to skip them for small images
-template <int kernel_id> inline bool             skipSmallImages(int w, int h) { return w*h < 3840 * 2160; }
+template <int kernel_id> inline bool             skipSmallImages(int w, int h) { return w*h < 7680 * 4320; }
 template <> inline bool      skipSmallImages<VX_KERNEL_MULTIPLY>(int w, int h) { return w*h <  640 *  480; }
 template <> inline bool skipSmallImages<VX_KERNEL_COLOR_CONVERT>(int w, int h) { return w*h < 2048 * 1536; }
 
@@ -175,7 +175,9 @@ OVX_BINARY_OP(xor, { ivx::IVX_CHECK_STATUS(vxuXor(ctx, ia, ib, ic)); }, VX_KERNE
 template <typename T>
 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(skipSmallImages<VX_KERNEL_MULTIPLY>(w, h))
+    if(scale == 1.0 || sizeof(T) > 1 ?
+       skipSmallImages<VX_KERNEL_ADD>(w, h) : /*actually it could be any kernel with generic minimum size*/
+       skipSmallImages<VX_KERNEL_MULTIPLY>(w, h) )
         return CV_HAL_ERROR_NOT_IMPLEMENTED;
     if (dimTooBig(w) || dimTooBig(h))
         return CV_HAL_ERROR_NOT_IMPLEMENTED;
index 9c23a83..09f3faa 100644 (file)
@@ -26,12 +26,12 @@ namespace ovx{
 CV_EXPORTS_W ivx::Context& getOpenVXContext();
 
 template <int kernel_id> inline bool skipSmallImages(int w, int h)     { return w*h < 3840 * 2160; }
-template <> inline bool skipSmallImages<VX_KERNEL_MINMAXLOC>(int w, int h) { return w*h < 1280*720; }
+template <> inline bool skipSmallImages<VX_KERNEL_MINMAXLOC>(int w, int h) { return w*h < 3840 * 2160; }
 template <> inline bool skipSmallImages<VX_KERNEL_MEDIAN_3x3>(int w, int h) { return w*h < 1280 * 720; }
 template <> inline bool skipSmallImages<VX_KERNEL_GAUSSIAN_3x3>(int w, int h) { return w*h < 1280 * 720; }
-template <> inline bool skipSmallImages<VX_KERNEL_BOX_3x3>(int w, int h) { return w*h < 1280 * 720; }
+template <> inline bool skipSmallImages<VX_KERNEL_BOX_3x3>(int w, int h) { return w*h < 1920 * 1080; }
 template <> inline bool skipSmallImages<VX_KERNEL_HISTOGRAM>(int w, int h) { return w*h < 2048 * 1536; }
-template <> inline bool skipSmallImages<VX_KERNEL_SOBEL_3x3>(int w, int h) { return w*h < 640 * 480; }
+template <> inline bool skipSmallImages<VX_KERNEL_SOBEL_3x3>(int w, int h) { return w*h < 1280 * 720; }
 template <> inline bool skipSmallImages<VX_KERNEL_CUSTOM_CONVOLUTION>(int w, int h) { return w*h < 1280 * 720; }
 
 }}