| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-FileCopyrightText: 2023 - 2025 Arm Limited and/or its affiliates <open-source-office@arm.com> | ||
| 2 | // | ||
| 3 | // SPDX-License-Identifier: Apache-2.0 | ||
| 4 | |||
| 5 | #ifndef KLEIDICV_COMPARE_SC_H | ||
| 6 | #define KLEIDICV_COMPARE_SC_H | ||
| 7 | |||
| 8 | #include "kleidicv/kleidicv.h" | ||
| 9 | #include "kleidicv/sve2.h" | ||
| 10 | |||
| 11 | namespace KLEIDICV_TARGET_NAMESPACE { | ||
| 12 | |||
| 13 | template <typename ScalarType> | ||
| 14 | class ComparatorEqual : public UnrollTwice { | ||
| 15 | public: | ||
| 16 | using ContextType = Context; | ||
| 17 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 18 | using VectorType = typename VecTraits::VectorType; | ||
| 19 | using SignedScalarType = typename std::make_signed<ScalarType>::type; | ||
| 20 | using SignedVecTraits = | ||
| 21 | KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>; | ||
| 22 | using SignedVectorType = typename SignedVecTraits::VectorType; | ||
| 23 | |||
| 24 | // NOLINTBEGIN(readability-make-member-function-const) | ||
| 25 | 998 | VectorType vector_path(ContextType ctx, VectorType src_a, | |
| 26 | VectorType src_b) KLEIDICV_STREAMING { | ||
| 27 | 998 | svbool_t pg = ctx.predicate(); | |
| 28 | 998 | svbool_t predicate = svcmpeq(pg, src_a, src_b); | |
| 29 | 1996 | return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0)); | |
| 30 | 998 | } | |
| 31 | // NOLINTEND(readability-make-member-function-const) | ||
| 32 | }; // end of class ComparatorEqual | ||
| 33 | |||
| 34 | template <typename ScalarType> | ||
| 35 | class ComparatorGreater : public UnrollTwice { | ||
| 36 | public: | ||
| 37 | using ContextType = Context; | ||
| 38 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 39 | using VectorType = typename VecTraits::VectorType; | ||
| 40 | using SignedScalarType = typename std::make_signed<ScalarType>::type; | ||
| 41 | using SignedVecTraits = | ||
| 42 | KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>; | ||
| 43 | using SignedVectorType = typename SignedVecTraits::VectorType; | ||
| 44 | |||
| 45 | // NOLINTBEGIN(readability-make-member-function-const) | ||
| 46 | 998 | VectorType vector_path(ContextType ctx, VectorType src_a, | |
| 47 | VectorType src_b) KLEIDICV_STREAMING { | ||
| 48 | 998 | svbool_t pg = ctx.predicate(); | |
| 49 | 998 | svbool_t predicate = svcmpgt(pg, src_a, src_b); | |
| 50 | 1996 | return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0)); | |
| 51 | 998 | } | |
| 52 | // NOLINTEND(readability-make-member-function-const) | ||
| 53 | }; // end of class ComparatorGreater | ||
| 54 | |||
| 55 | template <typename Comparator, typename ScalarType> | ||
| 56 | 468 | kleidicv_error_t compare_sc(const ScalarType *src_a, size_t src_a_stride, | |
| 57 | const ScalarType *src_b, size_t src_b_stride, | ||
| 58 | ScalarType *dst, size_t dst_stride, size_t width, | ||
| 59 | size_t height) KLEIDICV_STREAMING { | ||
| 60 |
8/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 231 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 231 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 231 times.
|
468 | CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height); |
| 61 |
8/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 228 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 228 times.
|
462 | CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height); |
| 62 |
8/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 225 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 225 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 225 times.
|
456 | CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); |
| 63 |
12/12✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 219 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 219 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 222 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 219 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 219 times.
|
450 | CHECK_IMAGE_SIZE(width, height); |
| 64 | |||
| 65 | 438 | Comparator operation{}; | |
| 66 | 438 | Rectangle rect{width, height}; | |
| 67 | 438 | Rows<const ScalarType> src_a_rows{src_a, src_a_stride}; | |
| 68 | 438 | Rows<const ScalarType> src_b_rows{src_b, src_b_stride}; | |
| 69 | 438 | Rows<ScalarType> dst_rows{dst, dst_stride}; | |
| 70 | |||
| 71 | 438 | apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows); | |
| 72 | |||
| 73 | 438 | return KLEIDICV_OK; | |
| 74 | 468 | } | |
| 75 | |||
| 76 | } // namespace KLEIDICV_TARGET_NAMESPACE | ||
| 77 | |||
| 78 | #endif // KLEIDICV_COMPARE_SC_H | ||
| 79 |