From 19cfe6b7510b92320da893df77f0a3f4e69214cc Mon Sep 17 00:00:00 2001 From: Michael Platings Date: Mon, 13 May 2024 10:16:44 +0000 Subject: [PATCH] Remove operations from OpenCV HAL The performance uplift from these operations is inconsistent across devices so remove them from the HAL until a consistent uplift can be achieved. --- adapters/opencv/kleidicv_hal.cpp | 26 ++++---------------------- doc/opencv.md | 10 +++++----- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/adapters/opencv/kleidicv_hal.cpp b/adapters/opencv/kleidicv_hal.cpp index 9cb32ae4d..b94c451e0 100644 --- a/adapters/opencv/kleidicv_hal.cpp +++ b/adapters/opencv/kleidicv_hal.cpp @@ -97,28 +97,6 @@ int bgr_to_bgr(const uchar *src_data, size_t src_step, uchar *dst_data, reinterpret_cast(src_data), src_step, reinterpret_cast(dst_data), dst_step, width, height)); } - - if (scn == 3 && dcn == 4) { - if (swapBlue) { - return convert_error(kleidicv_rgb_to_bgra_u8( - reinterpret_cast(src_data), src_step, - reinterpret_cast(dst_data), dst_step, width, height)); - } - return convert_error(kleidicv_rgb_to_rgba_u8( - reinterpret_cast(src_data), src_step, - reinterpret_cast(dst_data), dst_step, width, height)); - } - - if (scn == 4 && dcn == 3) { - if (swapBlue) { - return convert_error(kleidicv_rgba_to_bgr_u8( - reinterpret_cast(src_data), src_step, - reinterpret_cast(dst_data), dst_step, width, height)); - } - return convert_error(kleidicv_rgba_to_rgb_u8( - reinterpret_cast(src_data), src_step, - reinterpret_cast(dst_data), dst_step, width, height)); - } } return CV_HAL_ERROR_NOT_IMPLEMENTED; @@ -498,6 +476,10 @@ int resize(int src_type, const uchar *src_data, size_t src_step, int src_width, kleidicv_resize_linear_u8(src_data, src_step, src_width, src_height, dst_data, dst_step, dst_width, dst_height)); case CV_32F: + // 4*4 performance uplift is inconsistent so don't use it. + if (src_width * 4 == dst_width && src_height * 4 == dst_height) { + return CV_HAL_ERROR_NOT_IMPLEMENTED; + } return convert_error(kleidicv_resize_linear_f32( reinterpret_cast(src_data), src_step, src_width, src_height, reinterpret_cast(dst_data), dst_step, dst_width, diff --git a/doc/opencv.md b/doc/opencv.md index 890122b89..11013fd53 100644 --- a/doc/opencv.md +++ b/doc/opencv.md @@ -31,10 +31,10 @@ Notes on parameters: RGB to RGB/RGBA image conversion. All supported permutations listed in the table below. | | RGB | BGR | RGBA | BGRA | |-----|-----|-----|------|------| -| RGB | x | x | x | x | -| BGR | x | x | x | x | -| RGBA| x | x | x | x | -| BGRA| x | x | x | x | +| RGB | x | x | | | +| BGR | x | x | | | +| RGBA| | | x | x | +| BGRA| | | x | x | Notes on parameters: * `depth` - only supports `CV_8U` depth. @@ -125,7 +125,7 @@ Release context set up by [`morphology_init`](#morphology_init). ### `resize` Notes on parameters: * In-place operation not supported. -* `src_type` - only supports single-channel `CV_8U` or `CV_32F`. +* `src_type` - only supports `CV_8UC1` or, for 2*2 resize only, `CV_32FC1`. * `dst_width`,`dst_height` - must both be the same multiple of `src_width` and `src_height` respectively, and that multiple must be either 2 or 4. * `inv_scale_x`,`inv_scale_y` - must be 0 or `dst_width / src_width`. * `border_type` - Must be `INTER_LINEAR`. -- GitLab