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