Merge pull request #30040 from vrabaud:function_ptr

Fix function pointer signature mismatches - #30040

Contrib PR: https://github.com/opencv/opencv_contrib/pull/4224

Calling a function through a function pointer with a mismatched signature is undefined behavior in C/C++ and causes Clang Control Flow Integrity to trap with `SIGILL` (`ud1`) at indirect call sites.

This is a follow-up on https://github.com/opencv/opencv/pull/28939

### 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
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Vincent Rabaud
2026-09-23 10:44:20 +03:00
committed by GitHub
parent 924f87f481
commit 747ffc57be
28 changed files with 744 additions and 683 deletions
+6
View File
@@ -517,6 +517,12 @@ macro(ocv_add_modules_compiler_options)
if(OPENCV_ENABLE_MEMORY_SANITIZER)
add_definitions(-DOPENCV_ENABLE_MEMORY_SANITIZER=1)
endif()
if(CV_GCC OR CV_CLANG OR CV_ICX)
ocv_check_flag_support(CXX "-Wcast-function-type-strict" _varname_cxx "")
if(${_varname_cxx})
add_compile_options(-Wcast-function-type-strict)
endif()
endif()
endmacro()
# adjust -Wl,-rpath-link
+19 -89
View File
@@ -1459,10 +1459,13 @@ struct InRange_SIMD<double>
#endif
template <typename T>
static void inRange_(const T* src1, size_t step1, const T* src2, size_t step2,
const T* src3, size_t step3, uchar* dst, size_t step,
static void inRange_(const void* _src1, size_t step1, const void* _src2, size_t step2,
const void* _src3, size_t step3, uchar* dst, size_t step,
Size size)
{
const T* src1 = (const T*)_src1;
const T* src2 = (const T*)_src2;
const T* src3 = (const T*)_src3;
step1 /= sizeof(src1[0]);
step2 /= sizeof(src2[0]);
step3 /= sizeof(src3[0]);
@@ -1489,79 +1492,6 @@ static void inRange_(const T* src1, size_t step1, const T* src2, size_t step2,
}
}
static void inRange8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2,
const uchar* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange8s(const schar* src1, size_t step1, const schar* src2, size_t step2,
const schar* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange16u(const ushort* src1, size_t step1, const ushort* src2, size_t step2,
const ushort* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange16s(const short* src1, size_t step1, const short* src2, size_t step2,
const short* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange32u(const unsigned* src1, size_t step1, const unsigned* src2, size_t step2,
const unsigned* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange32s(const int* src1, size_t step1, const int* src2, size_t step2,
const int* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange64u(const uint64* src1, size_t step1, const uint64* src2, size_t step2,
const uint64* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange64s(const int64* src1, size_t step1, const int64* src2, size_t step2,
const int64* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange32f(const float* src1, size_t step1, const float* src2, size_t step2,
const float* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange64f(const double* src1, size_t step1, const double* src2, size_t step2,
const double* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange16f(const hfloat* src1, size_t step1, const hfloat* src2, size_t step2,
const hfloat* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRange16bf(const bfloat* src1, size_t step1, const bfloat* src2, size_t step2,
const bfloat* src3, size_t step3, uchar* dst, size_t step, Size size)
{
inRange_(src1, step1, src2, step2, src3, step3, dst, step, size);
}
static void inRangeReduce(const uchar* src, uchar* dst, size_t len, int cn)
{
int k = cn % 4 ? cn % 4 : 4;
@@ -1586,26 +1516,26 @@ static void inRangeReduce(const uchar* src, uchar* dst, size_t len, int cn)
}
}
typedef void (*InRangeFunc)( const uchar* src1, size_t step1, const uchar* src2, size_t step2,
const uchar* src3, size_t step3, uchar* dst, size_t step, Size sz );
typedef void (*InRangeFunc)( const void* src1, size_t step1, const void* src2, size_t step2,
const void* src3, size_t step3, uchar* dst, size_t step, Size sz );
static InRangeFunc getInRangeFunc(int depth)
{
static InRangeFunc inRangeTab[CV_DEPTH_MAX] =
{
(InRangeFunc)GET_OPTIMIZED(inRange8u),
(InRangeFunc)GET_OPTIMIZED(inRange8s),
(InRangeFunc)GET_OPTIMIZED(inRange16u),
(InRangeFunc)GET_OPTIMIZED(inRange16s),
(InRangeFunc)GET_OPTIMIZED(inRange32s),
(InRangeFunc)GET_OPTIMIZED(inRange32f),
(InRangeFunc)GET_OPTIMIZED(inRange64f),
(InRangeFunc)inRange16f,
(InRangeFunc)inRange16bf,
inRange_<uchar>,
inRange_<schar>,
inRange_<ushort>,
inRange_<short>,
inRange_<int>,
inRange_<float>,
inRange_<double>,
inRange_<hfloat>,
inRange_<bfloat>,
0,
(InRangeFunc)GET_OPTIMIZED(inRange64u),
(InRangeFunc)GET_OPTIMIZED(inRange64s),
(InRangeFunc)GET_OPTIMIZED(inRange32u),
inRange_<uint64_t>,
inRange_<int64_t>,
inRange_<unsigned>,
0,
};
+47 -74
View File
@@ -11,9 +11,12 @@ namespace cv
{
template<typename _Tp, typename _Rt>
void batchDistL1_(const _Tp* src1, const _Tp* src2, size_t step2,
int nvecs, int len, _Rt* dist, const uchar* mask)
static void batchDistL1_(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const _Tp* src1 = (const _Tp*)_src1;
const _Tp* src2 = (const _Tp*)_src2;
_Rt* dist = (_Rt*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -29,9 +32,12 @@ void batchDistL1_(const _Tp* src1, const _Tp* src2, size_t step2,
}
template<typename _Tp, typename _Rt>
void batchDistL2Sqr_(const _Tp* src1, const _Tp* src2, size_t step2,
int nvecs, int len, _Rt* dist, const uchar* mask)
static void batchDistL2Sqr_(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const _Tp* src1 = (const _Tp*)_src1;
const _Tp* src2 = (const _Tp*)_src2;
_Rt* dist = (_Rt*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -47,9 +53,12 @@ void batchDistL2Sqr_(const _Tp* src1, const _Tp* src2, size_t step2,
}
template<>
void batchDistL2Sqr_(const float* src1, const float* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
void batchDistL2Sqr_<float, float>(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const float* src1 = (const float*)_src1;
const float* src2 = (const float*)_src2;
float* dist = (float*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -65,9 +74,12 @@ void batchDistL2Sqr_(const float* src1, const float* src2, size_t step2,
}
template<typename _Tp, typename _Rt>
void batchDistL2_(const _Tp* src1, const _Tp* src2, size_t step2,
int nvecs, int len, _Rt* dist, const uchar* mask)
static void batchDistL2_(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const _Tp* src1 = (const _Tp*)_src1;
const _Tp* src2 = (const _Tp*)_src2;
_Rt* dist = (_Rt*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -83,9 +95,12 @@ void batchDistL2_(const _Tp* src1, const _Tp* src2, size_t step2,
}
template<>
void batchDistL2_(const float* src1, const float* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
void batchDistL2_<float, float>(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const float* src1 = (const float*)_src1;
const float* src2 = (const float*)_src2;
float* dist = (float*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -100,9 +115,12 @@ void batchDistL2_(const float* src1, const float* src2, size_t step2,
}
}
static void batchDistHamming(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, int* dist, const uchar* mask)
static void batchDistHamming(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const uchar* src1 = (const uchar*)_src1;
const uchar* src2 = (const uchar*)_src2;
int* dist = (int*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -122,9 +140,12 @@ static void batchDistHamming(const uchar* src1, const uchar* src2, size_t step2,
}
}
static void batchDistHamming2(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, int* dist, const uchar* mask)
static void batchDistHamming2(const void* _src1, const void* _src2, size_t step2,
int nvecs, int len, void* _dist, const uchar* mask)
{
const uchar* src1 = (const uchar*)_src1;
const uchar* src2 = (const uchar*)_src2;
int* dist = (int*)_dist;
step2 /= sizeof(src2[0]);
if( !mask )
{
@@ -144,56 +165,8 @@ static void batchDistHamming2(const uchar* src1, const uchar* src2, size_t step2
}
}
static void batchDistL1_8u32s(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, int* dist, const uchar* mask)
{
batchDistL1_<uchar, int>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL1_8u32f(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL1_<uchar, float>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL2Sqr_8u32s(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, int* dist, const uchar* mask)
{
batchDistL2Sqr_<uchar, int>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL2Sqr_8u32f(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL2Sqr_<uchar, float>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL2_8u32f(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL2_<uchar, float>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL1_32f(const float* src1, const float* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL1_<float, float>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL2Sqr_32f(const float* src1, const float* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL2Sqr_<float, float>(src1, src2, step2, nvecs, len, dist, mask);
}
static void batchDistL2_32f(const float* src1, const float* src2, size_t step2,
int nvecs, int len, float* dist, const uchar* mask)
{
batchDistL2_<float, float>(src1, src2, step2, nvecs, len, dist, mask);
}
typedef void (*BatchDistFunc)(const uchar* src1, const uchar* src2, size_t step2,
int nvecs, int len, uchar* dist, const uchar* mask);
typedef void (*BatchDistFunc)(const void* src1, const void* src2, size_t step2,
int nvecs, int len, void* dist, const uchar* mask);
struct BatchDistInvoker : public ParallelLoopBody
@@ -352,28 +325,28 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
if( type == CV_8U )
{
if( normType == NORM_L1 && dtype == CV_32S )
func = (BatchDistFunc)batchDistL1_8u32s;
func = batchDistL1_<uchar, int>;
else if( normType == NORM_L1 && dtype == CV_32F )
func = (BatchDistFunc)batchDistL1_8u32f;
func = batchDistL1_<uchar, float>;
else if( normType == NORM_L2SQR && dtype == CV_32S )
func = (BatchDistFunc)batchDistL2Sqr_8u32s;
func = batchDistL2Sqr_<uchar, int>;
else if( normType == NORM_L2SQR && dtype == CV_32F )
func = (BatchDistFunc)batchDistL2Sqr_8u32f;
func = batchDistL2Sqr_<uchar, float>;
else if( normType == NORM_L2 && dtype == CV_32F )
func = (BatchDistFunc)batchDistL2_8u32f;
func = batchDistL2_<uchar, float>;
else if( normType == NORM_HAMMING && dtype == CV_32S )
func = (BatchDistFunc)batchDistHamming;
func = batchDistHamming;
else if( normType == NORM_HAMMING2 && dtype == CV_32S )
func = (BatchDistFunc)batchDistHamming2;
func = batchDistHamming2;
}
else if( type == CV_32F && dtype == CV_32F )
{
if( normType == NORM_L1 )
func = (BatchDistFunc)batchDistL1_32f;
func = batchDistL1_<float, float>;
else if( normType == NORM_L2SQR )
func = (BatchDistFunc)batchDistL2Sqr_32f;
func = batchDistL2Sqr_<float, float>;
else if( normType == NORM_L2 )
func = (BatchDistFunc)batchDistL2_32f;
func = batchDistL2_<float, float>;
}
if( func == 0 )
+84 -77
View File
@@ -1691,35 +1691,10 @@ ExpandCCS( uchar* _ptr, int n, int elem_size )
}
}
static void DFT_32f(const OcvDftOptions & c, const Complexf* src, Complexf* dst)
template<typename T, void (*fn)(const OcvDftOptions&, const T*, T*)>
static void dftWrap(const OcvDftOptions & c, const void* src, void* dst)
{
DFT(c, src, dst);
}
static void DFT_64f(const OcvDftOptions & c, const Complexd* src, Complexd* dst)
{
DFT(c, src, dst);
}
static void RealDFT_32f(const OcvDftOptions & c, const float* src, float* dst)
{
RealDFT(c, src, dst);
}
static void RealDFT_64f(const OcvDftOptions & c, const double* src, double* dst)
{
RealDFT(c, src, dst);
}
static void CCSIDFT_32f(const OcvDftOptions & c, const float* src, float* dst)
{
CCSIDFT(c, src, dst);
}
static void CCSIDFT_64f(const OcvDftOptions & c, const double* src, double* dst)
{
CCSIDFT(c, src, dst);
fn(c, (const T*)src, (T*)dst);
}
}
@@ -1727,6 +1702,12 @@ static void CCSIDFT_64f(const OcvDftOptions & c, const double* src, double* dst)
#ifdef USE_IPP_DFT
typedef IppStatus (CV_STDCALL* IppDFTGetSizeFunc)(int, int, IppHintAlgorithm, int*, int*, int*);
typedef IppStatus (CV_STDCALL* IppDFTInitFunc)(int, int, IppHintAlgorithm, void*, uchar*);
template<typename SpecType, IppStatus (CV_STDCALL *init_fn)(int, int, IppHintAlgorithm, SpecType*, Ipp8u*)>
static IppStatus CV_STDCALL ippDFTInitWrap(int n, int flags, IppHintAlgorithm hint, void* spec, Ipp8u* initbuf)
{
return init_fn(n, flags, hint, (SpecType*)spec, initbuf);
}
#endif
namespace cv
@@ -3278,12 +3259,12 @@ public:
if( depth == CV_32F )
{
getSizeFunc = ippsDFTGetSize_R_32f;
initFunc = (IppDFTInitFunc)ippsDFTInit_R_32f;
initFunc = ippDFTInitWrap<IppsDFTSpec_R_32f, ippsDFTInit_R_32f>;
}
else
{
getSizeFunc = ippsDFTGetSize_R_64f;
initFunc = (IppDFTInitFunc)ippsDFTInit_R_64f;
initFunc = ippDFTInitWrap<IppsDFTSpec_R_64f, ippsDFTInit_R_64f>;
}
}
else
@@ -3291,12 +3272,12 @@ public:
if( depth == CV_32F )
{
getSizeFunc = ippsDFTGetSize_C_32fc;
initFunc = (IppDFTInitFunc)ippsDFTInit_C_32fc;
initFunc = ippDFTInitWrap<IppsDFTSpec_C_32fc, ippsDFTInit_C_32fc>;
}
else
{
getSizeFunc = ippsDFTGetSize_C_64fc;
initFunc = (IppDFTInitFunc)ippsDFTInit_C_64fc;
initFunc = ippDFTInitWrap<IppsDFTSpec_C_64fc, ippsDFTInit_C_64fc>;
}
}
if( getSizeFunc(opt.n, ipp_norm_flag, ippAlgHintNone, &specsize, &initsize, &worksize) >= 0 )
@@ -3351,12 +3332,12 @@ public:
{
static DFTFunc dft_tbl[6] =
{
(DFTFunc)DFT_32f,
(DFTFunc)RealDFT_32f,
(DFTFunc)CCSIDFT_32f,
(DFTFunc)DFT_64f,
(DFTFunc)RealDFT_64f,
(DFTFunc)CCSIDFT_64f
dftWrap<Complexf, DFT<float>>,
dftWrap<float, RealDFT<float>>,
dftWrap<float, CCSIDFT<float>>,
dftWrap<Complexd, DFT<double>>,
dftWrap<double, RealDFT<double>>,
dftWrap<double, CCSIDFT<double>>
};
int idx = 0;
if (stage == 0)
@@ -4145,28 +4126,11 @@ DCTInit( int n, int elem_size, void* _wave, int inv )
typedef void (*DCTFunc)(const OcvDftOptions & c, const void* src, size_t src_step, void* dft_src,
void* dft_dst, void* dst, size_t dst_step, const void* dct_wave);
static void DCT_32f(const OcvDftOptions & c, const float* src, size_t src_step, float* dft_src, float* dft_dst,
float* dst, size_t dst_step, const Complexf* dct_wave)
template<typename T, void (*fn)(const OcvDftOptions&, const T*, size_t, T*, T*, T*, size_t, const Complex<T>*)>
static void dctWrap(const OcvDftOptions & c, const void* src, size_t src_step, void* dft_src, void* dft_dst,
void* dst, size_t dst_step, const void* dct_wave)
{
DCT(c, src, src_step, dft_src, dft_dst, dst, dst_step, dct_wave);
}
static void IDCT_32f(const OcvDftOptions & c, const float* src, size_t src_step, float* dft_src, float* dft_dst,
float* dst, size_t dst_step, const Complexf* dct_wave)
{
IDCT(c, src, src_step, dft_src, dft_dst, dst, dst_step, dct_wave);
}
static void DCT_64f(const OcvDftOptions & c, const double* src, size_t src_step, double* dft_src, double* dft_dst,
double* dst, size_t dst_step, const Complexd* dct_wave)
{
DCT(c, src, src_step, dft_src, dft_dst, dst, dst_step, dct_wave);
}
static void IDCT_64f(const OcvDftOptions & c, const double* src, size_t src_step, double* dft_src, double* dft_dst,
double* dst, size_t dst_step, const Complexd* dct_wave)
{
IDCT(c, src, src_step, dft_src, dft_dst, dst, dst_step, dct_wave);
fn(c, (const T*)src, src_step, (T*)dft_src, (T*)dft_dst, (T*)dst, dst_step, (const Complex<T>*)dct_wave);
}
}
@@ -4179,11 +4143,54 @@ namespace cv
typedef IppStatus (CV_STDCALL * ippiDCTFunc)(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, const void* pDCTSpec, Ipp8u* pBuffer);
typedef IppStatus (CV_STDCALL * ippiDCTInit)(void* pDCTSpec, IppiSize roiSize, Ipp8u* pMemInit );
typedef IppStatus (CV_STDCALL * ippiDCTGetSize)(IppiSize roiSize, int* pSizeSpec, int* pSizeInit, int* pSizeBuf);
template<typename SpecType, IppStatus (CV_STDCALL *fn)(const Ipp32f*, int, Ipp32f*, int, const SpecType*, Ipp8u*)>
static IppStatus CV_STDCALL ippiDCTWrap(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, const void* pDCTSpec, Ipp8u* pBuffer)
{
return fn(pSrc, srcStep, pDst, dstStep, (const SpecType*)pDCTSpec, pBuffer);
}
template<typename SpecType, IppStatus (CV_STDCALL *fn)(SpecType*, IppiSize, Ipp8u*)>
static IppStatus CV_STDCALL ippiDCTInitWrap(void* pDCTSpec, IppiSize roiSize, Ipp8u* pMemInit)
{
return fn((SpecType*)pDCTSpec, roiSize, pMemInit);
}
template<IppStatus (CV_STDCALL *fn)(IppiSize, int*, int*, int*)>
static IppStatus CV_STDCALL ippiDCTGetSizeWrap(IppiSize roiSize, int* pSizeSpec, int* pSizeInit, int* pSizeBuf)
{
return fn(roiSize, pSizeSpec, pSizeInit, pSizeBuf);
}
#elif IPP_VERSION_X100 >= 700
typedef IppStatus (CV_STDCALL * ippiDCTFunc)(const Ipp32f*, int, Ipp32f*, int, const void*, Ipp8u*);
typedef IppStatus (CV_STDCALL * ippiDCTInitAlloc)(void**, IppiSize, IppHintAlgorithm);
typedef IppStatus (CV_STDCALL * ippiDCTFree)(void* pDCTSpec);
typedef IppStatus (CV_STDCALL * ippiDCTGetBufSize)(const void*, int*);
template<typename SpecType, IppStatus (CV_STDCALL *fn)(const Ipp32f*, int, Ipp32f*, int, const SpecType*, Ipp8u*)>
static IppStatus CV_STDCALL ippiDCTWrap(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, const void* pDCTSpec, Ipp8u* pBuffer)
{
return fn(pSrc, srcStep, pDst, dstStep, (const SpecType*)pDCTSpec, pBuffer);
}
template<typename SpecType, IppStatus (CV_STDCALL *fn)(SpecType**, IppiSize, IppHintAlgorithm)>
static IppStatus CV_STDCALL ippiDCTInitAllocWrap(void** pDCTSpec, IppiSize roiSize, IppHintAlgorithm hint)
{
return fn((SpecType**)pDCTSpec, roiSize, hint);
}
template<typename SpecType, IppStatus (CV_STDCALL *fn)(SpecType*)>
static IppStatus CV_STDCALL ippiDCTFreeWrap(void* pDCTSpec)
{
return fn((SpecType*)pDCTSpec);
}
template<typename SpecType, IppStatus (CV_STDCALL *fn)(const SpecType*, int*)>
static IppStatus CV_STDCALL ippiDCTGetBufSizeWrap(const void* pDCTSpec, int* pSize)
{
return fn((const SpecType*)pDCTSpec, pSize);
}
#endif
class DctIPPLoop_Invoker : public ParallelLoopBody
@@ -4220,9 +4227,9 @@ public:
ippFree(pInitBuf); \
return;
ippiDCTFunc ippiDCT_32f_C1R = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
ippiDCTInit ippDctInit = inv ? (ippiDCTInit)ippiDCTInvInit_32f : (ippiDCTInit)ippiDCTFwdInit_32f;
ippiDCTGetSize ippDctGetSize = inv ? (ippiDCTGetSize)ippiDCTInvGetSize_32f : (ippiDCTGetSize)ippiDCTFwdGetSize_32f;
ippiDCTFunc ippiDCT_32f_C1R = inv ? ippiDCTWrap<IppiDCTInvSpec_32f, ippiDCTInv_32f_C1R> : ippiDCTWrap<IppiDCTFwdSpec_32f, ippiDCTFwd_32f_C1R>;
ippiDCTInit ippDctInit = inv ? ippiDCTInitWrap<IppiDCTInvSpec_32f, ippiDCTInvInit_32f> : ippiDCTInitWrap<IppiDCTFwdSpec_32f, ippiDCTFwdInit_32f>;
ippiDCTGetSize ippDctGetSize = inv ? ippiDCTGetSizeWrap<ippiDCTInvGetSize_32f> : ippiDCTGetSizeWrap<ippiDCTFwdGetSize_32f>;
if(ippDctGetSize(srcRoiSize, &specSize, &initSize, &bufferSize) < 0)
{
@@ -4276,10 +4283,10 @@ public:
CV_SUPPRESS_DEPRECATED_START
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
ippiDCTInitAlloc ippInitAlloc = inv ? (ippiDCTInitAlloc)ippiDCTInvInitAlloc_32f : (ippiDCTInitAlloc)ippiDCTFwdInitAlloc_32f;
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
ippiDCTFunc ippDctFun = inv ? ippiDCTWrap<IppiDCTInvSpec_32f, ippiDCTInv_32f_C1R> : ippiDCTWrap<IppiDCTFwdSpec_32f, ippiDCTFwd_32f_C1R>;
ippiDCTInitAlloc ippInitAlloc = inv ? ippiDCTInitAllocWrap<IppiDCTInvSpec_32f, ippiDCTInvInitAlloc_32f> : ippiDCTInitAllocWrap<IppiDCTFwdSpec_32f, ippiDCTFwdInitAlloc_32f>;
ippiDCTFree ippFree = inv ? ippiDCTFreeWrap<IppiDCTInvSpec_32f, ippiDCTInvFree_32f> : ippiDCTFreeWrap<IppiDCTFwdSpec_32f, ippiDCTFwdFree_32f>;
ippiDCTGetBufSize ippGetBufSize = inv ? ippiDCTGetBufSizeWrap<IppiDCTInvSpec_32f, ippiDCTInvGetBufSize_32f> : ippiDCTGetBufSizeWrap<IppiDCTFwdSpec_32f, ippiDCTFwdGetBufSize_32f>;
if (ippInitAlloc(&pDCTSpec, srcRoiSize, ippAlgHintNone)>=0 && ippGetBufSize(pDCTSpec, &bufSize)>=0)
{
@@ -4352,9 +4359,9 @@ static bool ippi_DCT_32f(const uchar * src, size_t src_step, uchar * dst, size_t
if(pInitBuf) \
ippFree(pInitBuf); \
ippiDCTFunc ippiDCT_32f_C1R = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
ippiDCTInit ippDctInit = inv ? (ippiDCTInit)ippiDCTInvInit_32f : (ippiDCTInit)ippiDCTFwdInit_32f;
ippiDCTGetSize ippDctGetSize = inv ? (ippiDCTGetSize)ippiDCTInvGetSize_32f : (ippiDCTGetSize)ippiDCTFwdGetSize_32f;
ippiDCTFunc ippiDCT_32f_C1R = inv ? ippiDCTWrap<IppiDCTInvSpec_32f, ippiDCTInv_32f_C1R> : ippiDCTWrap<IppiDCTFwdSpec_32f, ippiDCTFwd_32f_C1R>;
ippiDCTInit ippDctInit = inv ? ippiDCTInitWrap<IppiDCTInvSpec_32f, ippiDCTInvInit_32f> : ippiDCTInitWrap<IppiDCTFwdSpec_32f, ippiDCTFwdInit_32f>;
ippiDCTGetSize ippDctGetSize = inv ? ippiDCTGetSizeWrap<ippiDCTInvGetSize_32f> : ippiDCTGetSizeWrap<ippiDCTFwdGetSize_32f>;
if(ippDctGetSize(srcRoiSize, &specSize, &initSize, &bufferSize) < 0)
return false;
@@ -4402,10 +4409,10 @@ static bool ippi_DCT_32f(const uchar * src, size_t src_step, uchar * dst, size_t
CV_SUPPRESS_DEPRECATED_START
ippiDCTFunc ippDctFun = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R;
ippiDCTInitAlloc ippInitAlloc = inv ? (ippiDCTInitAlloc)ippiDCTInvInitAlloc_32f : (ippiDCTInitAlloc)ippiDCTFwdInitAlloc_32f;
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
ippiDCTFunc ippDctFun = inv ? ippiDCTWrap<IppiDCTInvSpec_32f, ippiDCTInv_32f_C1R> : ippiDCTWrap<IppiDCTFwdSpec_32f, ippiDCTFwd_32f_C1R>;
ippiDCTInitAlloc ippInitAlloc = inv ? ippiDCTInitAllocWrap<IppiDCTInvSpec_32f, ippiDCTInvInitAlloc_32f> : ippiDCTInitAllocWrap<IppiDCTFwdSpec_32f, ippiDCTFwdInitAlloc_32f>;
ippiDCTFree ippFree = inv ? ippiDCTFreeWrap<IppiDCTInvSpec_32f, ippiDCTInvFree_32f> : ippiDCTFreeWrap<IppiDCTFwdSpec_32f, ippiDCTFwdFree_32f>;
ippiDCTGetBufSize ippGetBufSize = inv ? ippiDCTGetBufSizeWrap<IppiDCTInvSpec_32f, ippiDCTInvGetBufSize_32f> : ippiDCTGetBufSizeWrap<IppiDCTFwdSpec_32f, ippiDCTFwdGetBufSize_32f>;
status = ippStsErr;
@@ -4463,10 +4470,10 @@ public:
isContinuous = (flags & CV_HAL_DFT_IS_CONTINUOUS) != 0;
static DCTFunc dct_tbl[4] =
{
(DCTFunc)DCT_32f,
(DCTFunc)IDCT_32f,
(DCTFunc)DCT_64f,
(DCTFunc)IDCT_64f
dctWrap<float, DCT<float>>,
dctWrap<float, IDCT<float>>,
dctWrap<double, DCT<double>>,
dctWrap<double, IDCT<double>>
};
dct_func = dct_tbl[(int)isInverse + (depth == CV_64F)*2];
opt.nf = 0;
+16 -15
View File
@@ -6,7 +6,7 @@
namespace cv {
typedef bool (*HasNonZeroFunc)(const uchar*, size_t);
typedef bool (*HasNonZeroFunc)(const void*, size_t);
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
@@ -23,8 +23,9 @@ HasNonZeroFunc getHasNonZeroFunc(int depth);
#undef DEFINE_HASNONZERO_FUNC
#define DEFINE_HASNONZERO_FUNC(funcname, suffix, T, VT, cmp_op, scalar_nz_op) \
static bool funcname( const T* src, size_t len ) \
static bool funcname( const void* _src, size_t len ) \
{ \
const T* src = (const T*)_src; \
size_t i = 0; \
SIMD_ONLY( \
const int vlanes = VTraits<VT>::vlanes(); \
@@ -96,19 +97,19 @@ HasNonZeroFunc getHasNonZeroFunc(int depth)
{
static HasNonZeroFunc hasNonZeroTab[CV_DEPTH_MAX] =
{
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero32s),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero32f),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero64f),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16f),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16f),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero64s),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero64s),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero32s),
hasNonZero8u,
hasNonZero8u,
hasNonZero16u,
hasNonZero16u,
hasNonZero32s,
hasNonZero32f,
hasNonZero64f,
hasNonZero16f,
hasNonZero16f,
hasNonZero8u,
hasNonZero64s,
hasNonZero64s,
hasNonZero32s,
0
};
+39 -30
View File
@@ -22,8 +22,11 @@ namespace cv
{
template<typename Ti, typename T> static void
LUT_( const Ti* src, const T* lut, T* dst, const int len, const int cn, const int lutcn )
LUT_( const void* _src, const void* _lut, void* _dst, int len, int cn, int lutcn )
{
const Ti* src = (const Ti*)_src;
const T* lut = (const T*)_lut;
T* dst = (T*)_dst;
if( lutcn == 1 )
{
for( int i = 0; i < len*cn; i++ )
@@ -37,7 +40,13 @@ LUT_( const Ti* src, const T* lut, T* dst, const int len, const int cn, const in
}
}
typedef void (*LUTFunc)( const uchar* src, const uchar* lut, uchar* dst, int len, int cn, int lutcn );
template<typename T, void (*fn)(const uchar*, const T*, T*, int, int, int)>
static void lutDispatchWrap( const void* src, const void* lut, void* dst, int len, int cn, int lutcn )
{
fn((const uchar*)src, (const T*)lut, (T*)dst, len, cn, lutcn);
}
typedef void (*LUTFunc)( const void* src, const void* lut, void* dst, int len, int cn, int lutcn );
static LUTFunc getLUTFunc(const int srcDepth, const int dstDepth)
{
@@ -46,40 +55,40 @@ static LUTFunc getLUTFunc(const int srcDepth, const int dstDepth)
{
switch(dstDepth)
{
case CV_8U: ret = (LUTFunc)LUT8u_dispatch; break;
case CV_8S: ret = (LUTFunc)LUT_<uint8_t, int8_t>; break;
case CV_16U: ret = (LUTFunc)LUT16u_dispatch; break;
case CV_16S: ret = (LUTFunc)LUT_<uint8_t, int16_t>; break;
case CV_32S: ret = (LUTFunc)LUT_<uint8_t, int32_t>; break;
case CV_32F: ret = (LUTFunc)LUT_<uint8_t, int32_t>; break; // float
case CV_64F: ret = (LUTFunc)LUT_<uint8_t, int64_t>; break; // double
case CV_16F: ret = (LUTFunc)LUT_<uint8_t, int16_t>; break; // hfloat
case CV_16BF: ret = (LUTFunc)LUT_<uint8_t, int16_t>; break; // bfloat
case CV_Bool: ret = (LUTFunc)LUT_<uint8_t, uint8_t>; break; // bool
case CV_64U: ret = (LUTFunc)LUT_<uint8_t, uint64_t>; break;
case CV_64S: ret = (LUTFunc)LUT_<uint8_t, int64_t>; break;
case CV_32U: ret = (LUTFunc)LUT_<uint8_t, uint32_t>; break;
default: ret = nullptr; break;
case CV_8U: ret = lutDispatchWrap<uchar, LUT8u_dispatch>; break;
case CV_8S: ret = LUT_<uint8_t, int8_t>; break;
case CV_16U: ret = lutDispatchWrap<ushort, LUT16u_dispatch>; break;
case CV_16S: ret = LUT_<uint8_t, int16_t>; break;
case CV_32S: ret = LUT_<uint8_t, int32_t>; break;
case CV_32F: ret = LUT_<uint8_t, int32_t>; break; // float
case CV_64F: ret = LUT_<uint8_t, int64_t>; break; // double
case CV_16F: ret = LUT_<uint8_t, int16_t>; break; // hfloat
case CV_16BF: ret = LUT_<uint8_t, int16_t>; break; // bfloat
case CV_Bool: ret = LUT_<uint8_t, uint8_t>; break; // bool
case CV_64U: ret = LUT_<uint8_t, uint64_t>; break;
case CV_64S: ret = LUT_<uint8_t, int64_t>; break;
case CV_32U: ret = LUT_<uint8_t, uint32_t>; break;
default: ret = nullptr; break;
}
}
else if((srcDepth == CV_16U) || (srcDepth == CV_16S))
{
switch(dstDepth)
{
case CV_8U: ret = (LUTFunc)LUT_<uint16_t, uint8_t>; break;
case CV_8S: ret = (LUTFunc)LUT_<uint16_t, int8_t>; break;
case CV_16U: ret = (LUTFunc)LUT_<uint16_t, uint16_t>; break;
case CV_16S: ret = (LUTFunc)LUT_<uint16_t, int16_t>; break;
case CV_32S: ret = (LUTFunc)LUT_<uint16_t, int32_t>; break;
case CV_32F: ret = (LUTFunc)LUT_<uint16_t, int32_t>; break; // float
case CV_64F: ret = (LUTFunc)LUT_<uint16_t, int64_t>; break; // double
case CV_16F: ret = (LUTFunc)LUT_<uint16_t, int16_t>; break; // hfloat
case CV_16BF: ret = (LUTFunc)LUT_<uint16_t, int16_t>; break; // bfloat
case CV_Bool: ret = (LUTFunc)LUT_<uint16_t, uint8_t>; break; // bool
case CV_64U: ret = (LUTFunc)LUT_<uint16_t, uint64_t>; break;
case CV_64S: ret = (LUTFunc)LUT_<uint16_t, int64_t>; break;
case CV_32U: ret = (LUTFunc)LUT_<uint16_t, uint32_t>; break;
default: ret = nullptr; break;
case CV_8U: ret = LUT_<uint16_t, uint8_t>; break;
case CV_8S: ret = LUT_<uint16_t, int8_t>; break;
case CV_16U: ret = LUT_<uint16_t, uint16_t>; break;
case CV_16S: ret = LUT_<uint16_t, int16_t>; break;
case CV_32S: ret = LUT_<uint16_t, int32_t>; break;
case CV_32F: ret = LUT_<uint16_t, int32_t>; break; // float
case CV_64F: ret = LUT_<uint16_t, int64_t>; break; // double
case CV_16F: ret = LUT_<uint16_t, int16_t>; break; // hfloat
case CV_16BF: ret = LUT_<uint16_t, int16_t>; break; // bfloat
case CV_Bool: ret = LUT_<uint16_t, uint8_t>; break; // bool
case CV_64U: ret = LUT_<uint16_t, uint64_t>; break;
case CV_64S: ret = LUT_<uint16_t, int64_t>; break;
case CV_32U: ret = LUT_<uint16_t, uint32_t>; break;
default: ret = nullptr; break;
}
}
+9 -41
View File
@@ -812,8 +812,10 @@ struct iPow_SIMD<double, double>
template<typename T, typename WT>
static void
iPow_i( const T* src, T* dst, int len, int power )
iPow_i( const void* _src, void* _dst, int len, int power )
{
const T* src = (const T*)_src;
T* dst = (T*)_dst;
if( power < 0 )
{
T tab[5] =
@@ -852,8 +854,10 @@ iPow_i( const T* src, T* dst, int len, int power )
template<typename T>
static void
iPow_f( const T* src, T* dst, int len, int power0 )
iPow_f( const void* _src, void* _dst, int len, int power0 )
{
const T* src = (const T*)_src;
T* dst = (T*)_dst;
iPow_SIMD<T, T> vop;
int i = vop(src, dst, len, power0);
int power = std::abs(power0);
@@ -878,48 +882,12 @@ iPow_f( const T* src, T* dst, int len, int power0 )
}
}
static void iPow8u(const uchar* src, uchar* dst, int len, int power)
{
iPow_i<uchar, unsigned>(src, dst, len, power);
}
static void iPow8s(const schar* src, schar* dst, int len, int power)
{
iPow_i<schar, int>(src, dst, len, power);
}
static void iPow16u(const ushort* src, ushort* dst, int len, int power)
{
iPow_i<ushort, unsigned>(src, dst, len, power);
}
static void iPow16s(const short* src, short* dst, int len, int power)
{
iPow_i<short, int>(src, dst, len, power);
}
static void iPow32s(const int* src, int* dst, int len, int power)
{
iPow_i<int, int>(src, dst, len, power);
}
static void iPow32f(const float* src, float* dst, int len, int power)
{
iPow_f<float>(src, dst, len, power);
}
static void iPow64f(const double* src, double* dst, int len, int power)
{
iPow_f<double>(src, dst, len, power);
}
typedef void (*IPowFunc)( const uchar* src, uchar* dst, int len, int power );
typedef void (*IPowFunc)( const void* src, void* dst, int len, int power );
static IPowFunc ipowTab[CV_DEPTH_MAX] =
{
(IPowFunc)iPow8u, (IPowFunc)iPow8s, (IPowFunc)iPow16u, (IPowFunc)iPow16s,
(IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0
iPow_i<uchar, unsigned>, iPow_i<schar, int>, iPow_i<ushort, unsigned>, iPow_i<short, int>,
iPow_i<int, int>, iPow_f<float>, iPow_f<double>, 0
};
#ifdef HAVE_OPENCL
+19 -19
View File
@@ -930,59 +930,59 @@ void mulTransposed(InputArray _src, OutputArray _dst, bool ata,
* Dot Product *
\****************************************************************************************/
static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
static double dotProd_8u(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_8u, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_8u, ((const uchar*)src1, (const uchar*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_8s(const schar* src1, const schar* src2, int len)
static double dotProd_8s(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_8s, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_8s, ((const schar*)src1, (const schar*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
static double dotProd_16u(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_16u, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_16u, ((const ushort*)src1, (const ushort*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_16s(const short* src1, const short* src2, int len)
static double dotProd_16s(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_16s, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_16s, ((const short*)src1, (const short*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_32s(const int* src1, const int* src2, int len)
static double dotProd_32s(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_32s, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_32s, ((const int*)src1, (const int*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_32f(const float* src1, const float* src2, int len)
static double dotProd_32f(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_32f, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_32f, ((const float*)src1, (const float*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
static double dotProd_64f(const double* src1, const double* src2, int len)
static double dotProd_64f(const void* src1, const void* src2, int len)
{
CV_INSTRUMENT_REGION();
CV_CPU_DISPATCH(dotProd_64f, (src1, src2, len),
CV_CPU_DISPATCH(dotProd_64f, ((const double*)src1, (const double*)src2, len),
CV_CPU_DISPATCH_MODES_ALL);
}
typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len);
typedef double (*DotProdFunc)(const void* src1, const void* src2, int len);
static DotProdFunc getDotProdFunc(int depth)
{
static DotProdFunc dotProdTab[CV_DEPTH_MAX] =
{
(DotProdFunc)GET_OPTIMIZED(dotProd_8u), (DotProdFunc)GET_OPTIMIZED(dotProd_8s),
(DotProdFunc)dotProd_16u, (DotProdFunc)dotProd_16s,
(DotProdFunc)dotProd_32s, (DotProdFunc)GET_OPTIMIZED(dotProd_32f),
(DotProdFunc)dotProd_64f, 0
dotProd_8u, dotProd_8s,
dotProd_16u, dotProd_16s,
dotProd_32s, dotProd_32f,
dotProd_64f, 0
};
return dotProdTab[depth];
+71 -43
View File
@@ -75,8 +75,8 @@
namespace cv {
// forward declarations
typedef void (*TransformFunc)(const uchar* src, uchar* dst, const uchar* m, int len, int scn, int dcn);
typedef void (*ScaleAddFunc)(const uchar* src1, const uchar* src2, uchar* dst, int len, const void* alpha);
typedef void (*TransformFunc)(const void* src, void* dst, const void* m, int len, int scn, int dcn);
typedef void (*ScaleAddFunc)(const void* src1, const void* src2, void* dst, int len, const void* alpha);
typedef void (*MulTransposedFunc)(const Mat& src, const/*preallocated*/ Mat& dst, const Mat& delta, double scale);
typedef double (*MahalanobisImplFunc)(const Mat& v1, const Mat& v2, const Mat& icovar, double *diff_buffer /*[len]*/, int len /*=v1.total()*/);
@@ -1136,6 +1136,31 @@ typedef void (*GEMMStoreFunc)( const void* src1, size_t step1,
const void* src2, size_t step2, void* dst, size_t dststep,
Size dstsize, double alpha, double beta, int flags );
template<typename T, typename WT, void (*fn)(const T*, size_t, const T*, size_t, const T*, size_t, T*, size_t, Size, Size, double, double, int)>
static void gemmSingleMulWrap( const void* src1, size_t step1,
const void* src2, size_t step2, const void* src3, size_t step3,
void* dst, size_t dststep, Size srcsize, Size dstsize,
double alpha, double beta, int flags )
{
fn((const T*)src1, step1, (const T*)src2, step2, (const T*)src3, step3, (T*)dst, dststep, srcsize, dstsize, alpha, beta, flags);
}
template<typename T, typename WT, void (*fn)(const T*, size_t, const T*, size_t, WT*, size_t, Size, Size, int)>
static void gemmBlockMulWrap( const void* src1, size_t step1,
const void* src2, size_t step2, void* dst, size_t dststep,
Size srcsize, Size dstsize, int flags )
{
fn((const T*)src1, step1, (const T*)src2, step2, (WT*)dst, dststep, srcsize, dstsize, flags);
}
template<typename T, typename WT, void (*fn)(const T*, size_t, const WT*, size_t, T*, size_t, Size, double, double, int)>
static void gemmStoreWrap( const void* src1, size_t step1,
const void* src2, size_t step2, void* dst, size_t dststep,
Size dstsize, double alpha, double beta, int flags )
{
fn((const T*)src1, step1, (const WT*)src2, step2, (T*)dst, dststep, dstsize, alpha, beta, flags);
}
static void GEMMSingleMul_32f( const float* a_data, size_t a_step,
const float* b_data, size_t b_step,
const float* c_data, size_t c_step,
@@ -1560,28 +1585,28 @@ static void gemmImpl( Mat A, Mat B, double alpha,
if( type == CV_32FC1 )
{
singleMulFunc = (GEMMSingleMulFunc)GEMMSingleMul_32f;
blockMulFunc = (GEMMBlockMulFunc)GEMMBlockMul_32f;
storeFunc = (GEMMStoreFunc)GEMMStore_32f;
singleMulFunc = gemmSingleMulWrap<float, double, GEMMSingleMul_32f>;
blockMulFunc = gemmBlockMulWrap<float, double, GEMMBlockMul_32f>;
storeFunc = gemmStoreWrap<float, double, GEMMStore_32f>;
}
else if( type == CV_64FC1 )
{
singleMulFunc = (GEMMSingleMulFunc)GEMMSingleMul_64f;
blockMulFunc = (GEMMBlockMulFunc)GEMMBlockMul_64f;
storeFunc = (GEMMStoreFunc)GEMMStore_64f;
singleMulFunc = gemmSingleMulWrap<double, double, GEMMSingleMul_64f>;
blockMulFunc = gemmBlockMulWrap<double, double, GEMMBlockMul_64f>;
storeFunc = gemmStoreWrap<double, double, GEMMStore_64f>;
}
else if( type == CV_32FC2 )
{
singleMulFunc = (GEMMSingleMulFunc)GEMMSingleMul_32fc;
blockMulFunc = (GEMMBlockMulFunc)GEMMBlockMul_32fc;
storeFunc = (GEMMStoreFunc)GEMMStore_32fc;
singleMulFunc = gemmSingleMulWrap<Complexf, Complexd, GEMMSingleMul_32fc>;
blockMulFunc = gemmBlockMulWrap<Complexf, Complexd, GEMMBlockMul_32fc>;
storeFunc = gemmStoreWrap<Complexf, Complexd, GEMMStore_32fc>;
}
else
{
CV_Assert( type == CV_64FC2 );
singleMulFunc = (GEMMSingleMulFunc)GEMMSingleMul_64fc;
blockMulFunc = (GEMMBlockMulFunc)GEMMBlockMul_64fc;
storeFunc = (GEMMStoreFunc)GEMMStore_64fc;
singleMulFunc = gemmSingleMulWrap<Complexd, Complexd, GEMMSingleMul_64fc>;
blockMulFunc = gemmBlockMulWrap<Complexd, Complexd, GEMMBlockMul_64fc>;
storeFunc = gemmStoreWrap<Complexd, Complexd, GEMMStore_64fc>;
}
if( (d_size.width == 1 || len == 1) && !(flags & GEMM_2_T) && B.isContinuous() )
@@ -2844,13 +2869,19 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int
}
template<typename T, typename WT, void (*fn)(const T*, T*, const WT*, int, int, int)>
static void transformWrap(const void* src, void* dst, const void* m, int len, int scn, int dcn)
{
fn((const T*)src, (T*)dst, (const WT*)m, len, scn, dcn);
}
TransformFunc getTransformFunc(int depth)
{
static TransformFunc transformTab[CV_DEPTH_MAX] =
{
(TransformFunc)transform_8u, (TransformFunc)transform_8s, (TransformFunc)transform_16u,
(TransformFunc)transform_16s, (TransformFunc)transform_32s, (TransformFunc)transform_32f,
(TransformFunc)transform_64f, 0
transformWrap<uchar, float, transform_8u>, transformWrap<schar, float, transform_8s>, transformWrap<ushort, float, transform_16u>,
transformWrap<short, float, transform_16s>, transformWrap<int, double, transform_32s>, transformWrap<float, float, transform_32f>,
transformWrap<double, double, transform_64f>, 0
};
return transformTab[depth];
@@ -2860,9 +2891,9 @@ TransformFunc getDiagTransformFunc(int depth)
{
static TransformFunc diagTransformTab[CV_DEPTH_MAX] =
{
(TransformFunc)diagtransform_8u, (TransformFunc)diagtransform_8s, (TransformFunc)diagtransform_16u,
(TransformFunc)diagtransform_16s, (TransformFunc)diagtransform_32s, (TransformFunc)diagtransform_32f,
(TransformFunc)diagtransform_64f, 0
transformWrap<uchar, float, diagtransform_8u>, transformWrap<schar, float, diagtransform_8s>, transformWrap<ushort, float, diagtransform_16u>,
transformWrap<short, float, diagtransform_16s>, transformWrap<int, double, diagtransform_32s>, transformWrap<float, float, diagtransform_32f>,
transformWrap<double, double, diagtransform_64f>, 0
};
return diagTransformTab[depth];
@@ -2875,8 +2906,11 @@ TransformFunc getDiagTransformFunc(int depth)
\****************************************************************************************/
template<typename T> static void
perspectiveTransform_( const T* src, T* dst, const double* m, int len, int scn, int dcn )
perspectiveTransform_( const void* _src, void* _dst, const void* _m_ptr, int len, int scn, int dcn )
{
const T* src = (const T*)_src;
T* dst = (T*)_dst;
const double* m = (const double*)_m_ptr;
const double eps = FLT_EPSILON;
int i;
@@ -2959,24 +2993,12 @@ perspectiveTransform_( const T* src, T* dst, const double* m, int len, int scn,
}
}
static void
perspectiveTransform_32f(const float* src, float* dst, const double* m, int len, int scn, int dcn)
{
perspectiveTransform_(src, dst, m, len, scn, dcn);
}
static void
perspectiveTransform_64f(const double* src, double* dst, const double* m, int len, int scn, int dcn)
{
perspectiveTransform_(src, dst, m, len, scn, dcn);
}
TransformFunc getPerspectiveTransform(int depth)
{
if (depth == CV_32F)
return (TransformFunc)perspectiveTransform_32f;
return perspectiveTransform_<float>;
if (depth == CV_64F)
return (TransformFunc)perspectiveTransform_64f;
return perspectiveTransform_<double>;
CV_Assert(0 && "Not supported");
}
@@ -2986,10 +3008,13 @@ TransformFunc getPerspectiveTransform(int depth)
* ScaleAdd *
\****************************************************************************************/
static void scaleAdd_32f(const float* src1, const float* src2, float* dst,
int len, float* _alpha)
static void scaleAdd_32f(const void* _src1, const void* _src2, void* _dst,
int len, const void* _alpha)
{
float alpha = *_alpha;
const float* src1 = (const float*)_src1;
const float* src2 = (const float*)_src2;
float* dst = (float*)_dst;
float alpha = *(const float*)_alpha;
int i = 0;
#if (CV_SIMD || CV_SIMD_SCALABLE)
v_float32 v_alpha = vx_setall_f32(alpha);
@@ -3003,10 +3028,13 @@ static void scaleAdd_32f(const float* src1, const float* src2, float* dst,
}
static void scaleAdd_64f(const double* src1, const double* src2, double* dst,
int len, double* _alpha)
static void scaleAdd_64f(const void* _src1, const void* _src2, void* _dst,
int len, const void* _alpha)
{
double alpha = *_alpha;
const double* src1 = (const double*)_src1;
const double* src2 = (const double*)_src2;
double* dst = (double*)_dst;
double alpha = *(const double*)_alpha;
int i = 0;
#if (CV_SIMD_64F || CV_SIMD_SCALABLE_64F)
v_float64 a2 = vx_setall_f64(alpha);
@@ -3022,9 +3050,9 @@ static void scaleAdd_64f(const double* src1, const double* src2, double* dst,
ScaleAddFunc getScaleAddFunc(int depth)
{
if (depth == CV_32F)
return (ScaleAddFunc)scaleAdd_32f;
return scaleAdd_32f;
if (depth == CV_64F)
return (ScaleAddFunc)scaleAdd_64f;
return scaleAdd_64f;
CV_Assert(0 && "Not supported");
}
+34 -22
View File
@@ -1041,23 +1041,29 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
#if defined(HAVE_IPP) && !IPP_DISABLE_SORT
typedef IppStatus (CV_STDCALL *IppSortFunc)(void *pSrcDst, int len, Ipp8u *pBuffer);
template<typename T, IppStatus (CV_STDCALL *fn)(T*, int, Ipp8u*)>
static IppStatus CV_STDCALL ippSortWrap(void* pSrcDst, int len, Ipp8u* pBuffer)
{
return fn((T*)pSrcDst, len, pBuffer);
}
static IppSortFunc getSortFunc(int depth, bool sortDescending)
{
if (!sortDescending)
return depth == CV_8U ? (IppSortFunc)ippsSortRadixAscend_8u_I :
depth == CV_16U ? (IppSortFunc)ippsSortRadixAscend_16u_I :
depth == CV_16S ? (IppSortFunc)ippsSortRadixAscend_16s_I :
depth == CV_32S ? (IppSortFunc)ippsSortRadixAscend_32s_I :
depth == CV_32F ? (IppSortFunc)ippsSortRadixAscend_32f_I :
depth == CV_64F ? (IppSortFunc)ippsSortRadixAscend_64f_I :
return depth == CV_8U ? ippSortWrap<Ipp8u, ippsSortRadixAscend_8u_I> :
depth == CV_16U ? ippSortWrap<Ipp16u, ippsSortRadixAscend_16u_I> :
depth == CV_16S ? ippSortWrap<Ipp16s, ippsSortRadixAscend_16s_I> :
depth == CV_32S ? ippSortWrap<Ipp32s, ippsSortRadixAscend_32s_I> :
depth == CV_32F ? ippSortWrap<Ipp32f, ippsSortRadixAscend_32f_I> :
depth == CV_64F ? ippSortWrap<Ipp64f, ippsSortRadixAscend_64f_I> :
0;
else
return depth == CV_8U ? (IppSortFunc)ippsSortRadixDescend_8u_I :
depth == CV_16U ? (IppSortFunc)ippsSortRadixDescend_16u_I :
depth == CV_16S ? (IppSortFunc)ippsSortRadixDescend_16s_I :
depth == CV_32S ? (IppSortFunc)ippsSortRadixDescend_32s_I :
depth == CV_32F ? (IppSortFunc)ippsSortRadixDescend_32f_I :
depth == CV_64F ? (IppSortFunc)ippsSortRadixDescend_64f_I :
return depth == CV_8U ? ippSortWrap<Ipp8u, ippsSortRadixDescend_8u_I> :
depth == CV_16U ? ippSortWrap<Ipp16u, ippsSortRadixDescend_16u_I> :
depth == CV_16S ? ippSortWrap<Ipp16s, ippsSortRadixDescend_16s_I> :
depth == CV_32S ? ippSortWrap<Ipp32s, ippsSortRadixDescend_32s_I> :
depth == CV_32F ? ippSortWrap<Ipp32f, ippsSortRadixDescend_32f_I> :
depth == CV_64F ? ippSortWrap<Ipp64f, ippsSortRadixDescend_64f_I> :
0;
}
@@ -1199,21 +1205,27 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
#if defined(HAVE_IPP) && !IPP_DISABLE_SORT
typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer);
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, Ipp32s, Ipp32s*, int, Ipp8u*)>
static IppStatus CV_STDCALL ippSortIndexWrap(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer)
{
return fn((const T*)pSrc, srcStrideBytes, pDstIndx, len, pBuffer);
}
static IppSortIndexFunc getSortIndexFunc(int depth, bool sortDescending)
{
if (!sortDescending)
return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_8u :
depth == CV_16U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_16u :
depth == CV_16S ? (IppSortIndexFunc)ippsSortRadixIndexAscend_16s :
depth == CV_32S ? (IppSortIndexFunc)ippsSortRadixIndexAscend_32s :
depth == CV_32F ? (IppSortIndexFunc)ippsSortRadixIndexAscend_32f :
return depth == CV_8U ? ippSortIndexWrap<Ipp8u, ippsSortRadixIndexAscend_8u> :
depth == CV_16U ? ippSortIndexWrap<Ipp16u, ippsSortRadixIndexAscend_16u> :
depth == CV_16S ? ippSortIndexWrap<Ipp16s, ippsSortRadixIndexAscend_16s> :
depth == CV_32S ? ippSortIndexWrap<Ipp32s, ippsSortRadixIndexAscend_32s> :
depth == CV_32F ? ippSortIndexWrap<Ipp32f, ippsSortRadixIndexAscend_32f> :
0;
else
return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexDescend_8u :
depth == CV_16U ? (IppSortIndexFunc)ippsSortRadixIndexDescend_16u :
depth == CV_16S ? (IppSortIndexFunc)ippsSortRadixIndexDescend_16s :
depth == CV_32S ? (IppSortIndexFunc)ippsSortRadixIndexDescend_32s :
depth == CV_32F ? (IppSortIndexFunc)ippsSortRadixIndexDescend_32f :
return depth == CV_8U ? ippSortIndexWrap<Ipp8u, ippsSortRadixIndexDescend_8u> :
depth == CV_16U ? ippSortIndexWrap<Ipp16u, ippsSortRadixIndexDescend_16u> :
depth == CV_16S ? ippSortIndexWrap<Ipp16s, ippsSortRadixIndexDescend_16s> :
depth == CV_32S ? ippSortIndexWrap<Ipp32s, ippsSortRadixIndexDescend_32s> :
depth == CV_32F ? ippSortIndexWrap<Ipp32f, ippsSortRadixIndexDescend_32f> :
0;
}
+13 -4
View File
@@ -12,6 +12,12 @@ typedef int (*SumSqrFunc)(const uchar*, const uchar* mask, uchar*, uchar*, int,
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
template<typename T, typename ST, typename SQT, int (*fn)(const T*, const uchar*, ST*, SQT*, int, int)>
static int sumSqrWrap(const uchar* src, const uchar* mask, uchar* sum, uchar* sqsum, int len, int cn)
{
return fn((const T*)src, mask, (ST*)sum, (SQT*)sqsum, len, cn);
}
SumSqrFunc getSumSqrFunc(int depth);
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
@@ -621,10 +627,13 @@ SumSqrFunc getSumSqrFunc(int depth)
CV_INSTRUMENT_REGION();
static SumSqrFunc sumSqrTab[CV_DEPTH_MAX] =
{
(SumSqrFunc)GET_OPTIMIZED(sqsum8u), (SumSqrFunc)sqsum8s, (SumSqrFunc)sqsum16u, (SumSqrFunc)sqsum16s,
(SumSqrFunc)sqsum32s, (SumSqrFunc)GET_OPTIMIZED(sqsum32f), (SumSqrFunc)sqsum64f,
(SumSqrFunc)sqsum16f, (SumSqrFunc)sqsum16bf, 0,
(SumSqrFunc)sqsum64u, (SumSqrFunc)sqsum64s, (SumSqrFunc)sqsum32u, 0
sumSqrWrap<uchar, int, int, sqsum8u>, sumSqrWrap<schar, int, int, sqsum8s>,
sumSqrWrap<ushort, int, double, sqsum16u>, sumSqrWrap<short, int, double, sqsum16s>,
sumSqrWrap<int, double, double, sqsum32s>, sumSqrWrap<float, double, double, sqsum32f>,
sumSqrWrap<double, double, double, sqsum64f>,
sumSqrWrap<hfloat, float, double, sqsum16f>, sumSqrWrap<bfloat, float, double, sqsum16bf>, 0,
sumSqrWrap<uint64, double, double, sqsum64u>, sumSqrWrap<int64, double, double, sqsum64s>,
sumSqrWrap<unsigned, double, double, sqsum32u>, 0
};
return sumSqrTab[depth];
+15 -9
View File
@@ -46,19 +46,25 @@ void merge64s(const int64** src, int64* dst, int len, int cn )
} // namespace cv::hal::
typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn);
typedef void (*MergeFunc)(const void** src, void* dst, int len, int cn);
template<typename T, void (*fn)(const T**, T*, int, int)>
static void mergeWrap(const void** src, void* dst, int len, int cn)
{
fn((const T**)src, (T*)dst, len, cn);
}
static MergeFunc getMergeFunc(int depth)
{
static MergeFunc mergeTab[CV_DEPTH_MAX] =
{
(MergeFunc)GET_OPTIMIZED(cv::hal::merge8u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge8u),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge32s), (MergeFunc)GET_OPTIMIZED(cv::hal::merge32s),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge64s), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge8u),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge64s), (MergeFunc)GET_OPTIMIZED(cv::hal::merge64s),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge32s), 0, 0, 0,
mergeWrap<uchar, cv::hal::merge8u>, mergeWrap<uchar, cv::hal::merge8u>,
mergeWrap<ushort, cv::hal::merge16u>, mergeWrap<ushort, cv::hal::merge16u>,
mergeWrap<int, cv::hal::merge32s>, mergeWrap<int, cv::hal::merge32s>,
mergeWrap<int64_t, cv::hal::merge64s>, mergeWrap<ushort, cv::hal::merge16u>,
mergeWrap<ushort, cv::hal::merge16u>, mergeWrap<uchar, cv::hal::merge8u>,
mergeWrap<int64_t, cv::hal::merge64s>, mergeWrap<int64_t, cv::hal::merge64s>,
mergeWrap<int, cv::hal::merge32s>, 0, 0, 0,
};
return mergeTab[depth];
@@ -187,7 +193,7 @@ void merge(const Mat* mv, size_t n, OutputArray _dst)
for( size_t j = 0; j < total; j += blocksize )
{
size_t bsz = std::min(total - j, blocksize);
func( (const uchar**)&ptrs[1], ptrs[0], (int)bsz, cn );
func( (const void**)&ptrs[1], ptrs[0], (int)bsz, cn );
if( j + blocksize < total )
{
+1 -1
View File
@@ -54,7 +54,7 @@ void getMinMaxRes(const Mat & db, double * minVal, double * maxVal,
{
uint index_max = std::numeric_limits<uint>::max();
T minval = std::numeric_limits<T>::max();
T maxval = std::numeric_limits<T>::min() > 0 ? -std::numeric_limits<T>::max() : std::numeric_limits<T>::min(), maxval2 = maxval;
T maxval = std::numeric_limits<T>::min() > 0 ? (T)-std::numeric_limits<T>::max() : std::numeric_limits<T>::min(), maxval2 = maxval;
uint minloc = index_max, maxloc = index_max;
size_t index = 0;
+22 -13
View File
@@ -13,6 +13,15 @@ typedef void (*MinMaxIdxFunc)(const uchar* data, const uchar* mask,
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
template<typename T, typename WT, void (*fn)(const T*, const uchar*, WT*, WT*, size_t*, size_t*, int, size_t)>
static void minMaxIdxWrap(const uchar* data, const uchar* mask,
void* minval, void* maxval,
size_t* minidx, size_t* maxidx,
int len, size_t startidx)
{
fn((const T*)data, mask, (WT*)minval, (WT*)maxval, minidx, maxidx, len, startidx);
}
MinMaxIdxFunc getMinMaxIdxFunc(int depth);
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
@@ -369,19 +378,19 @@ MinMaxIdxFunc getMinMaxIdxFunc(int depth)
{
static MinMaxIdxFunc minMaxIdxTab[CV_DEPTH_MAX] =
{
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx8u),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx8s),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx16u),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx16s),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx32s),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx32f),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx64f),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx16f),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx16bf),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx8u),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx64u),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx64s),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx32u),
minMaxIdxWrap<uchar, int, minMaxIdx8u>,
minMaxIdxWrap<schar, int, minMaxIdx8s>,
minMaxIdxWrap<ushort, int, minMaxIdx16u>,
minMaxIdxWrap<short, int, minMaxIdx16s>,
minMaxIdxWrap<int, int, minMaxIdx32s>,
minMaxIdxWrap<float, float, minMaxIdx32f>,
minMaxIdxWrap<double, double, minMaxIdx64f>,
minMaxIdxWrap<hfloat, float, minMaxIdx16f>,
minMaxIdxWrap<bfloat, float, minMaxIdx16bf>,
minMaxIdxWrap<uchar, int, minMaxIdx8u>,
minMaxIdxWrap<uint64, uint64, minMaxIdx64u>,
minMaxIdxWrap<int64, int64, minMaxIdx64s>,
minMaxIdxWrap<unsigned, int64, minMaxIdx32u>,
0
};
+90 -78
View File
@@ -15,6 +15,18 @@ using NormDiffFunc = int (*)(const uchar*, const uchar*, const uchar*, uchar*, i
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
template<typename T, typename RT, int (*fn)(const T*, const uchar*, RT*, int, int)>
static int normWrap(const uchar* src1, const uchar* src2, uchar* res, int len, int cn)
{
return fn((const T*)src1, src2, (RT*)res, len, cn);
}
template<typename T, typename RT, int (*fn)(const T*, const T*, const uchar*, RT*, int, int)>
static int normDiffWrap(const uchar* src1, const uchar* src2, const uchar* src3, uchar* res, int len, int cn)
{
return fn((const T*)src1, (const T*)src2, src3, (RT*)res, len, cn);
}
NormFunc getNormFunc(int normType, int depth);
NormDiffFunc getNormDiffFunc(int normType, int depth);
@@ -2319,51 +2331,51 @@ NormFunc getNormFunc(int normType, int depth)
static NormFunc normTab[3][CV_DEPTH_MAX] =
{
{
(NormFunc)GET_OPTIMIZED(normInf_8u),
(NormFunc)GET_OPTIMIZED(normInf_8s),
(NormFunc)GET_OPTIMIZED(normInf_16u),
(NormFunc)GET_OPTIMIZED(normInf_16s),
(NormFunc)GET_OPTIMIZED(normInf_32s),
(NormFunc)GET_OPTIMIZED(normInf_32f),
(NormFunc)normInf_64f,
(NormFunc)GET_OPTIMIZED(normInf_16f),
(NormFunc)GET_OPTIMIZED(normInf_16bf),
(NormFunc)normInf_Bool,
(NormFunc)GET_OPTIMIZED(normInf_64u),
(NormFunc)GET_OPTIMIZED(normInf_64s),
(NormFunc)GET_OPTIMIZED(normInf_32u),
normWrap<uchar, int, normInf_8u>,
normWrap<schar, int, normInf_8s>,
normWrap<ushort, int, normInf_16u>,
normWrap<short, int, normInf_16s>,
normWrap<int, unsigned, normInf_32s>,
normWrap<float, float, normInf_32f>,
normWrap<double, double, normInf_64f>,
normWrap<hfloat, float, normInf_16f>,
normWrap<bfloat, float, normInf_16bf>,
normWrap<uchar, int, normInf_Bool>,
normWrap<uint64, uint64, normInf_64u>,
normWrap<int64, uint64, normInf_64s>,
normWrap<unsigned, unsigned, normInf_32u>,
0
},
{
(NormFunc)GET_OPTIMIZED(normL1_8u),
(NormFunc)GET_OPTIMIZED(normL1_8s),
(NormFunc)GET_OPTIMIZED(normL1_16u),
(NormFunc)GET_OPTIMIZED(normL1_16s),
(NormFunc)GET_OPTIMIZED(normL1_32s),
(NormFunc)GET_OPTIMIZED(normL1_32f),
(NormFunc)normL1_64f,
(NormFunc)GET_OPTIMIZED(normL1_16f),
(NormFunc)GET_OPTIMIZED(normL1_16bf),
(NormFunc)normL1_Bool,
(NormFunc)GET_OPTIMIZED(normL1_64u),
(NormFunc)GET_OPTIMIZED(normL1_64s),
(NormFunc)GET_OPTIMIZED(normL1_32u),
normWrap<uchar, int, normL1_8u>,
normWrap<schar, int, normL1_8s>,
normWrap<ushort, int, normL1_16u>,
normWrap<short, int, normL1_16s>,
normWrap<int, double, normL1_32s>,
normWrap<float, double, normL1_32f>,
normWrap<double, double, normL1_64f>,
normWrap<hfloat, float, normL1_16f>,
normWrap<bfloat, float, normL1_16bf>,
normWrap<uchar, int, normL1_Bool>,
normWrap<uint64, double, normL1_64u>,
normWrap<int64, double, normL1_64s>,
normWrap<unsigned, double, normL1_32u>,
0
},
{
(NormFunc)GET_OPTIMIZED(normL2_8u),
(NormFunc)GET_OPTIMIZED(normL2_8s),
(NormFunc)GET_OPTIMIZED(normL2_16u),
(NormFunc)GET_OPTIMIZED(normL2_16s),
(NormFunc)GET_OPTIMIZED(normL2_32s),
(NormFunc)GET_OPTIMIZED(normL2_32f),
(NormFunc)normL2_64f,
(NormFunc)GET_OPTIMIZED(normL2_16f),
(NormFunc)GET_OPTIMIZED(normL2_16bf),
(NormFunc)normL2_Bool,
(NormFunc)GET_OPTIMIZED(normL2_64u),
(NormFunc)GET_OPTIMIZED(normL2_64s),
(NormFunc)GET_OPTIMIZED(normL2_32u),
normWrap<uchar, int, normL2_8u>,
normWrap<schar, int, normL2_8s>,
normWrap<ushort, double, normL2_16u>,
normWrap<short, double, normL2_16s>,
normWrap<int, double, normL2_32s>,
normWrap<float, double, normL2_32f>,
normWrap<double, double, normL2_64f>,
normWrap<hfloat, float, normL2_16f>,
normWrap<bfloat, float, normL2_16bf>,
normWrap<uchar, int, normL2_Bool>,
normWrap<uint64, double, normL2_64u>,
normWrap<int64, double, normL2_64s>,
normWrap<unsigned, double, normL2_32u>,
0
}
};
@@ -2378,51 +2390,51 @@ NormDiffFunc getNormDiffFunc(int normType, int depth)
static NormDiffFunc normDiffTab[3][CV_DEPTH_MAX] =
{
{
(NormDiffFunc)GET_OPTIMIZED(normDiffInf_8u),
(NormDiffFunc)normDiffInf_8s,
(NormDiffFunc)normDiffInf_16u,
(NormDiffFunc)normDiffInf_16s,
(NormDiffFunc)normDiffInf_32s,
(NormDiffFunc)GET_OPTIMIZED(normDiffInf_32f),
(NormDiffFunc)normDiffInf_64f,
(NormDiffFunc)normDiffInf_16f,
(NormDiffFunc)normDiffInf_16bf,
(NormDiffFunc)normDiffInf_Bool,
(NormDiffFunc)normDiffInf_64u,
(NormDiffFunc)normDiffInf_64s,
(NormDiffFunc)normDiffInf_32u,
normDiffWrap<uchar, int, normDiffInf_8u>,
normDiffWrap<schar, int, normDiffInf_8s>,
normDiffWrap<ushort, int, normDiffInf_16u>,
normDiffWrap<short, int, normDiffInf_16s>,
normDiffWrap<int, unsigned, normDiffInf_32s>,
normDiffWrap<float, float, normDiffInf_32f>,
normDiffWrap<double, double, normDiffInf_64f>,
normDiffWrap<hfloat, float, normDiffInf_16f>,
normDiffWrap<bfloat, float, normDiffInf_16bf>,
normDiffWrap<uchar, int, normDiffInf_Bool>,
normDiffWrap<uint64, uint64, normDiffInf_64u>,
normDiffWrap<int64, uint64, normDiffInf_64s>,
normDiffWrap<unsigned, unsigned, normDiffInf_32u>,
0
},
{
(NormDiffFunc)GET_OPTIMIZED(normDiffL1_8u),
(NormDiffFunc)normDiffL1_8s,
(NormDiffFunc)normDiffL1_16u,
(NormDiffFunc)normDiffL1_16s,
(NormDiffFunc)normDiffL1_32s,
(NormDiffFunc)GET_OPTIMIZED(normDiffL1_32f),
(NormDiffFunc)normDiffL1_64f,
(NormDiffFunc)normDiffL1_16f,
(NormDiffFunc)normDiffL1_16bf,
(NormDiffFunc)normDiffL1_Bool,
(NormDiffFunc)normDiffL1_64u,
(NormDiffFunc)normDiffL1_64s,
(NormDiffFunc)normDiffL1_32u,
normDiffWrap<uchar, int, normDiffL1_8u>,
normDiffWrap<schar, int, normDiffL1_8s>,
normDiffWrap<ushort, int, normDiffL1_16u>,
normDiffWrap<short, int, normDiffL1_16s>,
normDiffWrap<int, double, normDiffL1_32s>,
normDiffWrap<float, double, normDiffL1_32f>,
normDiffWrap<double, double, normDiffL1_64f>,
normDiffWrap<hfloat, float, normDiffL1_16f>,
normDiffWrap<bfloat, float, normDiffL1_16bf>,
normDiffWrap<uchar, int, normDiffL1_Bool>,
normDiffWrap<uint64, double, normDiffL1_64u>,
normDiffWrap<int64, double, normDiffL1_64s>,
normDiffWrap<unsigned, double, normDiffL1_32u>,
0
},
{
(NormDiffFunc)GET_OPTIMIZED(normDiffL2_8u),
(NormDiffFunc)normDiffL2_8s,
(NormDiffFunc)normDiffL2_16u,
(NormDiffFunc)normDiffL2_16s,
(NormDiffFunc)normDiffL2_32s,
(NormDiffFunc)GET_OPTIMIZED(normDiffL2_32f),
(NormDiffFunc)normDiffL2_64f,
(NormDiffFunc)normDiffL2_16f,
(NormDiffFunc)normDiffL2_16bf,
(NormDiffFunc)normDiffL2_Bool,
(NormDiffFunc)normDiffL2_64u,
(NormDiffFunc)normDiffL2_64s,
(NormDiffFunc)normDiffL2_32u,
normDiffWrap<uchar, int, normDiffL2_8u>,
normDiffWrap<schar, int, normDiffL2_8s>,
normDiffWrap<ushort, double, normDiffL2_16u>,
normDiffWrap<short, double, normDiffL2_16s>,
normDiffWrap<int, double, normDiffL2_32s>,
normDiffWrap<float, double, normDiffL2_32f>,
normDiffWrap<double, double, normDiffL2_64f>,
normDiffWrap<hfloat, float, normDiffL2_16f>,
normDiffWrap<bfloat, float, normDiffL2_16bf>,
normDiffWrap<uchar, int, normDiffL2_Bool>,
normDiffWrap<uint64, double, normDiffL2_64u>,
normDiffWrap<int64, double, normDiffL2_64s>,
normDiffWrap<unsigned, double, normDiffL2_32u>,
0
},
};
+3 -3
View File
@@ -256,9 +256,9 @@ typedef void (*BinaryFunc)(const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz,
void*);
typedef void (*BinaryFuncC)(const uchar* src1, size_t step1,
const uchar* src2, size_t step2,
uchar* dst, size_t step, int width, int height,
typedef void (*BinaryFuncC)(const void* src1, size_t step1,
const void* src2, size_t step2,
void* dst, size_t step, int width, int height,
void*);
// Exported so the new element-wise expression engine can reuse the already-optimized,
+43 -56
View File
@@ -213,24 +213,17 @@ randi_( uint64_t* arr, int len, int cn, uint64* state, const DivStruct* p )
*state = temp;
}
#define DEF_RANDI_FUNC(suffix, type) \
static void randBits_##suffix(type* arr, int len, int cn, uint64* state, \
const Vec2l* p, void*, int flags) \
{ randBits_(arr, len, cn, state, p, flags); } \
\
static void randi_##suffix(type* arr, int len, int cn, uint64* state, \
const DivStruct* p, void*, int) \
{ randi_(arr, len, cn, state, p); }
template<typename T>
static void randBitsWrap(void* arr, int len, int cn, uint64* state, const void* p, void*, int flags)
{
randBits_((T*)arr, len, cn, state, (const Vec2l*)p, flags);
}
DEF_RANDI_FUNC(8u, uchar)
DEF_RANDI_FUNC(8b, bool)
DEF_RANDI_FUNC(8s, schar)
DEF_RANDI_FUNC(16u, ushort)
DEF_RANDI_FUNC(16s, short)
DEF_RANDI_FUNC(32u, unsigned)
DEF_RANDI_FUNC(32s, int)
DEF_RANDI_FUNC(64u, uint64_t)
DEF_RANDI_FUNC(64s, int64_t)
template<typename T>
static void randiWrap(void* arr, int len, int cn, uint64* state, const void* p, void*, int)
{
randi_((T*)arr, len, cn, state, (const DivStruct*)p);
}
// Narrow an f32 buffer into one of the 1-byte FP8 destinations.
static inline void cvt32fToFP8(const float* src, void* dst, int len, int depth)
@@ -240,8 +233,10 @@ static inline void cvt32fToFP8(const float* src, void* dst, int len, int depth)
}
static inline bool isFP8Depth(int d) { return d >= CV_8F_E4M3FN && d <= CV_8F_E4M3FNUZ; }
static void randf_16_or_32f( void* dst, int len_, int cn, uint64* state, const Vec2f* p, float* fbuf, int flags )
static void randf_16_or_32f( void* dst, int len_, int cn, uint64* state, const void* _p, void* _fbuf, int flags )
{
const Vec2f* p = (const Vec2f*)_p;
float* fbuf = (float*)_fbuf;
int depth = CV_MAT_DEPTH(flags);
uint64 temp = *state;
int k = 0, len = len_*cn;
@@ -264,8 +259,10 @@ static void randf_16_or_32f( void* dst, int len_, int cn, uint64* state, const V
}
static void
randf_64f( double* arr, int len_, int cn, uint64* state, const Vec2d* p, void*, int )
randf_64f( void* _arr, int len_, int cn, uint64* state, const void* _p, void*, int )
{
double* arr = (double*)_arr;
const Vec2d* p = (const Vec2d*)_p;
uint64 temp = *state;
int k = 0, len = len_*cn;
cn--;
@@ -280,24 +277,24 @@ randf_64f( double* arr, int len_, int cn, uint64* state, const Vec2d* p, void*,
hal::addRNGBias64f(arr, &p[0][0], len_, cn+1);
}
typedef void (*RandFunc)(uchar* arr, int len, int cn, uint64* state,
typedef void (*RandFunc)(void* arr, int len, int cn, uint64* state,
const void* p, void* tempbuf, int flags);
static RandFunc randTab[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{
{
(RandFunc)randi_8u, (RandFunc)randi_8s, (RandFunc)randi_16u,
(RandFunc)randi_16s, (RandFunc)randi_32s, (RandFunc)randf_16_or_32f,
(RandFunc)randf_64f, (RandFunc)randf_16_or_32f, (RandFunc)randf_16_or_32f,
(RandFunc)randi_8b, (RandFunc)randi_64u, (RandFunc)randi_64s,
(RandFunc)randi_32u,
(RandFunc)randf_16_or_32f, (RandFunc)randf_16_or_32f // CV_8F_E4M3FN, E4M3FNUZ
randiWrap<uchar>, randiWrap<schar>, randiWrap<ushort>,
randiWrap<short>, randiWrap<int>, randf_16_or_32f,
randf_64f, randf_16_or_32f, randf_16_or_32f,
randiWrap<bool>, randiWrap<uint64_t>, randiWrap<int64_t>,
randiWrap<unsigned>,
randf_16_or_32f, randf_16_or_32f // CV_8F_E4M3FN, E4M3FNUZ
},
{
(RandFunc)randBits_8u, (RandFunc)randBits_8s, (RandFunc)randBits_16u,
(RandFunc)randBits_16s, (RandFunc)randBits_32s, 0, 0, 0, 0,
(RandFunc)randBits_8b, (RandFunc)randBits_64u, (RandFunc)randBits_64s,
(RandFunc)randBits_32u, 0, 0, 0
randBitsWrap<uchar>, randBitsWrap<schar>, randBitsWrap<ushort>,
randBitsWrap<short>, randBitsWrap<int>, 0, 0, 0, 0,
randBitsWrap<bool>, randBitsWrap<uint64_t>, randBitsWrap<int64_t>,
randBitsWrap<unsigned>, 0, 0, 0
}
};
@@ -390,9 +387,12 @@ double RNG::gaussian(double sigma)
}
template<typename T, typename PT> static void
randnScale_(float* src, T* dst, int len, int cn,
const PT* mean, const PT* stddev, int flags )
randnScale_(float* src, void* _dst, int len, int cn,
const void* _mean, const void* _stddev, int flags )
{
T* dst = (T*)_dst;
const PT* mean = (const PT*)_mean;
const PT* stddev = (const PT*)_stddev;
bool stdmtx = (flags & RNG_FLAG_STDMTX) != 0;
int i, j, k;
if( !stdmtx || cn == 1 )
@@ -431,9 +431,12 @@ randnScale_(float* src, T* dst, int len, int cn,
// special version for 16f, 16bf and 32f
static void
randnScale_16_or_32f(float* fbuf, float* dst, int len, int cn,
const float* mean, const float* stddev, int flags)
randnScale_16_or_32f(float* fbuf, void* _dst, int len, int cn,
const void* _mean, const void* _stddev, int flags)
{
float* dst = (float*)_dst;
const float* mean = (const float*)_mean;
const float* stddev = (const float*)_stddev;
bool stdmtx = (flags & RNG_FLAG_STDMTX) != 0;
int depth = CV_MAT_DEPTH(flags);
float* arr = depth == CV_16F || depth == CV_16BF || isFP8Depth(depth) ? fbuf : dst;
@@ -498,33 +501,17 @@ randnScale_16_or_32f(float* fbuf, float* dst, int len, int cn,
cvt32fToFP8(fbuf, dst, len, depth);
}
#define DEF_RANDNSCALE_FUNC(suffix, T, PT) \
static void randnScale_##suffix( float* src, T* dst, int len, int cn, \
const PT* mean, const PT* stddev, int flags ) \
{ randnScale_(src, dst, len, cn, mean, stddev, flags); }
DEF_RANDNSCALE_FUNC(8u, uchar, float)
DEF_RANDNSCALE_FUNC(8b, bool, float)
DEF_RANDNSCALE_FUNC(8s, schar, float)
DEF_RANDNSCALE_FUNC(16u, ushort, float)
DEF_RANDNSCALE_FUNC(16s, short, float)
DEF_RANDNSCALE_FUNC(32u, unsigned, float)
DEF_RANDNSCALE_FUNC(32s, int, float)
DEF_RANDNSCALE_FUNC(64u, uint64_t, double)
DEF_RANDNSCALE_FUNC(64s, int64_t, double)
DEF_RANDNSCALE_FUNC(64f, double, double)
typedef void (*RandnScaleFunc)(float* src, void* dst, int len, int cn,
const void* mean, const void* stddev, int flags);
static RandnScaleFunc randnScaleTab[CV_DEPTH_MAX] =
{
(RandnScaleFunc)randnScale_8u, (RandnScaleFunc)randnScale_8s, (RandnScaleFunc)randnScale_16u,
(RandnScaleFunc)randnScale_16s, (RandnScaleFunc)randnScale_32s, (RandnScaleFunc)randnScale_16_or_32f,
(RandnScaleFunc)randnScale_64f, (RandnScaleFunc)randnScale_16_or_32f, (RandnScaleFunc)randnScale_16_or_32f,
(RandnScaleFunc)randnScale_8b, (RandnScaleFunc)randnScale_64u, (RandnScaleFunc)randnScale_64s,
(RandnScaleFunc)randnScale_32u,
(RandnScaleFunc)randnScale_16_or_32f, (RandnScaleFunc)randnScale_16_or_32f // CV_8F_E4M3FN, E4M3FNUZ
randnScale_<uchar, float>, randnScale_<schar, float>, randnScale_<ushort, float>,
randnScale_<short, float>, randnScale_<int, float>, randnScale_16_or_32f,
randnScale_<double, double>, randnScale_16_or_32f, randnScale_16_or_32f,
randnScale_<bool, float>, randnScale_<uint64_t, double>, randnScale_<int64_t, double>,
randnScale_<unsigned, float>,
randnScale_16_or_32f, randnScale_16_or_32f // CV_8F_E4M3FN, E4M3FNUZ
};
void RNG::fill( InputOutputArray _mat, int disttype,
+15 -9
View File
@@ -49,19 +49,25 @@ void split64s(const int64* src, int64** dst, int len, int cn )
* split & merge *
\****************************************************************************************/
typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn);
typedef void (*SplitFunc)(const void* src, void** dst, int len, int cn);
template<typename T, void (*fn)(const T*, T**, int, int)>
static void splitWrap(const void* src, void** dst, int len, int cn)
{
fn((const T*)src, (T**)dst, len, cn);
}
static SplitFunc getSplitFunc(int depth)
{
static SplitFunc splitTab[CV_DEPTH_MAX] =
{
(SplitFunc)GET_OPTIMIZED(cv::hal::split8u), (SplitFunc)GET_OPTIMIZED(cv::hal::split8u),
(SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u),
(SplitFunc)GET_OPTIMIZED(cv::hal::split32s), (SplitFunc)GET_OPTIMIZED(cv::hal::split32s),
(SplitFunc)GET_OPTIMIZED(cv::hal::split64s), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u),
(SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split8u),
(SplitFunc)GET_OPTIMIZED(cv::hal::split64s), (SplitFunc)GET_OPTIMIZED(cv::hal::split64s),
(SplitFunc)GET_OPTIMIZED(cv::hal::split32s), 0, 0, 0
splitWrap<uchar, cv::hal::split8u>, splitWrap<uchar, cv::hal::split8u>,
splitWrap<ushort, cv::hal::split16u>, splitWrap<ushort, cv::hal::split16u>,
splitWrap<int, cv::hal::split32s>, splitWrap<int, cv::hal::split32s>,
splitWrap<int64_t, cv::hal::split64s>, splitWrap<ushort, cv::hal::split16u>,
splitWrap<ushort, cv::hal::split16u>, splitWrap<uchar, cv::hal::split8u>,
splitWrap<int64_t, cv::hal::split64s>, splitWrap<int64_t, cv::hal::split64s>,
splitWrap<int, cv::hal::split32s>, 0, 0, 0
};
return splitTab[depth];
@@ -161,7 +167,7 @@ void split(const Mat& src, Mat* mv)
for( size_t j = 0; j < total; j += blocksize )
{
size_t bsz = std::min(total - j, blocksize);
func( ptrs[0], &ptrs[1], (int)bsz, cn );
func( ptrs[0], (void**)&ptrs[1], (int)bsz, cn );
if( j + blocksize < total )
{
+18 -12
View File
@@ -9,6 +9,12 @@
namespace cv {
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
template<typename T, typename ST, int (*fn)(const T*, const uchar*, ST*, int, int)>
static int sumWrap(const uchar* src, const uchar* mask, uchar* sum, int len, int cn)
{
return fn((const T*)src, mask, (ST*)sum, len, cn);
}
SumFunc getSumFunc(int depth);
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
@@ -384,19 +390,19 @@ SumFunc getSumFunc(int depth)
{
static SumFunc sumTab[CV_DEPTH_MAX] =
{
(SumFunc)GET_OPTIMIZED(sum8u),
(SumFunc)sum8s,
(SumFunc)sum16u,
(SumFunc)sum16s,
(SumFunc)sum32s,
(SumFunc)GET_OPTIMIZED(sum32f),
(SumFunc)sum64f,
(SumFunc)sum16f,
(SumFunc)sum16bf,
sumWrap<uchar, int, sum8u>,
sumWrap<schar, int, sum8s>,
sumWrap<ushort, int, sum16u>,
sumWrap<short, int, sum16s>,
sumWrap<int, double, sum32s>,
sumWrap<float, double, sum32f>,
sumWrap<double, double, sum64f>,
sumWrap<hfloat, float, sum16f>,
sumWrap<bfloat, float, sum16bf>,
0,
(SumFunc)sum64u,
(SumFunc)sum64s,
(SumFunc)sum32u,
sumWrap<uint64, double, sum64u>,
sumWrap<int64, double, sum64s>,
sumWrap<unsigned, double, sum32u>,
0
};
+9 -3
View File
@@ -486,6 +486,12 @@ static bool ocl_moments( InputArray _src, Moments& m, bool binary)
#ifdef HAVE_IPP
typedef IppStatus (CV_STDCALL * ippiMoments)(const void* pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx);
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, IppiSize, IppiMomentState_64f*)>
static IppStatus CV_STDCALL ippiMomentsWrap(const void* pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx)
{
return fn((const T*)pSrc, srcStep, roiSize, pCtx);
}
static bool ipp_moments(Mat &src, Moments &m )
{
#if IPP_VERSION_X100 >= 900
@@ -506,9 +512,9 @@ static bool ipp_moments(Mat &src, Moments &m )
int stateSize = 0;
ippiMoments ippiMoments64f =
(type == CV_8UC1)?(ippiMoments)ippiMoments64f_8u_C1R:
(type == CV_16UC1)?(ippiMoments)ippiMoments64f_16u_C1R:
(type == CV_32FC1)?(ippiMoments)ippiMoments64f_32f_C1R:
(type == CV_8UC1)?ippiMomentsWrap<Ipp8u, ippiMoments64f_8u_C1R>:
(type == CV_16UC1)?ippiMomentsWrap<Ipp16u, ippiMoments64f_16u_C1R>:
(type == CV_32FC1)?ippiMomentsWrap<Ipp32f, ippiMoments64f_32f_C1R>:
NULL;
if(!ippiMoments64f)
return false;
+8
View File
@@ -42,6 +42,14 @@
#include "precomp.hpp"
#include "backend.hpp"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wcast-function-type-strict"
#endif
#if defined (HAVE_GTK)
#include <gtk/gtk.h>
@@ -446,8 +446,9 @@ bool decodeSYCCData(const opj_image_t& inImg, cv::Mat& outImg, uint8_t shift, bo
return false;
}
OPJ_SIZE_T opjReadFromBuffer(void* dist, OPJ_SIZE_T count, detail::OpjMemoryBuffer* buffer)
OPJ_SIZE_T opjReadFromBuffer(void* dist, OPJ_SIZE_T count, void* userData)
{
detail::OpjMemoryBuffer* buffer = static_cast<detail::OpjMemoryBuffer*>(userData);
const OPJ_SIZE_T bytesToRead = std::min(buffer->availableBytes(), count);
if (bytesToRead > 0)
{
@@ -461,21 +462,23 @@ OPJ_SIZE_T opjReadFromBuffer(void* dist, OPJ_SIZE_T count, detail::OpjMemoryBuff
}
}
OPJ_SIZE_T opjSkipFromBuffer(OPJ_SIZE_T count, detail::OpjMemoryBuffer* buffer) {
const OPJ_SIZE_T bytesToSkip = std::min(buffer->availableBytes(), count);
OPJ_OFF_T opjSkipFromBuffer(OPJ_OFF_T count, void* userData) {
detail::OpjMemoryBuffer* buffer = static_cast<detail::OpjMemoryBuffer*>(userData);
const OPJ_SIZE_T bytesToSkip = std::min(buffer->availableBytes(), static_cast<OPJ_SIZE_T>(count));
if (bytesToSkip > 0)
{
buffer->pos += bytesToSkip;
return bytesToSkip;
return static_cast<OPJ_OFF_T>(bytesToSkip);
}
else
{
return static_cast<OPJ_SIZE_T>(-1);
return static_cast<OPJ_OFF_T>(-1);
}
}
OPJ_BOOL opjSeekFromBuffer(OPJ_OFF_T count, detail::OpjMemoryBuffer* buffer)
OPJ_BOOL opjSeekFromBuffer(OPJ_OFF_T count, void* userData)
{
detail::OpjMemoryBuffer* buffer = static_cast<detail::OpjMemoryBuffer*>(userData);
// Count should stay positive to prevent unsigned overflow
CV_DbgAssert(count > 0);
// To provide proper comparison between OPJ_OFF_T and OPJ_SIZE_T, both should be
@@ -494,9 +497,9 @@ detail::StreamPtr opjCreateBufferInputStream(detail::OpjMemoryBuffer* buf)
opj_stream_set_user_data(stream.get(), static_cast<void*>(buf), nullptr);
opj_stream_set_user_data_length(stream.get(), buf->length);
opj_stream_set_read_function(stream.get(), (opj_stream_read_fn)(opjReadFromBuffer));
opj_stream_set_skip_function(stream.get(), (opj_stream_skip_fn)(opjSkipFromBuffer));
opj_stream_set_seek_function(stream.get(), (opj_stream_seek_fn)(opjSeekFromBuffer));
opj_stream_set_read_function(stream.get(), opjReadFromBuffer);
opj_stream_set_skip_function(stream.get(), opjSkipFromBuffer);
opj_stream_set_seek_function(stream.get(), opjSeekFromBuffer);
}
return stream;
}
+5 -7
View File
@@ -234,9 +234,8 @@ ImageDecoder PngDecoder::newDecoder() const
return makePtr<PngDecoder>();
}
void PngDecoder::readDataFromBuf( void* _png_ptr, unsigned char* dst, size_t size )
void PngDecoder::readDataFromBuf( png_structp png_ptr, png_bytep dst, png_size_t size )
{
png_structp png_ptr = (png_structp)_png_ptr;
PngDecoder* decoder = (PngDecoder*)(png_get_io_ptr(png_ptr));
CV_Assert( decoder );
const Mat& buf = decoder->m_buf;
@@ -270,7 +269,7 @@ bool PngDecoder::readHeader()
uint32_t id = 0;
if( !m_buf.empty() )
png_set_read_fn(m_png_ptr, this, (png_rw_ptr)readDataFromBuf );
png_set_read_fn(m_png_ptr, this, readDataFromBuf );
else
{
m_f = fopen(m_filename.c_str(), "rb");
@@ -977,11 +976,10 @@ ImageEncoder PngEncoder::newEncoder() const
return makePtr<PngEncoder>();
}
void PngEncoder::writeDataToBuf(void* _png_ptr, unsigned char* src, size_t size)
void PngEncoder::writeDataToBuf(png_structp png_ptr, png_bytep src, png_size_t size)
{
if( size == 0 )
return;
png_structp png_ptr = (png_structp)_png_ptr;
PngEncoder* encoder = (PngEncoder*)(png_get_io_ptr(png_ptr));
CV_Assert( encoder && encoder->m_buf );
size_t cursz = encoder->m_buf->size();
@@ -989,7 +987,7 @@ void PngEncoder::writeDataToBuf(void* _png_ptr, unsigned char* src, size_t size)
memcpy( &(*encoder->m_buf)[cursz], src, size );
}
void PngEncoder::flushBuf(void*)
void PngEncoder::flushBuf(png_structp)
{
}
@@ -1020,7 +1018,7 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
if( m_buf )
{
png_set_write_fn(png_ptr, this,
(png_rw_ptr)writeDataToBuf, (png_flush_ptr)flushBuf);
writeDataToBuf, flushBuf);
}
else
{
+3 -3
View File
@@ -131,7 +131,7 @@ public:
ImageDecoder newDecoder() const CV_OVERRIDE;
private:
static void readDataFromBuf(void* png_ptr, uchar* dst, size_t size);
static void readDataFromBuf(png_structp png_ptr, png_bytep dst, png_size_t size);
static void info_fn(png_structp png_ptr, png_infop info_ptr);
static void row_fn(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass);
CV_NODISCARD_STD bool processing_start(void* frame_ptr, const Mat& img);
@@ -188,8 +188,8 @@ public:
ImageEncoder newEncoder() const CV_OVERRIDE;
protected:
static void writeDataToBuf(void* png_ptr, unsigned char* src, size_t size);
static void flushBuf(void* png_ptr);
static void writeDataToBuf(png_structp png_ptr, png_bytep src, png_size_t size);
static void flushBuf(png_structp png_ptr);
/**
* @brief Writes data to an output destination, either a file stream or an in-memory buffer.
*
+99 -43
View File
@@ -51,40 +51,96 @@
namespace cv
{
typedef void(*AccFunc)(const uchar*, uchar*, const uchar*, int, int);
typedef void(*AccProdFunc)(const uchar*, const uchar*, uchar*, const uchar*, int, int);
typedef void(*AccWFunc)(const uchar*, uchar*, const uchar*, int, int, double);
#ifdef HAVE_IPP
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, Ipp32f*, int, IppiSize)>
static IppStatus CV_STDCALL ippiAddWrap(const void* pSrc, int srcStep, Ipp32f* pSrcDst, int srcdstStep, IppiSize roiSize)
{
return fn((const T*)pSrc, srcStep, pSrcDst, srcdstStep, roiSize);
}
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, const Ipp8u*, int, Ipp32f*, int, IppiSize)>
static IppStatus CV_STDCALL ippiAddMaskWrap(const void* pSrc, int srcStep, const Ipp8u* pMask, int maskStep, Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize)
{
return fn((const T*)pSrc, srcStep, pMask, maskStep, pSrcDst, srcDstStep, roiSize);
}
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, const T*, int, Ipp32f*, int, IppiSize)>
static IppStatus CV_STDCALL ippiAddProductWrap(const void* pSrc1, int src1Step, const void* pSrc2, int src2Step, Ipp32f* pSrcDst, int srcdstStep, IppiSize roiSize)
{
return fn((const T*)pSrc1, src1Step, (const T*)pSrc2, src2Step, pSrcDst, srcdstStep, roiSize);
}
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, const T*, int, const Ipp8u*, int, Ipp32f*, int, IppiSize)>
static IppStatus CV_STDCALL ippiAddProductMaskWrap(const void* pSrc1, int src1Step, const void* pSrc2, int src2Step, const Ipp8u* pMask, int maskStep, Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize)
{
return fn((const T*)pSrc1, src1Step, (const T*)pSrc2, src2Step, pMask, maskStep, pSrcDst, srcDstStep, roiSize);
}
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, Ipp32f*, int, IppiSize, Ipp32f)>
static IppStatus CV_STDCALL ippiAddWeightedWrap(const void* pSrc, int srcStep, Ipp32f* pSrcDst, int srcdstStep, IppiSize roiSize, Ipp32f alpha)
{
return fn((const T*)pSrc, srcStep, pSrcDst, srcdstStep, roiSize, alpha);
}
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, const Ipp8u*, int, Ipp32f*, int, IppiSize, Ipp32f)>
static IppStatus CV_STDCALL ippiAddWeightedMaskWrap(const void* pSrc, int srcStep, const Ipp8u* pMask, int maskStep, Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize, Ipp32f alpha)
{
return fn((const T*)pSrc, srcStep, pMask, maskStep, pSrcDst, srcDstStep, roiSize, alpha);
}
#endif
typedef void(*AccFunc)(const void*, void*, const uchar*, int, int);
typedef void(*AccProdFunc)(const void*, const void*, void*, const uchar*, int, int);
typedef void(*AccWFunc)(const void*, void*, const uchar*, int, int, double);
template<typename ST, typename DT, void (*fn)(const ST*, DT*, const uchar*, int, int)>
static void accWrap(const void* src, void* dst, const uchar* mask, int len, int cn)
{
fn((const ST*)src, (DT*)dst, mask, len, cn);
}
template<typename ST, typename DT, void (*fn)(const ST*, const ST*, DT*, const uchar*, int, int)>
static void accProdWrap(const void* src1, const void* src2, void* dst, const uchar* mask, int len, int cn)
{
fn((const ST*)src1, (const ST*)src2, (DT*)dst, mask, len, cn);
}
template<typename ST, typename DT, void (*fn)(const ST*, DT*, const uchar*, int, int, double)>
static void accWWrap(const void* src, void* dst, const uchar* mask, int len, int cn, double alpha)
{
fn((const ST*)src, (DT*)dst, mask, len, cn, alpha);
}
static AccFunc accTab[CV_DEPTH_MAX] =
{
(AccFunc)acc_8u32f, (AccFunc)acc_8u64f,
(AccFunc)acc_16u32f, (AccFunc)acc_16u64f,
(AccFunc)acc_32f, (AccFunc)acc_32f64f,
(AccFunc)acc_64f
accWrap<uchar, float, acc_8u32f>, accWrap<uchar, double, acc_8u64f>,
accWrap<ushort, float, acc_16u32f>, accWrap<ushort, double, acc_16u64f>,
accWrap<float, float, acc_32f>, accWrap<float, double, acc_32f64f>,
accWrap<double, double, acc_64f>
};
static AccFunc accSqrTab[CV_DEPTH_MAX] =
{
(AccFunc)accSqr_8u32f, (AccFunc)accSqr_8u64f,
(AccFunc)accSqr_16u32f, (AccFunc)accSqr_16u64f,
(AccFunc)accSqr_32f, (AccFunc)accSqr_32f64f,
(AccFunc)accSqr_64f
accWrap<uchar, float, accSqr_8u32f>, accWrap<uchar, double, accSqr_8u64f>,
accWrap<ushort, float, accSqr_16u32f>, accWrap<ushort, double, accSqr_16u64f>,
accWrap<float, float, accSqr_32f>, accWrap<float, double, accSqr_32f64f>,
accWrap<double, double, accSqr_64f>
};
static AccProdFunc accProdTab[CV_DEPTH_MAX] =
{
(AccProdFunc)accProd_8u32f, (AccProdFunc)accProd_8u64f,
(AccProdFunc)accProd_16u32f, (AccProdFunc)accProd_16u64f,
(AccProdFunc)accProd_32f, (AccProdFunc)accProd_32f64f,
(AccProdFunc)accProd_64f
accProdWrap<uchar, float, accProd_8u32f>, accProdWrap<uchar, double, accProd_8u64f>,
accProdWrap<ushort, float, accProd_16u32f>, accProdWrap<ushort, double, accProd_16u64f>,
accProdWrap<float, float, accProd_32f>, accProdWrap<float, double, accProd_32f64f>,
accProdWrap<double, double, accProd_64f>
};
static AccWFunc accWTab[CV_DEPTH_MAX] =
{
(AccWFunc)accW_8u32f, (AccWFunc)accW_8u64f,
(AccWFunc)accW_16u32f, (AccWFunc)accW_16u64f,
(AccWFunc)accW_32f, (AccWFunc)accW_32f64f,
(AccWFunc)accW_64f
accWWrap<uchar, float, accW_8u32f>, accWWrap<uchar, double, accW_8u64f>,
accWWrap<ushort, float, accW_16u32f>, accWWrap<ushort, double, accW_16u64f>,
accWWrap<float, float, accW_32f>, accWWrap<float, double, accW_32f64f>,
accWWrap<double, double, accW_64f>
};
inline int getAccTabIdx(int sdepth, int ddepth)
@@ -187,16 +243,16 @@ static bool ipp_accumulate(InputArray _src, InputOutputArray _dst, InputArray _m
if (mask.empty())
{
CV_SUPPRESS_DEPRECATED_START
ippiAdd_I = sdepth == CV_8U && ddepth == CV_32F ? (IppiAdd)ippiAdd_8u32f_C1IR :
sdepth == CV_16U && ddepth == CV_32F ? (IppiAdd)ippiAdd_16u32f_C1IR :
sdepth == CV_32F && ddepth == CV_32F ? (IppiAdd)ippiAdd_32f_C1IR : 0;
ippiAdd_I = sdepth == CV_8U && ddepth == CV_32F ? ippiAddWrap<Ipp8u, ippiAdd_8u32f_C1IR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddWrap<Ipp16u, ippiAdd_16u32f_C1IR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddWrap<Ipp32f, ippiAdd_32f_C1IR> : 0;
CV_SUPPRESS_DEPRECATED_END
}
else if (scn == 1)
{
ippiAdd_IM = sdepth == CV_8U && ddepth == CV_32F ? (IppiAddMask)ippiAdd_8u32f_C1IMR :
sdepth == CV_16U && ddepth == CV_32F ? (IppiAddMask)ippiAdd_16u32f_C1IMR :
sdepth == CV_32F && ddepth == CV_32F ? (IppiAddMask)ippiAdd_32f_C1IMR : 0;
ippiAdd_IM = sdepth == CV_8U && ddepth == CV_32F ? ippiAddMaskWrap<Ipp8u, ippiAdd_8u32f_C1IMR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddMaskWrap<Ipp16u, ippiAdd_16u32f_C1IMR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddMaskWrap<Ipp32f, ippiAdd_32f_C1IMR> : 0;
}
if (ippiAdd_I || ippiAdd_IM)
@@ -284,15 +340,15 @@ static bool ipp_accumulate_square(InputArray _src, InputOutputArray _dst, InputA
if (mask.empty())
{
ippiAddSquare_I = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_8u32f_C1IR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_16u32f_C1IR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_32f_C1IR : 0;
ippiAddSquare_I = sdepth == CV_8U && ddepth == CV_32F ? ippiAddWrap<Ipp8u, ippiAddSquare_8u32f_C1IR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddWrap<Ipp16u, ippiAddSquare_16u32f_C1IR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddWrap<Ipp32f, ippiAddSquare_32f_C1IR> : 0;
}
else if (scn == 1)
{
ippiAddSquare_IM = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_8u32f_C1IMR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_16u32f_C1IMR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_32f_C1IMR : 0;
ippiAddSquare_IM = sdepth == CV_8U && ddepth == CV_32F ? ippiAddMaskWrap<Ipp8u, ippiAddSquare_8u32f_C1IMR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddMaskWrap<Ipp16u, ippiAddSquare_16u32f_C1IMR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddMaskWrap<Ipp32f, ippiAddSquare_32f_C1IMR> : 0;
}
if (ippiAddSquare_I || ippiAddSquare_IM)
@@ -381,15 +437,15 @@ static bool ipp_accumulate_product(InputArray _src1, InputArray _src2,
if (mask.empty())
{
ippiAddProduct_I = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_8u32f_C1IR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_16u32f_C1IR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_32f_C1IR : 0;
ippiAddProduct_I = sdepth == CV_8U && ddepth == CV_32F ? ippiAddProductWrap<Ipp8u, ippiAddProduct_8u32f_C1IR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddProductWrap<Ipp16u, ippiAddProduct_16u32f_C1IR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddProductWrap<Ipp32f, ippiAddProduct_32f_C1IR> : 0;
}
else if (scn == 1)
{
ippiAddProduct_IM = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_8u32f_C1IMR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_16u32f_C1IMR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_32f_C1IMR : 0;
ippiAddProduct_IM = sdepth == CV_8U && ddepth == CV_32F ? ippiAddProductMaskWrap<Ipp8u, ippiAddProduct_8u32f_C1IMR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddProductMaskWrap<Ipp16u, ippiAddProduct_16u32f_C1IMR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddProductMaskWrap<Ipp32f, ippiAddProduct_32f_C1IMR> : 0;
}
if (ippiAddProduct_I || ippiAddProduct_IM)
@@ -485,15 +541,15 @@ static bool ipp_accumulate_weighted( InputArray _src, InputOutputArray _dst,
if (mask.empty())
{
ippiAddWeighted_I = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_8u32f_C1IR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_16u32f_C1IR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_32f_C1IR : 0;
ippiAddWeighted_I = sdepth == CV_8U && ddepth == CV_32F ? ippiAddWeightedWrap<Ipp8u, ippiAddWeighted_8u32f_C1IR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddWeightedWrap<Ipp16u, ippiAddWeighted_16u32f_C1IR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddWeightedWrap<Ipp32f, ippiAddWeighted_32f_C1IR> : 0;
}
else if (scn == 1)
{
ippiAddWeighted_IM = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_8u32f_C1IMR :
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_16u32f_C1IMR :
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_32f_C1IMR : 0;
ippiAddWeighted_IM = sdepth == CV_8U && ddepth == CV_32F ? ippiAddWeightedMaskWrap<Ipp8u, ippiAddWeighted_8u32f_C1IMR> :
sdepth == CV_16U && ddepth == CV_32F ? ippiAddWeightedMaskWrap<Ipp16u, ippiAddWeighted_16u32f_C1IMR> :
sdepth == CV_32F && ddepth == CV_32F ? ippiAddWeightedMaskWrap<Ipp32f, ippiAddWeighted_32f_C1IMR> : 0;
}
if (ippiAddWeighted_I || ippiAddWeighted_IM)
+10 -3
View File
@@ -691,12 +691,19 @@ calcHist_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
typedef IppStatus(CV_STDCALL * IppiHistogram_C1)(const void* pSrc, int srcStep,
IppiSize roiSize, Ipp32u* pHist, const IppiHistogramSpec* pSpec, Ipp8u* pBuffer);
template<typename T, IppStatus (CV_STDCALL *fn)(const T*, int, IppiSize, Ipp32u*, const IppiHistogramSpec*, Ipp8u*)>
static IppStatus CV_STDCALL ippiHistogram_C1_Wrap(const void* pSrc, int srcStep,
IppiSize roiSize, Ipp32u* pHist, const IppiHistogramSpec* pSpec, Ipp8u* pBuffer)
{
return fn((const T*)pSrc, srcStep, roiSize, pHist, pSpec, pBuffer);
}
static IppiHistogram_C1 getIppiHistogramFunction_C1(int type)
{
IppiHistogram_C1 ippFunction =
(type == CV_8UC1) ? (IppiHistogram_C1)ippiHistogram_8u_C1R :
(type == CV_16UC1) ? (IppiHistogram_C1)ippiHistogram_16u_C1R :
(type == CV_32FC1) ? (IppiHistogram_C1)ippiHistogram_32f_C1R :
(type == CV_8UC1) ? ippiHistogram_C1_Wrap<Ipp8u, ippiHistogram_8u_C1R> :
(type == CV_16UC1) ? ippiHistogram_C1_Wrap<Ipp16u, ippiHistogram_16u_C1R> :
(type == CV_32FC1) ? ippiHistogram_C1_Wrap<Ipp32f, ippiHistogram_32f_C1R> :
NULL;
return ippFunction;
+26 -20
View File
@@ -8623,67 +8623,73 @@ bicubic64fC4(const float* srcx, const float* srcy, int len,
}
template<typename T, void (*fn)(const float*, const float*, int, const void*, size_t, Size, T*, const float*, int, T*)>
static void bicubicWarpWrap(const float* x, const float* y, int len, const void* src, size_t srcstep, Size srcsize, void* dst, const float* coeffs, int flags, const void* fillval)
{
fn(x, y, len, src, srcstep, srcsize, (T*)dst, coeffs, flags, (T*)fillval);
}
ImgWarpFunc getBicubicWarpFunc_(int type)
{
if (type == CV_8UC1) {
return (ImgWarpFunc)bicubic8uC1;
return bicubicWarpWrap<uint8_t, bicubic8uC1>;
}
if (type == CV_8UC2) {
return (ImgWarpFunc)bicubic8uC2;
return bicubicWarpWrap<uint8_t, bicubic8uC2>;
}
if (type == CV_8UC3) {
return (ImgWarpFunc)bicubic8uC3;
return bicubicWarpWrap<uint8_t, bicubic8uC3>;
}
if (type == CV_8UC4) {
return (ImgWarpFunc)bicubic8uC4;
return bicubicWarpWrap<uint8_t, bicubic8uC4>;
}
if (type == CV_16UC1) {
return (ImgWarpFunc)bicubic16uC1;
return bicubicWarpWrap<uint16_t, bicubic16uC1>;
}
if (type == CV_16UC2) {
return (ImgWarpFunc)bicubic16uC2;
return bicubicWarpWrap<uint16_t, bicubic16uC2>;
}
if (type == CV_16UC3) {
return (ImgWarpFunc)bicubic16uC3;
return bicubicWarpWrap<uint16_t, bicubic16uC3>;
}
if (type == CV_16UC4) {
return (ImgWarpFunc)bicubic16uC4;
return bicubicWarpWrap<uint16_t, bicubic16uC4>;
}
if (type == CV_16SC1) {
return (ImgWarpFunc)bicubic16sC1;
return bicubicWarpWrap<int16_t, bicubic16sC1>;
}
if (type == CV_16SC2) {
return (ImgWarpFunc)bicubic16sC2;
return bicubicWarpWrap<int16_t, bicubic16sC2>;
}
if (type == CV_16SC3) {
return (ImgWarpFunc)bicubic16sC3;
return bicubicWarpWrap<int16_t, bicubic16sC3>;
}
if (type == CV_16SC4) {
return (ImgWarpFunc)bicubic16sC4;
return bicubicWarpWrap<int16_t, bicubic16sC4>;
}
if (type == CV_32FC1) {
return (ImgWarpFunc)bicubic32fC1;
return bicubicWarpWrap<float, bicubic32fC1>;
}
if (type == CV_32FC2) {
return (ImgWarpFunc)bicubic32fC2;
return bicubicWarpWrap<float, bicubic32fC2>;
}
if (type == CV_32FC3) {
return (ImgWarpFunc)bicubic32fC3;
return bicubicWarpWrap<float, bicubic32fC3>;
}
if (type == CV_32FC4) {
return (ImgWarpFunc)bicubic32fC4;
return bicubicWarpWrap<float, bicubic32fC4>;
}
if (type == CV_64FC1) {
return (ImgWarpFunc)bicubic64fC1;
return bicubicWarpWrap<double, bicubic64fC1>;
}
if (type == CV_64FC2) {
return (ImgWarpFunc)bicubic64fC2;
return bicubicWarpWrap<double, bicubic64fC2>;
}
if (type == CV_64FC3) {
return (ImgWarpFunc)bicubic64fC3;
return bicubicWarpWrap<double, bicubic64fC3>;
}
if (type == CV_64FC4) {
return (ImgWarpFunc)bicubic64fC4;
return bicubicWarpWrap<double, bicubic64fC4>;
}
return (ImgWarpFunc)nullptr;
}
+8
View File
@@ -2,6 +2,14 @@
// https://numpy.org/doc/1.17/reference/c-api.array.html#importing-the-api
#define PY_ARRAY_UNIQUE_SYMBOL opencv_ARRAY_API
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wcast-function-type-strict"
#endif
#include "cv2.hpp"
#include "opencv2/opencv_modules.hpp"