1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #28664 from pratham-mcw:armpl_dft_opt

Add ARMPL support for DFT Function #28664

- This PR introduces hal/armpl/ with implementation of 1D, 2D DFT and DCT routines using ARM Performance Libraries as a custom HAL replacement for OpenCV's DFT & DCT Function.
- ArmPL MSI package is automatically downloaded and extracted via CMake when building on Windows ARM64, with a WITH_ARMPL option that defaults to ON for that platform.
- Forward and inverse real DFT calls in dxt.cpp are routed through ArmPL when available, with scaling applied only when needed.
- Test error thresholds in test_dxt.cpp are relaxed (from 1e-5 to 2e-4 for float ) to account for numerical differences between ArmPL and OpenCV's reference DFT results.

**Performance Benchmarks :**
<img width="993" height="835" alt="image" src="https://github.com/user-attachments/assets/76def647-6d20-4bce-8bc9-7363e723669f" />

- [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
This commit is contained in:
Pratham Kumar
2026-05-14 13:26:21 +05:30
committed by GitHub
parent 357ad24262
commit eadaab5fbb
9 changed files with 3176 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
if(HAVE_ARMPL)
set(ARMPL_HAL_VERSION 0.0.1 CACHE INTERNAL "")
set(ARMPL_HAL_LIBRARIES "armpl_hal" CACHE INTERNAL "")
set(ARMPL_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE INTERNAL "")
set(ARMPL_HAL_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/include/armpl_hal_core.hpp"
CACHE INTERNAL "")
file(GLOB ARMPL_HAL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_library(armpl_hal STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ARMPL_HAL_FILES})
target_include_directories(armpl_hal PRIVATE
${CMAKE_SOURCE_DIR}/modules/core/include
${CMAKE_BINARY_DIR}
${ARMPL_HAL_INCLUDE_DIRS}
${ARMPL_INCLUDE_PATH})
target_link_libraries(armpl_hal PUBLIC ${ARMPL_LIBRARY})
if(WITH_OPENMP AND OpenMP_CXX_FOUND)
target_link_libraries(armpl_hal PUBLIC OpenMP::OpenMP_CXX)
endif()
set_target_properties(armpl_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
if(NOT BUILD_SHARED_LIBS)
ocv_install_target(armpl_hal EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(armpl_hal PROPERTIES FOLDER "3rdparty")
endif()
else()
message(STATUS "ArmPL is not available, disabling related HAL")
endif(HAVE_ARMPL)
+91
View File
@@ -0,0 +1,91 @@
#ifndef OPENCV_ARMPL_HAL_CORE_HPP
#define OPENCV_ARMPL_HAL_CORE_HPP
#ifdef HAVE_ARMPL
#include <stddef.h>
#include <fftw3.h>
#include <opencv2/core/base.hpp>
#include <opencv2/core/utility.hpp>
#ifndef cvhalDFT
struct cvhalDFT;
#endif
int armpl_hal_dftInit2D(cvhalDFT **context, int width, int height,
int depth, int src_channels, int dst_channels,
int flags, int nonzero_rows);
int armpl_hal_dft2D(cvhalDFT *context, const unsigned char *src_data,
size_t src_step, unsigned char *dst_data, size_t dst_step);
int armpl_hal_dftFree2D(cvhalDFT *context);
#undef cv_hal_dftInit2D
#define cv_hal_dftInit2D armpl_hal_dftInit2D
#undef cv_hal_dft2D
#define cv_hal_dft2D armpl_hal_dft2D
#undef cv_hal_dftFree2D
#define cv_hal_dftFree2D armpl_hal_dftFree2D
struct ArmplDFTSpec_C_32fc {
fftwf_plan plan;
int n;
bool isInverse;
};
struct ArmplDFTSpec_C_64fc {
fftw_plan plan;
int n;
bool isInverse;
};
struct ArmplDFTSpec_R_32f {
fftwf_plan plan;
int n;
bool isInverse;
double scale;
};
struct ArmplDFTSpec_R_64f {
fftw_plan plan;
int n;
bool isInverse;
double scale;
};
int armpl_hal_dftInit1D(cvhalDFT **context, int len, int count,
int depth, int flags, bool *needBuffer);
int armpl_hal_dft1D(cvhalDFT *context,
const unsigned char *src, unsigned char *dst);
int armpl_hal_dftFree1D(cvhalDFT *context);
#undef cv_hal_dftInit1D
#define cv_hal_dftInit1D armpl_hal_dftInit1D
#undef cv_hal_dft1D
#define cv_hal_dft1D armpl_hal_dft1D
#undef cv_hal_dftFree1D
#define cv_hal_dftFree1D armpl_hal_dftFree1D
int armpl_hal_dctInit2D(cvhalDFT **context, int width, int height,
int depth, int flags);
int armpl_hal_dct2D(cvhalDFT *context, const unsigned char *src_data,
size_t src_step, unsigned char *dst_data, size_t dst_step);
int armpl_hal_dctFree2D(cvhalDFT *context);
#undef cv_hal_dctInit2D
#define cv_hal_dctInit2D armpl_hal_dctInit2D
#undef cv_hal_dct2D
#define cv_hal_dct2D armpl_hal_dct2D
#undef cv_hal_dctFree2D
#define cv_hal_dctFree2D armpl_hal_dctFree2D
#endif // HAVE_ARMPL
#endif // OPENCV_ARMPL_HAL_CORE_HPP
File diff suppressed because it is too large Load Diff