| 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_THRESHOLD_SC_H | ||
| 6 | #define KLEIDICV_THRESHOLD_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 BinaryThreshold final : public UnrollTwice { | ||
| 15 | public: | ||
| 16 | using ContextType = Context; | ||
| 17 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 18 | using VectorType = typename VecTraits::VectorType; | ||
| 19 | |||
| 20 | 213 | BinaryThreshold(ScalarType threshold, ScalarType value) KLEIDICV_STREAMING | |
| 21 | 213 | : threshold_(threshold), | |
| 22 | 213 | value_(value) {} | |
| 23 | |||
| 24 | 947 | VectorType vector_path(ContextType ctx, VectorType src) KLEIDICV_STREAMING { | |
| 25 | 947 | svbool_t predicate = svcmpgt(ctx.predicate(), src, threshold_); | |
| 26 | 1894 | return svsel_u8(predicate, svdup_u8(value_), svdup_u8(0)); | |
| 27 | 947 | } | |
| 28 | |||
| 29 | private: | ||
| 30 | ScalarType threshold_; | ||
| 31 | ScalarType value_; | ||
| 32 | }; // end of class BinaryThreshold<ScalarType> | ||
| 33 | |||
| 34 | template <typename T> | ||
| 35 | 225 | kleidicv_error_t threshold_binary_sc(const T *src, size_t src_stride, T *dst, | |
| 36 | size_t dst_stride, size_t width, | ||
| 37 | size_t height, T threshold, | ||
| 38 | T value) KLEIDICV_STREAMING { | ||
| 39 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 222 times.
|
225 | CHECK_POINTER_AND_STRIDE(src, src_stride, height); |
| 40 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 219 times.
|
222 | CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); |
| 41 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 216 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 213 times.
|
219 | CHECK_IMAGE_SIZE(width, height); |
| 42 | |||
| 43 | 213 | Rectangle rect{width, height}; | |
| 44 | 213 | Rows<const T> src_rows{src, src_stride}; | |
| 45 | 213 | Rows<T> dst_rows{dst, dst_stride}; | |
| 46 | 213 | BinaryThreshold<T> operation{threshold, value}; | |
| 47 | 213 | apply_operation_by_rows(operation, rect, src_rows, dst_rows); | |
| 48 | 213 | return KLEIDICV_OK; | |
| 49 | 225 | } | |
| 50 | |||
| 51 | } // namespace KLEIDICV_TARGET_NAMESPACE | ||
| 52 | |||
| 53 | #endif // KLEIDICV_THRESHOLD_SC_H | ||
| 54 |