diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index b03fe73b04..bc9dcc2803 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -2442,30 +2442,43 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } else { - typedef IppStatus (CV_STDCALL* ippiNormRelFunc)(const void *, int, const void *, int, IppiSize, Ipp64f *); - ippiNormRelFunc ippFunc = + typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); + typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); + ippiNormRelFuncNoHint ippFuncNoHint = normType == NORM_INF ? - (type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_Inf_8u_C1R : - type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_Inf_16u_C1R : - type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_Inf_16s_C1R : - type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_Inf_32f_C1R : + (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R : + type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R : + type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16s_C1R : + type == CV_32FC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_32f_C1R : 0) : normType == NORM_L1 ? - (type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_L1_8u_C1R : - type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_L1_16u_C1R : - type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_L1_16s_C1R : - type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_L1_32f_C1R : + (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_8u_C1R : + type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16u_C1R : + type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16s_C1R : 0) : normType == NORM_L2 || normType == NORM_L2SQR ? - (type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_L2_8u_C1R : - type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_L2_16u_C1R : - type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_L2_16s_C1R : - type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_L2_32f_C1R : + (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_8u_C1R : + type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R : + type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R : 0) : 0; - if( ippFunc ) + ippiNormRelFuncHint ippFuncHint = + normType == NORM_L1 ? + (type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R : + 0) : + normType == NORM_L2 || normType == NORM_L2SQR ? + (type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R : + 0) : 0; + if (ippFuncNoHint) { Ipp64f norm; - if( ippFunc(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm) >= 0 ) + if( ippFuncNoHint(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm) >= 0 ) + return (double)norm; + setIppErrorStatus(); + } + if (ippFuncHint) + { + Ipp64f norm; + if( ippFuncHint(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 ) return (double)norm; setIppErrorStatus(); }