1/*
2 *  Copyright 2012 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#include "libyuv/basic_types.h"
12
13#include "libyuv/compare_row.h"
14#include "libyuv/row.h"
15
16#ifdef __cplusplus
17namespace libyuv {
18extern "C" {
19#endif
20
21#if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \
22    !defined(__aarch64__)
23
24uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) {
25  volatile uint32 sse;
26  asm volatile (
27    "vmov.u8    q8, #0                         \n"
28    "vmov.u8    q10, #0                        \n"
29    "vmov.u8    q9, #0                         \n"
30    "vmov.u8    q11, #0                        \n"
31
32  "1:                                          \n"
33    MEMACCESS(0)
34    "vld1.8     {q0}, [%0]!                    \n"
35    MEMACCESS(1)
36    "vld1.8     {q1}, [%1]!                    \n"
37    "subs       %2, %2, #16                    \n"
38    "vsubl.u8   q2, d0, d2                     \n"
39    "vsubl.u8   q3, d1, d3                     \n"
40    "vmlal.s16  q8, d4, d4                     \n"
41    "vmlal.s16  q9, d6, d6                     \n"
42    "vmlal.s16  q10, d5, d5                    \n"
43    "vmlal.s16  q11, d7, d7                    \n"
44    "bgt        1b                             \n"
45
46    "vadd.u32   q8, q8, q9                     \n"
47    "vadd.u32   q10, q10, q11                  \n"
48    "vadd.u32   q11, q8, q10                   \n"
49    "vpaddl.u32 q1, q11                        \n"
50    "vadd.u64   d0, d2, d3                     \n"
51    "vmov.32    %3, d0[0]                      \n"
52    : "+r"(src_a),
53      "+r"(src_b),
54      "+r"(count),
55      "=r"(sse)
56    :
57    : "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11");
58  return sse;
59}
60
61#endif  // defined(__ARM_NEON__) && !defined(__aarch64__)
62
63#ifdef __cplusplus
64}  // extern "C"
65}  // namespace libyuv
66#endif
67