Repository: opencv/opencv
File: hal/ipp/src/norm_ipp.cpp (C++)

Code before:
        IppiSize sz = { width*cn, height };

        typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
        typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *);
        ippiNormFuncHint ippiNormHint =
        norm_type == cv::NORM_L1 ?
        (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
        0) :
        norm_type == cv::NORM_L2 || norm_type == cv::NORM_L2SQR ?
        (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R :
        0) : 0;
        ippiNormFuncNoHint ippiNorm =
        norm_type == cv::NORM_INF ?
        (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R :
        type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R :
        type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R :
        type == CV_32FC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R :
        0) :
        norm_type == cv::NORM_L1 ?
        (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R :
        type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R :
        type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R :
        0) :
        norm_type == cv::NORM_L2 || norm_type == cv::NORM_L2SQR ?
        (
            #ifndef IPP_DISABLE_NORM_8U
            type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R :
            #endif
            type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R :
            type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R :
            0) : 0;
            if( ippiNormHint || ippiNorm )
            {
                Ipp64f norm;
                IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src, (int)src_step, sz, &norm, ippAlgHintAccurate) :
                CV_INSTRUMENT_FUN_IPP(ippiNorm, src, (int)src_step, sz, &norm);
                if( ret >= 0 )
                {
                    *result = (norm_type == cv::NORM_L2SQR) ? norm * norm : norm;
                    return CV_HAL_ERROR_OK;
                }
            }
    }

    return CV_HAL_ERROR_NOT_IMPLEMENTED;
}

int ipp_hal_normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2_step, const uchar* mask,
                     size_t mask_step, int width, int height, int type, int norm_type, double* result)
{
    if( norm_type & cv::NORM_RELATIVE )

Review comment (suggestion):
We prefer `#if` instead of `#ifdef` approach due to available compiler warnings.
When used macro is removed or renamed we will get warning for all related code for updating.

Code after:
        IppiSize sz = { width*cn, height };

        typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
        typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *);
        ippiNormFuncHint ippiNormHint =
        norm_type == cv::NORM_L1 ?
        (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
        0) :
        norm_type == cv::NORM_L2 || norm_type == cv::NORM_L2SQR ?
        (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R :
        0) : 0;
        ippiNormFuncNoHint ippiNorm =
        norm_type == cv::NORM_INF ?
        (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R :
        type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R :
        type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R :
        type == CV_32FC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R :
        0) :
        norm_type == cv::NORM_L1 ?
        (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R :
        type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R :
        type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R :
        0) :
        norm_type == cv::NORM_L2 || norm_type == cv::NORM_L2SQR ?
        (
            #if (!IPP_DISABLE_NORM_8U)
            type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R :
            #endif
            type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R :
            type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R :
            0) : 0;
            if( ippiNormHint || ippiNorm )
            {
                Ipp64f norm;
                IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src, (int)src_step, sz, &norm, ippAlgHintAccurate) :
                CV_INSTRUMENT_FUN_IPP(ippiNorm, src, (int)src_step, sz, &norm);
                if( ret >= 0 )
                {
                    *result = (norm_type == cv::NORM_L2SQR) ? norm * norm : norm;
                    return CV_HAL_ERROR_OK;
                }
            }
    }

    return CV_HAL_ERROR_NOT_IMPLEMENTED;
}

int ipp_hal_normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2_step, const uchar* mask,
                     size_t mask_step, int width, int height, int type, int norm_type, double* result)
{
    if( norm_type & cv::NORM_RELATIVE )