| 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 | 57024 | 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 | 627264 | : offsets_{o0, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, | |
| 34 | 627264 | o11, o12, o13, o14, o15, o16, o17, o18, o19, o20} {} | |
| 35 | |||
| 36 | 100720 | ptrdiff_t c0() const { return offsets_[0]; } | |
| 37 | 100720 | ptrdiff_t c1() const { return offsets_[1]; } | |
| 38 | 100720 | ptrdiff_t c2() const { return offsets_[2]; } | |
| 39 | 100720 | ptrdiff_t c3() const { return offsets_[3]; } | |
| 40 | 100720 | ptrdiff_t c4() const { return offsets_[4]; } | |
| 41 | 100720 | ptrdiff_t c5() const { return offsets_[5]; } | |
| 42 | 100720 | ptrdiff_t c6() const { return offsets_[6]; } | |
| 43 | 100720 | ptrdiff_t c7() const { return offsets_[7]; } | |
| 44 | 100720 | ptrdiff_t c8() const { return offsets_[8]; } | |
| 45 | 100720 | ptrdiff_t c9() const { return offsets_[9]; } | |
| 46 | 100720 | ptrdiff_t c10() const { return offsets_[10]; } | |
| 47 | 100720 | ptrdiff_t c11() const { return offsets_[11]; } | |
| 48 | 100720 | ptrdiff_t c12() const { return offsets_[12]; } | |
| 49 | 100720 | ptrdiff_t c13() const { return offsets_[13]; } | |
| 50 | 100720 | ptrdiff_t c14() const { return offsets_[14]; } | |
| 51 | 100720 | ptrdiff_t c15() const { return offsets_[15]; } | |
| 52 | 100720 | ptrdiff_t c16() const { return offsets_[16]; } | |
| 53 | 100720 | ptrdiff_t c17() const { return offsets_[17]; } | |
| 54 | 100720 | ptrdiff_t c18() const { return offsets_[18]; } | |
| 55 | 100720 | ptrdiff_t c19() const { return offsets_[19]; } | |
| 56 | 100720 | ptrdiff_t c20() const { return offsets_[20]; } | |
| 57 | |||
| 58 | private: | ||
| 59 | ptrdiff_t offsets_[21]; | ||
| 60 | }; | ||
| 61 | |||
| 62 | 256 | FixedBorderInfo(size_t width, FixedBorderType border_type) | |
| 63 | 256 | : width_(width), border_type_(border_type) {} | |
| 64 | |||
| 65 | // Returns offsets without the influence of any border. | ||
| 66 | 2624 | Offsets offsets_without_border() const KLEIDICV_STREAMING { | |
| 67 | 2624 | 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 | 27200 | Offsets offsets_with_left_border(size_t column_index) const | |
| 74 | KLEIDICV_STREAMING { | ||
| 75 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 6800 times.
✓ Branch 2 taken 6800 times.
✓ Branch 3 taken 6800 times.
✓ Branch 4 taken 6800 times.
|
27200 | switch (border_type_) { |
| 76 | case FixedBorderType::REPLICATE: | ||
| 77 |
2/2✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 680 times.
|
6800 | if (column_index == 0) { |
| 78 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == 1) { |
| 81 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == 2) { |
| 84 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == 3) { |
| 87 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == 4) { |
| 90 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == 5) { |
| 93 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == 6) { |
| 96 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == 7) { |
| 99 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == 8) { |
| 102 | 680 | 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 | 680 | 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 6120 times.
✓ Branch 1 taken 680 times.
|
6800 | if (column_index == 0) { |
| 112 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == 1) { |
| 115 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == 2) { |
| 118 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == 3) { |
| 121 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == 4) { |
| 124 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == 5) { |
| 127 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == 6) { |
| 130 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == 7) { |
| 133 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == 8) { |
| 136 | 680 | 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 | 680 | 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 6120 times.
✓ Branch 1 taken 680 times.
|
6800 | if (column_index == 0) { |
| 146 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 147 | 680 | width_ - 6, width_ - 5, width_ - 4, width_ - 3, width_ - 2, | |
| 148 | 680 | width_ - 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); | |
| 149 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == 1) { |
| 150 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 151 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == 2) { |
| 154 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 155 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == 3) { |
| 158 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 159 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == 4) { |
| 162 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 163 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == 5) { |
| 166 | 1360 | return get(width_ - 10, width_ - 9, width_ - 8, width_ - 7, | |
| 167 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == 6) { |
| 170 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == 7) { |
| 173 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == 8) { |
| 176 | 680 | 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 | 680 | 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 6120 times.
✓ Branch 1 taken 680 times.
|
6800 | if (column_index == 0) { |
| 186 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == 1) { |
| 189 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == 2) { |
| 192 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == 3) { |
| 195 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == 4) { |
| 198 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == 5) { |
| 201 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == 6) { |
| 204 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == 7) { |
| 207 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == 8) { |
| 210 | 680 | 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 | 680 | 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 | 27200 | } | |
| 222 | |||
| 223 | // Returns offsets for columns affected by right border. | ||
| 224 | 27200 | Offsets offsets_with_right_border(size_t column_index) const | |
| 225 | KLEIDICV_STREAMING { | ||
| 226 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 6800 times.
✓ Branch 2 taken 6800 times.
✓ Branch 3 taken 6800 times.
✓ Branch 4 taken 6800 times.
|
27200 | switch (border_type_) { |
| 227 | case FixedBorderType::REPLICATE: | ||
| 228 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 6120 times.
|
6800 | if (column_index == (width_ - 10)) { |
| 229 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == (width_ - 9)) { |
| 232 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == (width_ - 8)) { |
| 235 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == (width_ - 7)) { |
| 238 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == (width_ - 6)) { |
| 241 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == (width_ - 5)) { |
| 244 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == (width_ - 4)) { |
| 247 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == (width_ - 3)) { |
| 250 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == (width_ - 2)) { |
| 253 | 680 | 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 | 680 | 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 680 times.
✓ Branch 1 taken 6120 times.
|
6800 | if (column_index == (width_ - 10)) { |
| 263 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == (width_ - 9)) { |
| 266 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == (width_ - 8)) { |
| 269 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == (width_ - 7)) { |
| 272 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == (width_ - 6)) { |
| 275 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == (width_ - 5)) { |
| 278 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == (width_ - 4)) { |
| 281 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == (width_ - 3)) { |
| 284 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == (width_ - 2)) { |
| 287 | 680 | 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 | 680 | 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 680 times.
✓ Branch 1 taken 6120 times.
|
6800 | if (column_index == (width_ - 10)) { |
| 297 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, | |
| 298 | 680 | 6, 7, 8, 9, 10 - width_); | |
| 299 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == (width_ - 9)) { |
| 300 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, | |
| 301 | 680 | 6, 7, 8, 9 - width_, 10 - width_); | |
| 302 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == (width_ - 8)) { |
| 303 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, | |
| 304 | 680 | 6, 7, 8 - width_, 9 - width_, 10 - width_); | |
| 305 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == (width_ - 7)) { |
| 306 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, | |
| 307 | 680 | 6, 7 - width_, 8 - width_, 9 - width_, 10 - width_); | |
| 308 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == (width_ - 6)) { |
| 309 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, | |
| 310 | 680 | 6 - width_, 7 - width_, 8 - width_, 9 - width_, | |
| 311 | 680 | 10 - width_); | |
| 312 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == (width_ - 5)) { |
| 313 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, | |
| 314 | 680 | 5 - width_, 6 - width_, 7 - width_, 8 - width_, 9 - width_, | |
| 315 | 680 | 10 - width_); | |
| 316 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == (width_ - 4)) { |
| 317 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, | |
| 318 | 680 | 4 - width_, 5 - width_, 6 - width_, 7 - width_, 8 - width_, | |
| 319 | 680 | 9 - width_, 10 - width_); | |
| 320 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == (width_ - 3)) { |
| 321 | 680 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, | |
| 322 | 680 | 3 - width_, 4 - width_, 5 - width_, 6 - width_, 7 - width_, | |
| 323 | 680 | 8 - width_, 9 - width_, 10 - width_); | |
| 324 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == (width_ - 2)) { |
| 325 | 1360 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2 - width_, | |
| 326 | 680 | 3 - width_, 4 - width_, 5 - width_, 6 - width_, 7 - width_, | |
| 327 | 680 | 8 - width_, 9 - width_, 10 - width_); | |
| 328 | } else { | ||
| 329 | 1360 | return get(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1 - width_, | |
| 330 | 680 | 2 - width_, 3 - width_, 4 - width_, 5 - width_, 6 - width_, | |
| 331 | 680 | 7 - width_, 8 - width_, 9 - width_, 10 - width_); | |
| 332 | } | ||
| 333 | break; | ||
| 334 | |||
| 335 | case FixedBorderType::REVERSE: | ||
| 336 |
2/2✓ Branch 0 taken 680 times.
✓ Branch 1 taken 6120 times.
|
6800 | if (column_index == (width_ - 10)) { |
| 337 | 680 | 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 680 times.
✓ Branch 1 taken 5440 times.
|
6120 | } else if (column_index == (width_ - 9)) { |
| 340 | 680 | 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 680 times.
✓ Branch 1 taken 4760 times.
|
5440 | } else if (column_index == (width_ - 8)) { |
| 343 | 680 | 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 680 times.
✓ Branch 1 taken 4080 times.
|
4760 | } else if (column_index == (width_ - 7)) { |
| 346 | 680 | 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 680 times.
✓ Branch 1 taken 3400 times.
|
4080 | } else if (column_index == (width_ - 6)) { |
| 349 | 680 | 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 680 times.
✓ Branch 1 taken 2720 times.
|
3400 | } else if (column_index == (width_ - 5)) { |
| 352 | 680 | 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 680 times.
✓ Branch 1 taken 2040 times.
|
2720 | } else if (column_index == (width_ - 4)) { |
| 355 | 680 | 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 680 times.
✓ Branch 1 taken 1360 times.
|
2040 | } else if (column_index == (width_ - 3)) { |
| 358 | 680 | 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 680 times.
✓ Branch 1 taken 680 times.
|
1360 | } else if (column_index == (width_ - 2)) { |
| 361 | 680 | 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 | 680 | 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 | 27200 | } | |
| 373 | // NOLINTEND(readability-function-cognitive-complexity) | ||
| 374 | |||
| 375 | // Returns offsets for rows or columns affected by any border. | ||
| 376 | 2592 | Offsets offsets_with_border(size_t row_or_column_index) const | |
| 377 | KLEIDICV_STREAMING { | ||
| 378 |
2/2✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1312 times.
|
2592 | if (row_or_column_index < 10U) { |
| 379 | // Rows and columns have the same offsets. | ||
| 380 | 1280 | return offsets_with_left_border(row_or_column_index); | |
| 381 | } | ||
| 382 |
2/2✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 32 times.
|
1312 | if (row_or_column_index >= (width_ - 10U)) { |
| 383 | // Rows and columns have the same offsets. | ||
| 384 | 1280 | return offsets_with_right_border(row_or_column_index); | |
| 385 | } | ||
| 386 | 32 | return offsets_without_border(); | |
| 387 | 2592 | } | |
| 388 | |||
| 389 | private: | ||
| 390 | // Takes care of static signed to unsigned casts. | ||
| 391 | 57024 | 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 | 114048 | return Offsets{o0, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, | |
| 398 | 57024 | 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 |