From 5bd64e09a360e9fa342fbd951a3635f065bc478e Mon Sep 17 00:00:00 2001 From: Rostislav Vasilikhin Date: Wed, 8 May 2024 16:45:08 +0200 Subject: [PATCH] Merge pull request #25554 from savuor:rv/hal_lut Merge pull request #25554 from savuor:rv/hal_lut HAL for LUT added #25554 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake --- modules/core/src/hal_replacement.hpp | 26 ++++++++++++++++++++++++++ modules/core/src/lut.cpp | 3 +++ 2 files changed, 29 insertions(+) diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index 498cd63700..bbdfc1e180 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -214,6 +214,32 @@ inline int hal_ni_not8u(const uchar *src_data, size_t src_step, uchar *dst_data, #define cv_hal_not8u hal_ni_not8u //! @endcond +/** +Lookup table replacement +Table consists of 256 elements of a size from 1 to 8 bytes having 1 channel or src_channels +For 8s input type 128 is added to LUT index +Destination should have the same element type and number of channels as lookup table elements +@param src_data Source image data +@param src_step Source image step +@param src_type Sorce image type +@param lut_data Pointer to lookup table +@param lut_channel_size Size of each channel in bytes +@param lut_channels Number of channels in lookup table +@param dst_data Destination data +@param dst_step Destination step +@param width Width of images +@param height Height of images +@sa LUT +*/ +//! @addtogroup core_hal_interface_lut Lookup table +//! @{ +inline int hal_ni_lut(const uchar *src_data, size_t src_step, size_t src_type, const uchar* lut_data, size_t lut_channel_size, size_t lut_channels, uchar *dst_data, size_t dst_step, int width, int height) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +//! @} + +//! @cond IGNORED +#define cv_hal_lut hal_ni_lut +//! @endcond + /** Hamming norm of a vector @param a pointer to vector data diff --git a/modules/core/src/lut.cpp b/modules/core/src/lut.cpp index f5dc205082..cb2b9e7b56 100644 --- a/modules/core/src/lut.cpp +++ b/modules/core/src/lut.cpp @@ -377,6 +377,9 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst ) CV_OVX_RUN(!ovx::skipSmallImages(src.cols, src.rows), openvx_LUT(src, dst, lut)) + CALL_HAL(LUT, cv_hal_lut, src.data, src.step, src.type(), lut.data, + lut.elemSize1(), lutcn, dst.data, dst.step, src.rows, src.cols); + #if !IPP_DISABLE_PERF_LUT CV_IPP_RUN(_src.dims() <= 2, ipp_lut(src, lut, dst)); #endif