GCC Code Coverage Report


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

Line Branch Exec Source
1 #include "romanov_a_gauss_block/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 #include <tuple>
8 #include <vector>
9
10 #include "romanov_a_gauss_block/common/include/common.hpp"
11
12 namespace romanov_a_gauss_block {
13
14
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 RomanovAGaussBlockSEQ::RomanovAGaussBlockSEQ(const InType &in) {
15 SetTypeOfTask(GetStaticTypeOfTask());
16 GetInput() = in;
17 64 GetOutput() = std::vector<uint8_t>();
18 64 }
19
20 64 bool RomanovAGaussBlockSEQ::ValidationImpl() {
21 64 return std::get<0>(GetInput()) * std::get<1>(GetInput()) * 3 == static_cast<int>(std::get<2>(GetInput()).size());
22 }
23
24 64 bool RomanovAGaussBlockSEQ::PreProcessingImpl() {
25 64 return true;
26 }
27
28 namespace {
29 240672 int ApplyKernel(const std::vector<uint8_t> &img, int row, int col, int channel, int width, int height,
30 const std::array<std::array<int, 3>, 3> &kernel) {
31 int sum = 0;
32
2/2
✓ Branch 0 taken 722016 times.
✓ Branch 1 taken 240672 times.
962688 for (size_t kr = 0; kr < 3; ++kr) {
33
2/2
✓ Branch 0 taken 2166048 times.
✓ Branch 1 taken 722016 times.
2888064 for (size_t kc = 0; kc < 3; ++kc) {
34 2166048 int nr = row + static_cast<int>(kr) - 1;
35 2166048 int nc = col + static_cast<int>(kc) - 1;
36
4/4
✓ Branch 0 taken 2149488 times.
✓ Branch 1 taken 16560 times.
✓ Branch 2 taken 2133984 times.
✓ Branch 3 taken 15504 times.
2166048 if (nr >= 0 && nr < height && nc >= 0 && nc < width) {
37 2133984 size_t idx = (((static_cast<size_t>(nr) * width) + nc) * 3) + channel;
38 2133984 sum += (static_cast<int>(img[idx]) * kernel.at(kr).at(kc));
39 }
40 }
41 }
42 240672 return sum;
43 }
44 } // namespace
45
46 64 bool RomanovAGaussBlockSEQ::RunImpl() {
47 64 const int width = std::get<0>(GetInput());
48 64 const int height = std::get<1>(GetInput());
49
50 64 const std::vector<uint8_t> initial_picture = std::get<2>(GetInput());
51
1/4
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
64 std::vector<uint8_t> result_picture(static_cast<size_t>(height * width * 3));
52
53 64 const std::array<std::array<int, 3>, 3> kernel = {{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}};
54
55
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 64 times.
968 for (int row = 0; row < height; ++row) {
56
2/2
✓ Branch 0 taken 80224 times.
✓ Branch 1 taken 904 times.
81128 for (int col = 0; col < width; ++col) {
57
2/2
✓ Branch 0 taken 240672 times.
✓ Branch 1 taken 80224 times.
320896 for (int channel = 0; channel < 3; ++channel) {
58 240672 int sum = ApplyKernel(initial_picture, row, col, channel, width, height, kernel);
59
1/2
✓ Branch 0 taken 240672 times.
✗ Branch 1 not taken.
240672 int result_value = (sum + 8) / 16;
60 result_value = std::clamp(result_value, 0, 255);
61 240672 auto idx = ((static_cast<size_t>(row) * width + col) * 3) + channel;
62 240672 result_picture[idx] = static_cast<uint8_t>(result_value);
63 }
64 }
65 }
66
67
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 GetOutput() = result_picture;
68 64 return true;
69 }
70
71 64 bool RomanovAGaussBlockSEQ::PostProcessingImpl() {
72 64 return true;
73 }
74
75 } // namespace romanov_a_gauss_block
76