Line | Branch | Exec | Source |
---|---|---|---|
1 | // SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates <open-source-office@arm.com> | ||
2 | // | ||
3 | // SPDX-License-Identifier: Apache-2.0 | ||
4 | |||
5 | #include "kleidicv/kleidicv.h" | ||
6 | #include "kleidicv/neon.h" | ||
7 | |||
8 | namespace kleidicv::neon { | ||
9 | |||
10 | template <typename ScalarType> | ||
11 | class ComparatorEqual : public UnrollTwice { | ||
12 | public: | ||
13 | using VecTraits = neon::VecTraits<ScalarType>; | ||
14 | using VectorType = typename VecTraits::VectorType; | ||
15 | |||
16 | 500 | VectorType vector_path(VectorType src_a, VectorType src_b) { | |
17 | 500 | return vceqq_u8(src_a, src_b); | |
18 | } | ||
19 | |||
20 | // NOLINTBEGIN(readability-make-member-function-const) | ||
21 | 687 | ScalarType scalar_path(ScalarType src_a, ScalarType src_b) { | |
22 | 687 | return src_a == src_b ? 255 : 0; | |
23 | } | ||
24 | // NOLINTEND(readability-make-member-function-const) | ||
25 | }; // end of class ComparatorEqual | ||
26 | |||
27 | template <typename ScalarType> | ||
28 | class ComparatorGreater : public UnrollTwice { | ||
29 | public: | ||
30 | using VecTraits = neon::VecTraits<ScalarType>; | ||
31 | using VectorType = typename VecTraits::VectorType; | ||
32 | |||
33 | 500 | VectorType vector_path(VectorType src_a, VectorType src_b) { | |
34 | 500 | return vcgtq_u8(src_a, src_b); | |
35 | } | ||
36 | |||
37 | // NOLINTBEGIN(readability-make-member-function-const) | ||
38 | 687 | ScalarType scalar_path(ScalarType src_a, ScalarType src_b) { | |
39 | 687 | return src_a > src_b ? 255 : 0; | |
40 | } | ||
41 | // NOLINTEND(readability-make-member-function-const) | ||
42 | }; // end of class ComparatorGreater | ||
43 | |||
44 | template <typename Comparator, typename ScalarType> | ||
45 | 156 | static kleidicv_error_t compare(const ScalarType *src_a, size_t src_a_stride, | |
46 | const ScalarType *src_b, size_t src_b_stride, | ||
47 | ScalarType *dst, size_t dst_stride, | ||
48 | size_t width, size_t height) { | ||
49 |
8/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 77 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 77 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 77 times.
|
156 | CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height); |
50 |
8/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 76 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 76 times.
|
154 | CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height); |
51 |
8/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 75 times.
|
152 | CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); |
52 |
12/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 73 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 73 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 74 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 73 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 73 times.
|
150 | CHECK_IMAGE_SIZE(width, height); |
53 | |||
54 | 146 | Comparator operation{}; | |
55 | 146 | Rectangle rect{width, height}; | |
56 | 146 | Rows<const ScalarType> src_a_rows{src_a, src_a_stride}; | |
57 | 146 | Rows<const ScalarType> src_b_rows{src_b, src_b_stride}; | |
58 | 146 | Rows<ScalarType> dst_rows{dst, dst_stride}; | |
59 | |||
60 | 146 | apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows); | |
61 | |||
62 | 146 | return KLEIDICV_OK; | |
63 | 156 | } | |
64 | |||
65 | template <typename ScalarType> | ||
66 | 78 | kleidicv_error_t compare_equal(const ScalarType *src_a, size_t src_a_stride, | |
67 | const ScalarType *src_b, size_t src_b_stride, | ||
68 | ScalarType *dst, size_t dst_stride, size_t width, | ||
69 | size_t height) { | ||
70 | 78 | return compare<ComparatorEqual<ScalarType>>( | |
71 | 78 | src_a, src_a_stride, src_b, src_b_stride, dst, dst_stride, width, height); | |
72 | } | ||
73 | |||
74 | template <typename ScalarType> | ||
75 | 78 | kleidicv_error_t compare_greater(const ScalarType *src_a, size_t src_a_stride, | |
76 | const ScalarType *src_b, size_t src_b_stride, | ||
77 | ScalarType *dst, size_t dst_stride, | ||
78 | size_t width, size_t height) { | ||
79 | 78 | return compare<ComparatorGreater<ScalarType>>( | |
80 | 78 | src_a, src_a_stride, src_b, src_b_stride, dst, dst_stride, width, height); | |
81 | } | ||
82 | |||
83 | #define KLEIDICV_INSTANTIATE_TEMPLATE(name, stype) \ | ||
84 | template KLEIDICV_TARGET_FN_ATTRS kleidicv_error_t name<stype>( \ | ||
85 | const stype *src_a, size_t src_a_stride, const stype *src_b, \ | ||
86 | size_t src_b_stride, stype *dst, size_t dst_stride, size_t width, \ | ||
87 | size_t height) | ||
88 | |||
89 | KLEIDICV_INSTANTIATE_TEMPLATE(compare_equal, uint8_t); | ||
90 | KLEIDICV_INSTANTIATE_TEMPLATE(compare_greater, uint8_t); | ||
91 | |||
92 | } // namespace kleidicv::neon | ||
93 |