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_  // NOLINT
12#define INCLUDE_LIBYUV_COMPARE_ROW_H_
13
14#include "libyuv/basic_types.h"
15
16#ifdef __cplusplus
17namespace libyuv {
18extern "C" {
19#endif
20
21#if defined(__pnacl__) || defined(__CLR_VER) || \
22    (defined(__i386__) && !defined(__SSE2__))
23#define LIBYUV_DISABLE_X86
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
32// Visual C 2012 required for AVX2.
33#if defined(_M_IX86) && !defined(__clang__) && \
34    defined(_MSC_VER) && _MSC_VER >= 1700
35#define VISUALC_HAS_AVX2 1
36#endif  // VisualStudio >= 2012
37
38// clang >= 3.4.0 required for AVX2.
39#if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
40#if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
41#define CLANG_HAS_AVX2 1
42#endif  // clang >= 3.4
43#endif  // __clang__
44
45#if !defined(LIBYUV_DISABLE_X86) && \
46    defined(_M_IX86) && (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
47#define HAS_HASHDJB2_AVX2
48#endif
49
50// The following are available for Visual C and GCC:
51#if !defined(LIBYUV_DISABLE_X86) && \
52    (defined(__x86_64__) || (defined(__i386__) || defined(_M_IX86)))
53#define HAS_HASHDJB2_SSE41
54#define HAS_SUMSQUAREERROR_SSE2
55#endif
56
57// The following are available for Visual C and clangcl 32 bit:
58#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \
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 Neon:
65#if !defined(LIBYUV_DISABLE_NEON) && \
66    (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
67#define HAS_SUMSQUAREERROR_NEON
68#endif
69
70uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count);
71uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count);
72uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count);
73uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count);
74
75uint32 HashDjb2_C(const uint8* src, int count, uint32 seed);
76uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed);
77uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed);
78
79#ifdef __cplusplus
80}  // extern "C"
81}  // namespace libyuv
82#endif
83
84#endif  // INCLUDE_LIBYUV_COMPARE_ROW_H_  NOLINT
85