GCC Code Coverage Report


Directory: ./
File: tasks/kolotukhin_a_gaussian_blur/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 6 6 100.0%
Branches: 17 18 94.4%

Line Branch Exec Source
1 #include "kolotukhin_a_gaussian_blur/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 #include <vector>
8
9 #include "kolotukhin_a_gaussian_blur/common/include/common.hpp"
10
11 namespace kolotukhin_a_gaussian_blur {
12
13
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
32 KolotukhinAGaussinBlureSEQ::KolotukhinAGaussinBlureSEQ(const InType &in) {
14 SetTypeOfTask(GetStaticTypeOfTask());
15 GetInput() = in;
16 GetOutput().clear();
17 32 }
18
19 32 bool KolotukhinAGaussinBlureSEQ::ValidationImpl() {
20 const auto &pixel_data = get<0>(GetInput());
21 32 const auto img_width = get<1>(GetInput());
22 32 const auto img_height = get<2>(GetInput());
23
24 32 return static_cast<std::size_t>(img_height) * static_cast<std::size_t>(img_width) == pixel_data.size();
25 }
26
27 32 bool KolotukhinAGaussinBlureSEQ::PreProcessingImpl() {
28 32 const auto img_width = get<1>(GetInput());
29 32 const auto img_height = get<2>(GetInput());
30
31 32 GetOutput().assign(static_cast<std::size_t>(img_height) * static_cast<std::size_t>(img_width), 0);
32 32 return true;
33 }
34
35 32 bool KolotukhinAGaussinBlureSEQ::RunImpl() {
36 const auto &pixel_data = get<0>(GetInput());
37 32 const auto img_width = get<1>(GetInput());
38 32 const auto img_height = get<2>(GetInput());
39
40 const static std::array<std::array<int, 3>, 3> kKernel = {{{{1, 2, 1}}, {{2, 4, 2}}, {{1, 2, 1}}}};
41 const static int kSum = 16;
42
43 auto &output = GetOutput();
44
45
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 32 times.
128 for (int row = 0; row < img_height; row++) {
46
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 96 times.
408 for (int col = 0; col < img_width; col++) {
47 int acc = 0;
48
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 312 times.
1248 for (int dy = -1; dy <= 1; dy++) {
49
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 936 times.
3744 for (int dx = -1; dx <= 1; dx++) {
50 2808 std::uint8_t pixel = GetPixel(pixel_data, img_width, img_height, col + dx, row + dy);
51 2808 acc += kKernel.at(1 + dy).at(1 + dx) * static_cast<int>(pixel);
52 }
53 }
54 312 output[(static_cast<std::size_t>(row) * static_cast<std::size_t>(img_width)) + static_cast<std::size_t>(col)] =
55 312 static_cast<std::uint8_t>(acc / kSum);
56 }
57 }
58 32 return true;
59 }
60
61 2808 std::uint8_t KolotukhinAGaussinBlureSEQ::GetPixel(const std::vector<std::uint8_t> &pixel_data, int img_width,
62 int img_height, int pos_x, int pos_y) {
63
4/4
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 1944 times.
✓ Branch 3 taken 864 times.
3096 std::size_t x = static_cast<std::size_t>(std::max(0, std::min(pos_x, img_width - 1)));
64
4/4
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 2496 times.
✓ Branch 2 taken 1872 times.
✓ Branch 3 taken 936 times.
3120 std::size_t y = static_cast<std::size_t>(std::max(0, std::min(pos_y, img_height - 1)));
65 2808 return pixel_data[(y * static_cast<std::size_t>(img_width)) + x];
66 }
67
68 32 bool KolotukhinAGaussinBlureSEQ::PostProcessingImpl() {
69 32 return true;
70 }
71
72 } // namespace kolotukhin_a_gaussian_blur
73