GCC Code Coverage Report


Directory: ./
File: tasks/smyshlaev_a_gauss_filt/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 5 5 100.0%
Branches: 15 20 75.0%

Line Branch Exec Source
1 #include "smyshlaev_a_gauss_filt/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cstddef>
5 #include <cstdint>
6 #include <vector>
7
8 #include "smyshlaev_a_gauss_filt/common/include/common.hpp"
9
10 namespace smyshlaev_a_gauss_filt {
11
12 namespace {
13 int GetPixelClamped(const InType &img, int x, int y, int ch) {
14 2649348 const int w = img.width;
15 2649348 const int h = img.height;
16 2649348 const int c = img.channels;
17
18 2649348 x = std::clamp(x, 0, w - 1);
19 2649348 y = std::clamp(y, 0, h - 1);
20
21 2649348 return img.data[(((y * w) + x) * c) + ch];
22 }
23 } // namespace
24
25
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
144 SmyshlaevAGaussFiltSEQ::SmyshlaevAGaussFiltSEQ(const InType &in) {
26 SetTypeOfTask(GetStaticTypeOfTask());
27 GetInput() = in;
28 144 }
29
30 144 bool SmyshlaevAGaussFiltSEQ::ValidationImpl() {
31
4/8
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 144 times.
144 return GetInput().width > 0 && GetInput().height > 0 && GetInput().channels > 0 && !GetInput().data.empty();
32 }
33
34 144 bool SmyshlaevAGaussFiltSEQ::PreProcessingImpl() {
35 144 return true;
36 }
37
38 144 bool SmyshlaevAGaussFiltSEQ::RunImpl() {
39 const auto &input_image = GetInput();
40 auto &output_image = GetOutput();
41
42 144 output_image.width = input_image.width;
43 144 output_image.height = input_image.height;
44 144 output_image.channels = input_image.channels;
45
46 const int w = input_image.width;
47 const int h = input_image.height;
48 const int c = input_image.channels;
49
50 144 output_image.data.resize(static_cast<size_t>(w) * h * c);
51
52 144 const std::vector<int> kernel = {1, 2, 1, 2, 4, 2, 1, 2, 1};
53 const int kernel_sum = 16;
54
55
2/2
✓ Branch 0 taken 3816 times.
✓ Branch 1 taken 144 times.
3960 for (int dy = 0; dy < h; ++dy) {
56
2/2
✓ Branch 0 taken 113868 times.
✓ Branch 1 taken 3816 times.
117684 for (int dx = 0; dx < w; ++dx) {
57
2/2
✓ Branch 0 taken 294372 times.
✓ Branch 1 taken 113868 times.
408240 for (int ch = 0; ch < c; ++ch) {
58 int sum = 0;
59
2/2
✓ Branch 0 taken 883116 times.
✓ Branch 1 taken 294372 times.
1177488 for (int ky = -1; ky <= 1; ++ky) {
60
2/2
✓ Branch 0 taken 2649348 times.
✓ Branch 1 taken 883116 times.
3532464 for (int kx = -1; kx <= 1; ++kx) {
61 2649348 int idx = dx + kx;
62 2649348 int idy = dy + ky;
63
64 int value = GetPixelClamped(input_image, idx, idy, ch);
65 2649348 int k_value = kernel[((ky + 1) * 3) + (kx + 1)];
66 2649348 sum += value * k_value;
67 }
68 }
69
70 294372 output_image.data[(((dy * w) + dx) * c) + ch] = static_cast<uint8_t>(sum / kernel_sum);
71 }
72 }
73 }
74
75 144 return true;
76 }
77
78 144 bool SmyshlaevAGaussFiltSEQ::PostProcessingImpl() {
79 144 return true;
80 }
81
82 } // namespace smyshlaev_a_gauss_filt
83