compare_row.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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(__native_client__) && defined(__x86_64__)) || \
  19. (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
  20. #define LIBYUV_DISABLE_X86
  21. #endif
  22. #if defined(__native_client__)
  23. #define LIBYUV_DISABLE_NEON
  24. #endif
  25. // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
  26. #if defined(__has_feature)
  27. #if __has_feature(memory_sanitizer)
  28. #define LIBYUV_DISABLE_X86
  29. #endif
  30. #endif
  31. // Visual C 2012 required for AVX2.
  32. #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
  33. _MSC_VER >= 1700
  34. #define VISUALC_HAS_AVX2 1
  35. #endif // VisualStudio >= 2012
  36. // clang >= 3.4.0 required for AVX2.
  37. #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
  38. #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
  39. #define CLANG_HAS_AVX2 1
  40. #endif // clang >= 3.4
  41. #endif // __clang__
  42. // The following are available for Visual C and GCC:
  43. #if !defined(LIBYUV_DISABLE_X86) && \
  44. (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86))
  45. #define HAS_HASHDJB2_SSE41
  46. #define HAS_SUMSQUAREERROR_SSE2
  47. #define HAS_HAMMINGDISTANCE_SSE42
  48. #endif
  49. // The following are available for Visual C and clangcl 32 bit:
  50. #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \
  51. (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
  52. #define HAS_HASHDJB2_AVX2
  53. #define HAS_SUMSQUAREERROR_AVX2
  54. #endif
  55. // The following are available for GCC and clangcl 64 bit:
  56. #if !defined(LIBYUV_DISABLE_X86) && \
  57. (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
  58. #define HAS_HAMMINGDISTANCE_SSSE3
  59. #endif
  60. // The following are available for GCC and clangcl 64 bit:
  61. #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
  62. (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
  63. #define HAS_HAMMINGDISTANCE_AVX2
  64. #endif
  65. // The following are available for Neon:
  66. #if !defined(LIBYUV_DISABLE_NEON) && \
  67. (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
  68. #define HAS_SUMSQUAREERROR_NEON
  69. #define HAS_HAMMINGDISTANCE_NEON
  70. #endif
  71. #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
  72. #define HAS_HAMMINGDISTANCE_MSA
  73. #define HAS_SUMSQUAREERROR_MSA
  74. #endif
  75. #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
  76. #define HAS_HAMMINGDISTANCE_MMI
  77. #define HAS_SUMSQUAREERROR_MMI
  78. #endif
  79. uint32_t HammingDistance_C(const uint8_t* src_a,
  80. const uint8_t* src_b,
  81. int count);
  82. uint32_t HammingDistance_SSE42(const uint8_t* src_a,
  83. const uint8_t* src_b,
  84. int count);
  85. uint32_t HammingDistance_SSSE3(const uint8_t* src_a,
  86. const uint8_t* src_b,
  87. int count);
  88. uint32_t HammingDistance_AVX2(const uint8_t* src_a,
  89. const uint8_t* src_b,
  90. int count);
  91. uint32_t HammingDistance_NEON(const uint8_t* src_a,
  92. const uint8_t* src_b,
  93. int count);
  94. uint32_t HammingDistance_MSA(const uint8_t* src_a,
  95. const uint8_t* src_b,
  96. int count);
  97. uint32_t HammingDistance_MMI(const uint8_t* src_a,
  98. const uint8_t* src_b,
  99. int count);
  100. uint32_t SumSquareError_C(const uint8_t* src_a,
  101. const uint8_t* src_b,
  102. int count);
  103. uint32_t SumSquareError_SSE2(const uint8_t* src_a,
  104. const uint8_t* src_b,
  105. int count);
  106. uint32_t SumSquareError_AVX2(const uint8_t* src_a,
  107. const uint8_t* src_b,
  108. int count);
  109. uint32_t SumSquareError_NEON(const uint8_t* src_a,
  110. const uint8_t* src_b,
  111. int count);
  112. uint32_t SumSquareError_MSA(const uint8_t* src_a,
  113. const uint8_t* src_b,
  114. int count);
  115. uint32_t SumSquareError_MMI(const uint8_t* src_a,
  116. const uint8_t* src_b,
  117. int count);
  118. uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed);
  119. uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed);
  120. uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed);
  121. #ifdef __cplusplus
  122. } // extern "C"
  123. } // namespace libyuv
  124. #endif
  125. #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_