GCC Code Coverage Report


Directory: ./
File: tasks/melnik_i_gauss_block_part/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 24 25 96.0%
Functions: 5 6 83.3%
Branches: 9 10 90.0%

Line Branch Exec Source
1 #include "melnik_i_gauss_block_part/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 #include <vector>
8
9 #include "melnik_i_gauss_block_part/common/include/common.hpp"
10
11 namespace melnik_i_gauss_block_part {
12
13 namespace {
14
15 inline int ClampInt(int v, int lo, int hi) {
16 return std::max(lo, std::min(v, hi));
17 }
18
19 } // namespace
20
21
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 MelnikIGaussBlockPartSEQ::MelnikIGaussBlockPartSEQ(const InType &in) {
22 SetTypeOfTask(GetStaticTypeOfTask());
23 GetInput() = in;
24 GetOutput().clear();
25 72 }
26
27 72 bool MelnikIGaussBlockPartSEQ::ValidationImpl() {
28 const auto &[data, width, height] = GetInput();
29
30 72 const std::size_t expected = static_cast<std::size_t>(width) * static_cast<std::size_t>(height);
31 72 return data.size() == expected;
32 }
33
34 72 bool MelnikIGaussBlockPartSEQ::PreProcessingImpl() {
35 const auto &[data, width, height] = GetInput();
36
37 (void)data;
38 72 GetOutput().assign(static_cast<std::size_t>(width) * static_cast<std::size_t>(height), 0);
39 72 return true;
40 }
41
42 72 bool MelnikIGaussBlockPartSEQ::RunImpl() {
43 const auto &[data, width, height] = GetInput();
44
45 static constexpr std::array<int, 9> kKernel = {1, 2, 1, 2, 4, 2, 1, 2, 1};
46 static constexpr int kSum = 16;
47
48 auto &out = GetOutput();
49 72 out.resize(static_cast<std::size_t>(width) * static_cast<std::size_t>(height));
50
51
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 72 times.
368 for (int yy = 0; yy < height; ++yy) {
52
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 296 times.
1520 for (int xx = 0; xx < width; ++xx) {
53 int acc = 0;
54 std::size_t kernel_idx = 0;
55
2/2
✓ Branch 0 taken 3672 times.
✓ Branch 1 taken 1224 times.
4896 for (int dy = -1; dy <= 1; ++dy) {
56
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 3672 times.
14688 for (int dx = -1; dx <= 1; ++dx) {
57 11016 acc += kKernel.at(kernel_idx) * GetPixelClamped(data, width, height, xx + dx, yy + dy);
58 11016 ++kernel_idx;
59 }
60 }
61 1224 out[(static_cast<std::size_t>(yy) * static_cast<std::size_t>(width)) + static_cast<std::size_t>(xx)] =
62 1224 (acc + kSum / 2) / kSum;
63 }
64 }
65 72 return true;
66 }
67
68 72 bool MelnikIGaussBlockPartSEQ::PostProcessingImpl() {
69 72 return true;
70 }
71
72 std::uint8_t MelnikIGaussBlockPartSEQ::GetPixelClamped(const std::vector<std::uint8_t> &data, int width, int height,
73 int x, int y) {
74 11016 const int xx = ClampInt(x, 0, width - 1);
75 11016 const int yy = ClampInt(y, 0, height - 1);
76 11016 return data[(static_cast<std::size_t>(yy) * static_cast<std::size_t>(width)) + static_cast<std::size_t>(xx)];
77 }
78
79 } // namespace melnik_i_gauss_block_part
80