GCC Code Coverage Report


Directory: ./
File: tasks/fedoseev_linear_image_filtering_vertical/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 29 30 96.7%
Functions: 5 5 100.0%
Branches: 14 22 63.6%

Line Branch Exec Source
1 #include "fedoseev_linear_image_filtering_vertical/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstddef>
6 #include <vector>
7
8 #include "fedoseev_linear_image_filtering_vertical/common/include/common.hpp"
9
10 namespace fedoseev_linear_image_filtering_vertical {
11
12
1/2
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
160 LinearImageFilteringVerticalSeq::LinearImageFilteringVerticalSeq(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 160 GetOutput() = InType{};
16 160 }
17
18 160 bool LinearImageFilteringVerticalSeq::ValidationImpl() {
19 const InType &input = GetInput();
20
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if (input.width < 3 || input.height < 3) {
21 return false;
22 }
23
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if (input.data.size() != static_cast<size_t>(input.width) * static_cast<size_t>(input.height)) {
24 return false;
25 }
26 return true;
27 }
28
29 160 bool LinearImageFilteringVerticalSeq::PreProcessingImpl() {
30 const InType &input = GetInput();
31 160 OutType output;
32 160 output.width = input.width;
33 160 output.height = input.height;
34
2/6
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 160 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160 output.data.resize(static_cast<size_t>(input.width) * static_cast<size_t>(input.height), 0);
35 GetOutput() = output;
36 160 return true;
37 }
38
39 160 bool LinearImageFilteringVerticalSeq::RunImpl() {
40 const InType &input = GetInput();
41 OutType &output = GetOutput();
42
43 160 int w = input.width;
44 160 int h = input.height;
45 160 const std::vector<int> &src = input.data;
46 std::vector<int> &dst = output.data;
47
48 160 const std::array<std::array<int, 3>, 3> kernel = {{{{1, 2, 1}}, {{2, 4, 2}}, {{1, 2, 1}}}};
49 const int kernel_sum = 16;
50
51 auto get_pixel = [&](int col, int row) -> int {
52 126432 col = std::clamp(col, 0, w - 1);
53 126432 row = std::clamp(row, 0, h - 1);
54 126432 return src[(static_cast<size_t>(row) * static_cast<size_t>(w)) + static_cast<size_t>(col)];
55 };
56
57
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 160 times.
1472 for (int row = 0; row < h; ++row) {
58
2/2
✓ Branch 0 taken 14048 times.
✓ Branch 1 taken 1312 times.
15360 for (int col = 0; col < w; ++col) {
59 int sum = 0;
60
2/2
✓ Branch 0 taken 42144 times.
✓ Branch 1 taken 14048 times.
56192 for (int ky = -1; ky <= 1; ++ky) {
61
2/2
✓ Branch 0 taken 126432 times.
✓ Branch 1 taken 42144 times.
168576 for (int kx = -1; kx <= 1; ++kx) {
62 126432 sum += get_pixel(col + kx, row + ky) * kernel.at(ky + 1).at(kx + 1);
63 }
64 }
65 14048 dst[(static_cast<size_t>(row) * static_cast<size_t>(w)) + static_cast<size_t>(col)] = sum / kernel_sum;
66 }
67 }
68
69 160 return true;
70 }
71
72 160 bool LinearImageFilteringVerticalSeq::PostProcessingImpl() {
73 160 return true;
74 }
75
76 } // namespace fedoseev_linear_image_filtering_vertical
77