| 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_SATURATING_ADD_ABS_WITH_THRESHOLD_SC_H | ||
| 6 | #define KLEIDICV_SATURATING_ADD_ABS_WITH_THRESHOLD_SC_H | ||
| 7 | |||
| 8 | #include <limits> | ||
| 9 | |||
| 10 | #include "kleidicv/kleidicv.h" | ||
| 11 | #include "kleidicv/sve2.h" | ||
| 12 | |||
| 13 | namespace KLEIDICV_TARGET_NAMESPACE { | ||
| 14 | |||
| 15 | template <typename ScalarType> | ||
| 16 | class SaturatingAddAbsWithThreshold final : public UnrollTwice { | ||
| 17 | public: | ||
| 18 | using ContextType = Context; | ||
| 19 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 20 | using VectorType = typename VecTraits::VectorType; | ||
| 21 | |||
| 22 | 234 | explicit SaturatingAddAbsWithThreshold(ScalarType threshold) | |
| 23 | 234 | KLEIDICV_STREAMING : threshold_(threshold) {} | |
| 24 | |||
| 25 | 1738 | VectorType vector_path(ContextType ctx, VectorType src_a, | |
| 26 | VectorType src_b) KLEIDICV_STREAMING { | ||
| 27 | 1738 | auto pg = ctx.predicate(); | |
| 28 | 1738 | VectorType add_abs = svqadd_x(pg, svqabs_x(pg, src_a), svqabs_x(pg, src_b)); | |
| 29 | 1738 | svbool_t predicate = svcmpgt(pg, add_abs, threshold_); | |
| 30 | 3476 | return svsel(predicate, add_abs, VecTraits::svdup(0)); | |
| 31 | 1738 | } | |
| 32 | |||
| 33 | private: | ||
| 34 | ScalarType threshold_; | ||
| 35 | }; // end of class SaturatingAddAbsWithThreshold<ScalarType> | ||
| 36 | |||
| 37 | template <typename T> | ||
| 38 | 258 | kleidicv_error_t saturating_add_abs_with_threshold_sc( | |
| 39 | const T *src_a, size_t src_a_stride, const T *src_b, size_t src_b_stride, | ||
| 40 | T *dst, size_t dst_stride, size_t width, size_t height, | ||
| 41 | T threshold) KLEIDICV_STREAMING { | ||
| 42 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 252 times.
|
258 | CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height); |
| 43 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 246 times.
|
252 | CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height); |
| 44 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 240 times.
|
246 | CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); |
| 45 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 237 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 234 times.
|
240 | CHECK_IMAGE_SIZE(width, height); |
| 46 | |||
| 47 | 234 | SaturatingAddAbsWithThreshold<T> operation{threshold}; | |
| 48 | 234 | Rectangle rect{width, height}; | |
| 49 | 234 | Rows<const T> src_a_rows{src_a, src_a_stride}; | |
| 50 | 234 | Rows<const T> src_b_rows{src_b, src_b_stride}; | |
| 51 | 234 | Rows<T> dst_rows{dst, dst_stride}; | |
| 52 | 234 | apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows); | |
| 53 | 234 | return KLEIDICV_OK; | |
| 54 | 258 | } | |
| 55 | |||
| 56 | } // namespace KLEIDICV_TARGET_NAMESPACE | ||
| 57 | |||
| 58 | #endif // KLEIDICV_SATURATING_ADD_ABS_WITH_THRESHOLD_SC_H | ||
| 59 |