| 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_MIN_MAX_SC_H | ||
| 6 | #define KLEIDICV_MIN_MAX_SC_H | ||
| 7 | |||
| 8 | #include <limits> | ||
| 9 | |||
| 10 | #include "kleidicv/sve2.h" | ||
| 11 | |||
| 12 | namespace KLEIDICV_TARGET_NAMESPACE { | ||
| 13 | |||
| 14 | template <typename ScalarType> | ||
| 15 | class MinMax final : public UnrollTwice { | ||
| 16 | public: | ||
| 17 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 18 | using VectorType = typename VecTraits::VectorType; | ||
| 19 | using ContextType = Context; | ||
| 20 | |||
| 21 | 2670 | MinMax(VectorType &vmin, VectorType &vmax) KLEIDICV_STREAMING : vmin_{vmin}, | |
| 22 | 2670 | vmax_{vmax} {} | |
| 23 | |||
| 24 | 14668 | void vector_path(ContextType ctx, VectorType src) KLEIDICV_STREAMING { | |
| 25 | 14668 | auto pg = ctx.predicate(); | |
| 26 | 14668 | vmin_ = svmin_m(pg, vmin_, src); | |
| 27 | 14668 | vmax_ = svmax_m(pg, vmax_, src); | |
| 28 | 14668 | } | |
| 29 | |||
| 30 | 1554 | ScalarType get_min() const KLEIDICV_STREAMING { | |
| 31 | 1554 | auto pg = VecTraits::svptrue(); | |
| 32 | 3108 | return svminv(pg, vmin_); | |
| 33 | 1554 | } | |
| 34 | |||
| 35 | 1554 | ScalarType get_max() const KLEIDICV_STREAMING { | |
| 36 | 1554 | auto pg = VecTraits::svptrue(); | |
| 37 | 3108 | return svmaxv(pg, vmax_); | |
| 38 | 1554 | } | |
| 39 | |||
| 40 | private: | ||
| 41 | VectorType &vmin_, &vmax_; | ||
| 42 | }; // end of class MinMax<T> | ||
| 43 | |||
| 44 | template <typename ScalarType> | ||
| 45 | 3294 | kleidicv_error_t min_max_sc(const ScalarType *src, size_t src_stride, | |
| 46 | size_t width, size_t height, ScalarType *min_value, | ||
| 47 | ScalarType *max_value) KLEIDICV_STREAMING { | ||
| 48 |
24/24✓ Branch 0 taken 90 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 456 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 456 times.
✓ Branch 6 taken 90 times.
✓ Branch 7 taken 456 times.
✓ Branch 8 taken 93 times.
✓ Branch 9 taken 456 times.
✓ Branch 10 taken 93 times.
✓ Branch 11 taken 456 times.
✓ Branch 12 taken 93 times.
✓ Branch 13 taken 456 times.
✓ Branch 14 taken 93 times.
✓ Branch 15 taken 456 times.
✓ Branch 16 taken 93 times.
✓ Branch 17 taken 456 times.
✓ Branch 18 taken 93 times.
✓ Branch 19 taken 456 times.
✓ Branch 20 taken 93 times.
✓ Branch 21 taken 462 times.
✓ Branch 22 taken 93 times.
✓ Branch 23 taken 462 times.
|
3294 | CHECK_POINTER_AND_STRIDE(src, src_stride, height); |
| 49 |
36/36✓ Branch 0 taken 3 times.
✓ Branch 1 taken 453 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 450 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 450 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 453 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 450 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 450 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 453 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 450 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 450 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 453 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 450 times.
✓ Branch 22 taken 6 times.
✓ Branch 23 taken 450 times.
✓ Branch 24 taken 3 times.
✓ Branch 25 taken 453 times.
✓ Branch 26 taken 3 times.
✓ Branch 27 taken 450 times.
✓ Branch 28 taken 6 times.
✓ Branch 29 taken 450 times.
✓ Branch 30 taken 3 times.
✓ Branch 31 taken 459 times.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 456 times.
✓ Branch 34 taken 6 times.
✓ Branch 35 taken 456 times.
|
2742 | CHECK_IMAGE_SIZE(width, height); |
| 50 | |||
| 51 |
24/24✓ Branch 0 taken 3 times.
✓ Branch 1 taken 447 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 444 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 447 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 444 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 447 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 444 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 447 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 444 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 447 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 444 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 453 times.
✓ Branch 22 taken 6 times.
✓ Branch 23 taken 450 times.
|
2706 | if (KLEIDICV_UNLIKELY(width == 0 || height == 0)) { |
| 52 | 36 | return KLEIDICV_ERROR_RANGE; | |
| 53 | } | ||
| 54 | |||
| 55 | 2670 | Rectangle rect{width, height}; | |
| 56 | 2670 | Rows<const ScalarType> src_rows{src, src_stride}; | |
| 57 | |||
| 58 | using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>; | ||
| 59 | using VectorType = typename VecTraits::VectorType; | ||
| 60 | 2670 | VectorType vmin = VecTraits::svdup(std::numeric_limits<ScalarType>::max()); | |
| 61 | 2670 | VectorType vmax = VecTraits::svdup(std::numeric_limits<ScalarType>::lowest()); | |
| 62 | |||
| 63 | 2670 | MinMax<ScalarType> operation{vmin, vmax}; | |
| 64 | |||
| 65 | 2670 | apply_operation_by_rows(operation, rect, src_rows); | |
| 66 |
12/12✓ Branch 0 taken 186 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 186 times.
✓ Branch 7 taken 258 times.
✓ Branch 8 taken 186 times.
✓ Branch 9 taken 258 times.
✓ Branch 10 taken 186 times.
✓ Branch 11 taken 264 times.
|
2670 | if (min_value) { |
| 67 | 1554 | *min_value = operation.get_min(); | |
| 68 | 1554 | } | |
| 69 |
12/12✓ Branch 0 taken 186 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 186 times.
✓ Branch 7 taken 258 times.
✓ Branch 8 taken 186 times.
✓ Branch 9 taken 258 times.
✓ Branch 10 taken 186 times.
✓ Branch 11 taken 264 times.
|
2670 | if (max_value) { |
| 70 | 1554 | *max_value = operation.get_max(); | |
| 71 | 1554 | } | |
| 72 | 2670 | return KLEIDICV_OK; | |
| 73 | 3294 | } | |
| 74 | |||
| 75 | } // namespace KLEIDICV_TARGET_NAMESPACE | ||
| 76 | |||
| 77 | #endif // KLEIDICV_MIN_MAX_SC_H | ||
| 78 |