1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00
Files
opencv/hal/armpl/include/armpl_hal_core.hpp
T
Pratham Kumar eadaab5fbb 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
2026-05-14 10:56:21 +03:00

92 lines
2.3 KiB
C++

#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