KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/arithmetics/absdiff_sc.h
Date: 2025-11-25 17:23:32
Exec Total Coverage
Lines: 19 19 100.0%
Functions: 30 30 100.0%
Branches: 90 90 100.0%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #ifndef ABSDIFF_SC_H
6 #define ABSDIFF_SC_H
7
8 #include "kleidicv/sve2.h"
9
10 namespace KLEIDICV_TARGET_NAMESPACE {
11
12 template <typename ScalarType, typename VectorType,
13 std::enable_if_t<std::is_signed<ScalarType>::value, bool> = true>
14 5747 VectorType vector_path_impl(svbool_t pg, VectorType src_a,
15 VectorType src_b) KLEIDICV_STREAMING {
16 // Results of SABD may be outside the signed range so use two
17 // saturating instructions instead.
18 5747 return svqabs_x(pg, svqsub_m(pg, src_a, src_b));
19 }
20
21 template <typename ScalarType, typename VectorType,
22 std::enable_if_t<std::is_unsigned<ScalarType>::value, bool> = true>
23 2447 VectorType vector_path_impl(svbool_t pg, VectorType src_a,
24 VectorType src_b) KLEIDICV_STREAMING {
25 2447 return svabd_m(pg, src_a, src_b);
26 }
27
28 template <typename ScalarType>
29 class SaturatingAbsDiff final : public UnrollTwice {
30 public:
31 using ContextType = Context;
32 using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>;
33 using VectorType = typename VecTraits::VectorType;
34
35 8194 VectorType vector_path(ContextType ctx, VectorType src_a,
36 VectorType src_b) KLEIDICV_STREAMING {
37 8194 return vector_path_impl<ScalarType>(ctx.predicate(), src_a, src_b);
38 }
39 }; // end of class SaturatingAbsDiff<ScalarType>
40
41 template <typename T>
42 1077 kleidicv_error_t saturating_absdiff_sc(const T *src_a, size_t src_a_stride,
43 const T *src_b, size_t src_b_stride,
44 T *dst, size_t dst_stride, size_t width,
45 size_t height) KLEIDICV_STREAMING {
46
20/20
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 207 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 207 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 213 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 213 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 213 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 213 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 213 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 213 times.
1077 CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height);
47
20/20
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 204 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 204 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 207 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 207 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 207 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 207 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 207 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 207 times.
1053 CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height);
48
20/20
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 201 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 201 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 201 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 201 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 201 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 201 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 201 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 201 times.
1029 CHECK_POINTER_AND_STRIDE(dst, dst_stride, height);
49
30/30
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 195 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 195 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 198 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 195 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 195 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 198 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 195 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 195 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 198 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 195 times.
✓ Branch 22 taken 6 times.
✓ Branch 23 taken 195 times.
✓ Branch 24 taken 3 times.
✓ Branch 25 taken 198 times.
✓ Branch 26 taken 3 times.
✓ Branch 27 taken 195 times.
✓ Branch 28 taken 6 times.
✓ Branch 29 taken 195 times.
1005 CHECK_IMAGE_SIZE(width, height);
50
51 975 SaturatingAbsDiff<T> operation;
52 975 Rectangle rect{width, height};
53 975 Rows<const T> src_a_rows{src_a, src_a_stride};
54 975 Rows<const T> src_b_rows{src_b, src_b_stride};
55 975 Rows<T> dst_rows{dst, dst_stride};
56 975 apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows);
57 975 return KLEIDICV_OK;
58 1077 }
59
60 } // namespace KLEIDICV_TARGET_NAMESPACE
61
62 #endif // ABSDIFF_SC_H
63