compare_row.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright 2013 The LibYuv Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_
  11. #define INCLUDE_LIBYUV_COMPARE_ROW_H_
  12. #include "libyuv/basic_types.h"
  13. #ifdef __cplusplus
  14. namespace libyuv {
  15. extern "C" {
  16. #endif
  17. #if defined(__pnacl__) || defined(__CLR_VER) || \
  18. (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
  19. #define LIBYUV_DISABLE_X86
  20. #endif
  21. // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
  22. #if defined(__has_feature)
  23. #if __has_feature(memory_sanitizer)
  24. #define LIBYUV_DISABLE_X86
  25. #endif
  26. #endif
  27. // Visual C 2012 required for AVX2.
  28. #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
  29. _MSC_VER >= 1700
  30. #define VISUALC_HAS_AVX2 1
  31. #endif // VisualStudio >= 2012
  32. // clang >= 3.4.0 required for AVX2.
  33. #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
  34. #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
  35. #define CLANG_HAS_AVX2 1
  36. #endif // clang >= 3.4
  37. #endif // __clang__
  38. // The following are available for Visual C:
  39. #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \
  40. (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
  41. #define HAS_HASHDJB2_AVX2
  42. #endif
  43. // The following are available for Visual C and GCC:
  44. #if !defined(LIBYUV_DISABLE_X86) && \
  45. (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86))
  46. #define HAS_HASHDJB2_SSE41
  47. #define HAS_SUMSQUAREERROR_SSE2
  48. # if (MSC_VER >= 1400)
  49. // Visual Studio 2005 doesn't support sse42
  50. # define HAS_HAMMINGDISTANCE_SSE42
  51. # endif
  52. #endif
  53. // The following are available for Visual C and clangcl 32 bit:
  54. #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \
  55. (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
  56. #define HAS_HASHDJB2_AVX2
  57. #define HAS_SUMSQUAREERROR_AVX2
  58. #endif
  59. // The following are available for GCC and clangcl 64 bit:
  60. #if !defined(LIBYUV_DISABLE_X86) && \
  61. (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
  62. #define HAS_HAMMINGDISTANCE_SSSE3
  63. #endif
  64. // The following are available for GCC and clangcl 64 bit:
  65. #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
  66. (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
  67. #define HAS_HAMMINGDISTANCE_AVX2
  68. #endif
  69. // The following are available for Neon:
  70. #if !defined(LIBYUV_DISABLE_NEON) && \
  71. (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
  72. #define HAS_SUMSQUAREERROR_NEON
  73. #define HAS_HAMMINGDISTANCE_NEON
  74. #endif
  75. #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
  76. #define HAS_HAMMINGDISTANCE_MSA
  77. #define HAS_SUMSQUAREERROR_MSA
  78. #endif
  79. uint32 HammingDistance_C(const uint8* src_a, const uint8* src_b, int count);
  80. uint32 HammingDistance_SSE42(const uint8* src_a, const uint8* src_b, int count);
  81. uint32 HammingDistance_SSSE3(const uint8* src_a, const uint8* src_b, int count);
  82. uint32 HammingDistance_AVX2(const uint8* src_a, const uint8* src_b, int count);
  83. uint32 HammingDistance_NEON(const uint8* src_a, const uint8* src_b, int count);
  84. uint32 HammingDistance_MSA(const uint8* src_a, const uint8* src_b, int count);
  85. uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count);
  86. uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count);
  87. uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count);
  88. uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count);
  89. uint32 SumSquareError_MSA(const uint8* src_a, const uint8* src_b, int count);
  90. uint32 HashDjb2_C(const uint8* src, int count, uint32 seed);
  91. uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed);
  92. uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed);
  93. #ifdef __cplusplus
  94. } // extern "C"
  95. } // namespace libyuv
  96. #endif
  97. #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_