• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(__clang__) &&                                                   \
59     (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
60 #define HAS_HASHDJB2_AVX2
61 #define HAS_SUMSQUAREERROR_AVX2
62 #endif
63 
64 // The following are available for GCC and clangcl:
65 #if !defined(LIBYUV_DISABLE_X86) && (defined(__x86_64__) || defined(__i386__))
66 #define HAS_HAMMINGDISTANCE_SSSE3
67 #endif
68 
69 // The following are available for GCC and clangcl:
70 #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
71     (defined(__x86_64__) || defined(__i386__))
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 uint32_t HammingDistance_C(const uint8_t* src_a,
88                            const uint8_t* src_b,
89                            int count);
90 uint32_t HammingDistance_SSE42(const uint8_t* src_a,
91                                const uint8_t* src_b,
92                                int count);
93 uint32_t HammingDistance_SSSE3(const uint8_t* src_a,
94                                const uint8_t* src_b,
95                                int count);
96 uint32_t HammingDistance_AVX2(const uint8_t* src_a,
97                               const uint8_t* src_b,
98                               int count);
99 uint32_t HammingDistance_NEON(const uint8_t* src_a,
100                               const uint8_t* src_b,
101                               int count);
102 uint32_t HammingDistance_MSA(const uint8_t* src_a,
103                              const uint8_t* src_b,
104                              int count);
105 uint32_t SumSquareError_C(const uint8_t* src_a,
106                           const uint8_t* src_b,
107                           int count);
108 uint32_t SumSquareError_SSE2(const uint8_t* src_a,
109                              const uint8_t* src_b,
110                              int count);
111 uint32_t SumSquareError_AVX2(const uint8_t* src_a,
112                              const uint8_t* src_b,
113                              int count);
114 uint32_t SumSquareError_NEON(const uint8_t* src_a,
115                              const uint8_t* src_b,
116                              int count);
117 uint32_t SumSquareError_MSA(const uint8_t* src_a,
118                             const uint8_t* src_b,
119                             int count);
120 
121 uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed);
122 uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed);
123 uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed);
124 
125 #ifdef __cplusplus
126 }  // extern "C"
127 }  // namespace libyuv
128 #endif
129 
130 #endif  // INCLUDE_LIBYUV_COMPARE_ROW_H_
131