KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/arithmetics/add_abs_with_threshold_sc.h
Date: 2025-09-25 14:13:34
Exec Total Coverage
Lines: 21 21 100.0%
Functions: 6 6 100.0%
Branches: 18 18 100.0%

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 156 explicit SaturatingAddAbsWithThreshold(ScalarType threshold)
23 156 KLEIDICV_STREAMING : threshold_(threshold) {}
24
25 1379 VectorType vector_path(ContextType ctx, VectorType src_a,
26 VectorType src_b) KLEIDICV_STREAMING {
27 1379 auto pg = ctx.predicate();
28 1379 VectorType add_abs = svqadd_x(pg, svqabs_x(pg, src_a), svqabs_x(pg, src_b));
29 1379 svbool_t predicate = svcmpgt(pg, add_abs, threshold_);
30 2758 return svsel(predicate, add_abs, VecTraits::svdup(0));
31 1379 }
32
33 private:
34 ScalarType threshold_;
35 }; // end of class SaturatingAddAbsWithThreshold<ScalarType>
36
37 template <typename T>
38 172 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 4 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 168 times.
172 CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height);
43
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 164 times.
168 CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height);
44
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 160 times.
164 CHECK_POINTER_AND_STRIDE(dst, dst_stride, height);
45
6/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 158 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 156 times.
160 CHECK_IMAGE_SIZE(width, height);
46
47 156 SaturatingAddAbsWithThreshold<T> operation{threshold};
48 156 Rectangle rect{width, height};
49 156 Rows<const T> src_a_rows{src_a, src_a_stride};
50 156 Rows<const T> src_b_rows{src_b, src_b_stride};
51 156 Rows<T> dst_rows{dst, dst_stride};
52 156 apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows);
53 156 return KLEIDICV_OK;
54 172 }
55
56 } // namespace KLEIDICV_TARGET_NAMESPACE
57
58 #endif // KLEIDICV_SATURATING_ADD_ABS_WITH_THRESHOLD_SC_H
59