KleidiCV Coverage Report


Directory: ./
File: kleidicv/include/kleidicv/workspace/border_21x21.h
Date: 2025-09-25 14:13:34
Exec Total Coverage
Lines: 219 219 100.0%
Functions: 84 84 100.0%
Branches: 156 158 98.7%

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 KLEIDICV_WORKSPACE_BORDER_21X21_H
6 #define KLEIDICV_WORKSPACE_BORDER_21X21_H
7
8 #include "border_types.h"
9
10 namespace KLEIDICV_TARGET_NAMESPACE {
11
12 // Border offsets for fixed-size filters.
13 template <typename T, const size_t S>
14 class FixedBorderInfo;
15
16 // Border offsets for 21x21 filters.
17 template <typename T>
18 class FixedBorderInfo<T, 21UL> final {
19 public:
20 // Simple object holding read-only constant offsets.
21 class Offsets final {
22 public:
23 // NOLINTBEGIN(hicpp-member-init)
24 Offsets() = default;
25 // NOLINTEND(hicpp-member-init)
26
27 42768 Offsets(ptrdiff_t o0, ptrdiff_t o1, ptrdiff_t o2, ptrdiff_t o3,
28 ptrdiff_t o4, ptrdiff_t o5, ptrdiff_t o6, ptrdiff_t o7,
29 ptrdiff_t o8, ptrdiff_t o9, ptrdiff_t o10, ptrdiff_t o11,
30 ptrdiff_t o12, ptrdiff_t o13, ptrdiff_t o14, ptrdiff_t o15,
31 ptrdiff_t o16, ptrdiff_t o17, ptrdiff_t o18, ptrdiff_t o19,
32 ptrdiff_t o20)
33 470448 : offsets_{o0, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10,
34 470448 o11, o12, o13, o14, o15, o16, o17, o18, o19, o20} {}
35
36 76224 ptrdiff_t c0() const { return offsets_[0]; }
37 76224 ptrdiff_t c1() const { return offsets_[1]; }
38 76224 ptrdiff_t c2() const { return offsets_[2]; }
39 76224 ptrdiff_t c3() const { return offsets_[3]; }
40 76224 ptrdiff_t c4() const { return offsets_[4]; }
41 76224 ptrdiff_t c5() const { return offsets_[5]; }
42 76224 ptrdiff_t c6() const { return offsets_[6]; }
43 76224 ptrdiff_t c7() const { return offsets_[7]; }
44 76224 ptrdiff_t c8() const { return offsets_[8]; }
45 76224 ptrdiff_t c9() const { return offsets_[9]; }
46 76224 ptrdiff_t c10() const { return offsets_[10]; }
47 76224 ptrdiff_t c11() const { return offsets_[11]; }
48 76224 ptrdiff_t c12() const { return offsets_[12]; }
49 76224 ptrdiff_t c13() const { return offsets_[13]; }
50 76224 ptrdiff_t c14() const { return offsets_[14]; }
51 76224 ptrdiff_t c15() const { return offsets_[15]; }
52 76224 ptrdiff_t c16() const { return offsets_[16]; }
53 76224 ptrdiff_t c17() const { return offsets_[17]; }
54 76224 ptrdiff_t c18() const { return offsets_[18]; }
55 76224 ptrdiff_t c19() const { return offsets_[19]; }
56 76224 ptrdiff_t c20() const { return offsets_[20]; }
57
58 private:
59 ptrdiff_t offsets_[21];
60 };
61
62 192 FixedBorderInfo(size_t width, FixedBorderType border_type)
63 192 : width_(width), border_type_(border_type) {}
64
65 // Returns offsets without the influence of any border.
66 1968 Offsets offsets_without_border() const KLEIDICV_STREAMING {
67 1968 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7,
68 8, 9, 10);
69 }
70
71 // NOLINTBEGIN(readability-function-cognitive-complexity)
72 // Returns offsets for columns affected by left border.
73 20400 Offsets offsets_with_left_border(size_t column_index) const
74 KLEIDICV_STREAMING {
75
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
✓ Branch 2 taken 5100 times.
✓ Branch 3 taken 5100 times.
✓ Branch 4 taken 5100 times.
20400 switch (border_type_) {
76 case FixedBorderType::REPLICATE:
77
2/2
✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 510 times.
5100 if (column_index == 0) {
78 510 return get(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
79 10);
80
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == 1) {
81 510 return get(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5,
82 6, 7, 8, 9, 10);
83
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == 2) {
84 510 return get(-2, -2, -2, -2, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 4, 5,
85 6, 7, 8, 9, 10);
86
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == 3) {
87 510 return get(-3, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 4, 5,
88 6, 7, 8, 9, 10);
89
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == 4) {
90 510 return get(-4, -4, -4, -4, -4, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
91 6, 7, 8, 9, 10);
92
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == 5) {
93 510 return get(-5, -5, -5, -5, -5, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
94 6, 7, 8, 9, 10);
95
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == 6) {
96 510 return get(-6, -6, -6, -6, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
97 6, 7, 8, 9, 10);
98
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == 7) {
99 510 return get(-7, -7, -7, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
100 6, 7, 8, 9, 10);
101
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == 8) {
102 510 return get(-8, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
103 6, 7, 8, 9, 10);
104 } else {
105 510 return get(-9, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
106 6, 7, 8, 9, 10);
107 }
108 break;
109
110 case FixedBorderType::REFLECT:
111
2/2
✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 510 times.
5100 if (column_index == 0) {
112 510 return get(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
113 10);
114
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == 1) {
115 510 return get(7, 6, 5, 4, 3, 2, 1, 0, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
116 9, 10);
117
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == 2) {
118 510 return get(5, 4, 3, 2, 1, 0, -1, -2, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7,
119 8, 9, 10);
120
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == 3) {
121 510 return get(3, 2, 1, 0, -1, -2, -3, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7,
122 8, 9, 10);
123
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == 4) {
124 510 return get(1, 0, -1, -2, -3, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6,
125 7, 8, 9, 10);
126
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == 5) {
127 510 return get(-1, -2, -3, -4, -5, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
128 6, 7, 8, 9, 10);
129
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == 6) {
130 510 return get(-3, -4, -5, -6, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
131 6, 7, 8, 9, 10);
132
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == 7) {
133 510 return get(-5, -6, -7, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
134 6, 7, 8, 9, 10);
135
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == 8) {
136 510 return get(-7, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
137 6, 7, 8, 9, 10);
138 } else {
139 510 return get(-9, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
140 6, 7, 8, 9, 10);
141 }
142 break;
143
144 case FixedBorderType::WRAP:
145
2/2
✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 510 times.
5100 if (column_index == 0) {
146 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
147 510 width_ - 6, width_ - 5, width_ - 4, width_ - 3, width_ - 2,
148 510 width_ - 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
149
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == 1) {
150 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
151 510 width_ - 6, width_ - 5, width_ - 4, width_ - 3, width_ - 2,
152 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
153
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == 2) {
154 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
155 510 width_ - 6, width_ - 5, width_ - 4, width_ - 3, -2, -1, 0,
156 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
157
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == 3) {
158 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
159 510 width_ - 6, width_ - 5, width_ - 4, -3, -2, -1, 0, 1, 2, 3,
160 4, 5, 6, 7, 8, 9, 10);
161
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == 4) {
162 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
163 510 width_ - 6, width_ - 5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
164 6, 7, 8, 9, 10);
165
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == 5) {
166 1020 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7,
167 510 width_ - 6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
168 9, 10);
169
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == 6) {
170 510 return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, -6, -5,
171 -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
172
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == 7) {
173 510 return get(width_ - 10, width_ - 9, width_ - 8, -7, -6, -5, -4, -3,
174 -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
175
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == 8) {
176 510 return get(width_ - 10, width_ - 9, -8, -7, -6, -5, -4, -3, -2, -1, 0,
177 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
178 } else {
179 510 return get(width_ - 10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2,
180 3, 4, 5, 6, 7, 8, 9, 10);
181 }
182 break;
183
184 case FixedBorderType::REVERSE:
185
2/2
✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 510 times.
5100 if (column_index == 0) {
186 510 return get(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
187 9, 10);
188
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == 1) {
189 510 return get(8, 7, 6, 5, 4, 3, 2, 1, 0, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
190 9, 10);
191
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == 2) {
192 510 return get(6, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
193 9, 10);
194
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == 3) {
195 510 return get(4, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7,
196 8, 9, 10);
197
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == 4) {
198 510 return get(2, 1, 0, -1, -2, -3, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6,
199 7, 8, 9, 10);
200
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == 5) {
201 510 return get(0, -1, -2, -3, -4, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6,
202 7, 8, 9, 10);
203
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == 6) {
204 510 return get(-2, -3, -4, -5, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
205 6, 7, 8, 9, 10);
206
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == 7) {
207 510 return get(-4, -5, -6, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
208 6, 7, 8, 9, 10);
209
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == 8) {
210 510 return get(-6, -7, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
211 6, 7, 8, 9, 10);
212 } else {
213 510 return get(-8, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
214 6, 7, 8, 9, 10);
215 }
216 break;
217 }
218 // Unreachable. Compiler should emit a warning-as-error if any cases are
219 // uncovered above.
220 return Offsets{}; // GCOVR_EXCL_LINE
221 20400 }
222
223 // Returns offsets for columns affected by right border.
224 20400 Offsets offsets_with_right_border(size_t column_index) const
225 KLEIDICV_STREAMING {
226
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
✓ Branch 2 taken 5100 times.
✓ Branch 3 taken 5100 times.
✓ Branch 4 taken 5100 times.
20400 switch (border_type_) {
227 case FixedBorderType::REPLICATE:
228
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4590 times.
5100 if (column_index == (width_ - 10)) {
229 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
230 6, 7, 8, 9, 9);
231
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == (width_ - 9)) {
232 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
233 6, 7, 8, 8, 8);
234
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == (width_ - 8)) {
235 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
236 6, 7, 7, 7, 7);
237
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == (width_ - 7)) {
238 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
239 6, 6, 6, 6, 6);
240
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == (width_ - 6)) {
241 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
242 5, 5, 5, 5, 5);
243
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == (width_ - 5)) {
244 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4,
245 4, 4, 4, 4, 4);
246
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == (width_ - 4)) {
247 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 3, 3,
248 3, 3, 3, 3, 3);
249
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == (width_ - 3)) {
250 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 2, 2, 2,
251 2, 2, 2, 2, 2);
252
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == (width_ - 2)) {
253 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 1, 1, 1, 1,
254 1, 1, 1, 1, 1);
255 } else {
256 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0, 0,
257 0, 0, 0, 0, 0);
258 }
259 break;
260
261 case FixedBorderType::REFLECT:
262
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4590 times.
5100 if (column_index == (width_ - 10)) {
263 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
264 6, 7, 8, 9, 9);
265
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == (width_ - 9)) {
266 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
267 6, 7, 8, 8, 7);
268
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == (width_ - 8)) {
269 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
270 6, 7, 7, 6, 5);
271
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == (width_ - 7)) {
272 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
273 6, 6, 5, 4, 3);
274
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == (width_ - 6)) {
275 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
276 5, 4, 3, 2, 1);
277
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == (width_ - 5)) {
278 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4,
279 3, 2, 1, 0, -1);
280
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == (width_ - 4)) {
281 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 3, 2,
282 1, 0, -1, -2, -3);
283
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == (width_ - 3)) {
284 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 2, 1, 0,
285 -1, -2, -3, -4, -5);
286
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == (width_ - 2)) {
287 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 1, 0, -1,
288 -2, -3, -4, -5, -6, -7);
289 } else {
290 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, -1, -2, -3,
291 -4, -5, -6, -7, -8, -9);
292 }
293 break;
294
295 case FixedBorderType::WRAP:
296
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4590 times.
5100 if (column_index == (width_ - 10)) {
297 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
298 510 6, 7, 8, 9, 10 - width_);
299
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == (width_ - 9)) {
300 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
301 510 6, 7, 8, 9 - width_, 10 - width_);
302
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == (width_ - 8)) {
303 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
304 510 6, 7, 8 - width_, 9 - width_, 10 - width_);
305
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == (width_ - 7)) {
306 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
307 510 6, 7 - width_, 8 - width_, 9 - width_, 10 - width_);
308
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == (width_ - 6)) {
309 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
310 510 6 - width_, 7 - width_, 8 - width_, 9 - width_,
311 510 10 - width_);
312
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == (width_ - 5)) {
313 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4,
314 510 5 - width_, 6 - width_, 7 - width_, 8 - width_, 9 - width_,
315 510 10 - width_);
316
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == (width_ - 4)) {
317 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3,
318 510 4 - width_, 5 - width_, 6 - width_, 7 - width_, 8 - width_,
319 510 9 - width_, 10 - width_);
320
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == (width_ - 3)) {
321 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2,
322 510 3 - width_, 4 - width_, 5 - width_, 6 - width_, 7 - width_,
323 510 8 - width_, 9 - width_, 10 - width_);
324
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == (width_ - 2)) {
325 1020 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2 - width_,
326 510 3 - width_, 4 - width_, 5 - width_, 6 - width_, 7 - width_,
327 510 8 - width_, 9 - width_, 10 - width_);
328 } else {
329 1020 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1 - width_,
330 510 2 - width_, 3 - width_, 4 - width_, 5 - width_, 6 - width_,
331 510 7 - width_, 8 - width_, 9 - width_, 10 - width_);
332 }
333 break;
334
335 case FixedBorderType::REVERSE:
336
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4590 times.
5100 if (column_index == (width_ - 10)) {
337 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
338 6, 7, 8, 9, 8);
339
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 4080 times.
4590 } else if (column_index == (width_ - 9)) {
340 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
341 6, 7, 8, 7, 6);
342
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3570 times.
4080 } else if (column_index == (width_ - 8)) {
343 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
344 6, 7, 6, 5, 4);
345
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3060 times.
3570 } else if (column_index == (width_ - 7)) {
346 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
347 6, 5, 4, 3, 2);
348
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2550 times.
3060 } else if (column_index == (width_ - 6)) {
349 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
350 4, 3, 2, 1, 0);
351
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2040 times.
2550 } else if (column_index == (width_ - 5)) {
352 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 3,
353 2, 1, 0, -1, -2);
354
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1530 times.
2040 } else if (column_index == (width_ - 4)) {
355 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 2, 1,
356 0, -1, -2, -3, -4);
357
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1020 times.
1530 } else if (column_index == (width_ - 3)) {
358 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 1, 0, -1,
359 -2, -3, -4, -5, -6);
360
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 510 times.
1020 } else if (column_index == (width_ - 2)) {
361 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 0, -1, -2,
362 -3, -4, -5, -6, -7, -8);
363 } else {
364 510 return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, -1, -2, -3, -4,
365 -5, -6, -7, -8, -9, -10);
366 }
367 break;
368 }
369 // Unreachable. Compiler should emit a warning-as-error if any cases are
370 // uncovered above.
371 return Offsets{}; // GCOVR_EXCL_LINE
372 20400 }
373 // NOLINTEND(readability-function-cognitive-complexity)
374
375 // Returns offsets for rows or columns affected by any border.
376 1944 Offsets offsets_with_border(size_t row_or_column_index) const
377 KLEIDICV_STREAMING {
378
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 984 times.
1944 if (row_or_column_index < 10U) {
379 // Rows and columns have the same offsets.
380 960 return offsets_with_left_border(row_or_column_index);
381 }
382
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 24 times.
984 if (row_or_column_index >= (width_ - 10U)) {
383 // Rows and columns have the same offsets.
384 960 return offsets_with_right_border(row_or_column_index);
385 }
386 24 return offsets_without_border();
387 1944 }
388
389 private:
390 // Takes care of static signed to unsigned casts.
391 42768 Offsets get(ptrdiff_t o0, ptrdiff_t o1, ptrdiff_t o2, ptrdiff_t o3,
392 ptrdiff_t o4, ptrdiff_t o5, ptrdiff_t o6, ptrdiff_t o7,
393 ptrdiff_t o8, ptrdiff_t o9, ptrdiff_t o10, ptrdiff_t o11,
394 ptrdiff_t o12, ptrdiff_t o13, ptrdiff_t o14, ptrdiff_t o15,
395 ptrdiff_t o16, ptrdiff_t o17, ptrdiff_t o18, ptrdiff_t o19,
396 ptrdiff_t o20) const KLEIDICV_STREAMING {
397 85536 return Offsets{o0, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10,
398 42768 o11, o12, o13, o14, o15, o16, o17, o18, o19, o20};
399 }
400
401 size_t width_;
402 FixedBorderType border_type_;
403 }; // end of class FixedBorderInfo<T, 21UL>
404
405 // Shorthand for 21x21 filter border type.
406 template <typename T>
407 using FixedBorderInfo21x21 = FixedBorderInfo<T, 21UL>;
408
409 } // namespace KLEIDICV_TARGET_NAMESPACE
410
411 #endif // KLEIDICV_WORKSPACE_BORDER_21X21_H
412