#pragma once #include #include #include /* helper tables */ extern const unsigned char icvSaturate8u_cv[]; #define CV_FAST_CAST_8U(t) ( (-256 <= (t) && (t) <= 512) ? icvSaturate8u_cv[(t)+256] : 0 ) #define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b)) #define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a)) // Any 1 to 1. // memset for vin is meant to clear the source buffer so that // SIMD that reads full multiple of 16 bytes will not trigger msan errors. // memset is not needed for production, as the garbage values are processed but // not used, although there may be edge cases for subsampling. // The size of the buffer is based on the largest read, which can be inferred // by the source type (e.g. ARGB) and the mask (last parameter), or by examining // the source code for how much the source pointers are advanced. //数据4对齐 #define ALIGN_4(x) (((x) + 3) & ~3) //数据2对齐 #define ALIGN_2(x) (((x) + 1) & ~1) // Subsampled source needs to be increase by 1 of not even. #define SS(width, shift) (((width) + (1 << (shift)) - 1) >> (shift)) #define SIMD_ALIGNED(var) __declspec(align(16)) var //#define ANY11(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) void FastCopy_Any(const unsigned char* src_ptr, unsigned char* dst_ptr, int width); void FastCopy(unsigned char* pSrc, unsigned char* pDst, int nWidth); void distanceATS_L1_8u(unsigned char* const src,int nWidth,int nHeight,int nPitch, unsigned char* dst); void OptimizeCalMatAdd_8U(unsigned char* pRelated, int nRelatedWidth, int nRelatedHeight, int nRelatedPitch, unsigned char* pTarget, int nTargetWidth, int nTargetHeight, int nTargetPitch, int nLeft, int nTop, int nChannel ); //ANY11(FastCopy_Any, FastCopy, 0, 1, 1, 63);