OptimizeCal.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <immintrin.h>
  3. #include <iostream>
  4. #include <opencv2/opencv.hpp>
  5. /* helper tables */
  6. extern const unsigned char icvSaturate8u_cv[];
  7. #define CV_FAST_CAST_8U(t) ( (-256 <= (t) && (t) <= 512) ? icvSaturate8u_cv[(t)+256] : 0 )
  8. #define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b))
  9. #define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a))
  10. // Any 1 to 1.
  11. // memset for vin is meant to clear the source buffer so that
  12. // SIMD that reads full multiple of 16 bytes will not trigger msan errors.
  13. // memset is not needed for production, as the garbage values are processed but
  14. // not used, although there may be edge cases for subsampling.
  15. // The size of the buffer is based on the largest read, which can be inferred
  16. // by the source type (e.g. ARGB) and the mask (last parameter), or by examining
  17. // the source code for how much the source pointers are advanced.
  18. //Êý¾Ý4¶ÔÆë
  19. #define ALIGN_4(x) (((x) + 3) & ~3)
  20. //Êý¾Ý2¶ÔÆë
  21. #define ALIGN_2(x) (((x) + 1) & ~1)
  22. // Subsampled source needs to be increase by 1 of not even.
  23. #define SS(width, shift) (((width) + (1 << (shift)) - 1) >> (shift))
  24. #define SIMD_ALIGNED(var) __declspec(align(16)) var
  25. //#define ANY11(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK)
  26. void FastCopy_Any(const unsigned char* src_ptr, unsigned char* dst_ptr, int width);
  27. void FastCopy(unsigned char* pSrc, unsigned char* pDst, int nWidth);
  28. void distanceATS_L1_8u(unsigned char* const src,int nWidth,int nHeight,int nPitch, unsigned char* dst);
  29. void OptimizeCalMatAdd_8U(unsigned char* pRelated, int nRelatedWidth, int nRelatedHeight, int nRelatedPitch,
  30. unsigned char* pTarget, int nTargetWidth, int nTargetHeight, int nTargetPitch,
  31. int nLeft, int nTop,
  32. int nChannel
  33. );
  34. //ANY11(FastCopy_Any, FastCopy, 0, 1, 1, 63);