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