GCC Code Coverage Report


Directory: ./
File: tasks/terekhov_d_seq_gauss_vert/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 59 60 98.3%
Functions: 8 8 100.0%
Branches: 29 38 76.3%

Line Branch Exec Source
1 #include "terekhov_d_seq_gauss_vert/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <vector>
7
8 #include "terekhov_d_seq_gauss_vert/common/include/common.hpp"
9
10 namespace terekhov_d_seq_gauss_vert {
11
12
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 TerekhovDGaussVertSEQ::TerekhovDGaussVertSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 24 }
16
17 24 bool TerekhovDGaussVertSEQ::ValidationImpl() {
18 const auto &input = GetInput();
19
20
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (input.width <= 0 || input.height <= 0) {
21 return false;
22 }
23
24
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (static_cast<int>(input.data.size()) != input.width * input.height) {
25 return false;
26 }
27
28 return true;
29 }
30
31 24 bool TerekhovDGaussVertSEQ::PreProcessingImpl() {
32 const auto &input = GetInput();
33 24 width_ = input.width;
34 24 height_ = input.height;
35
36 24 GetOutput().width = width_;
37 24 GetOutput().height = height_;
38 24 GetOutput().data.resize(static_cast<size_t>(width_) * static_cast<size_t>(height_));
39
40 24 int padded_width = width_ + 2;
41 24 int padded_height = height_ + 2;
42 24 padded_image_.resize(static_cast<size_t>(padded_width) * static_cast<size_t>(padded_height));
43
44
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 24 times.
488 for (int row = 0; row < padded_height; ++row) {
45
2/2
✓ Branch 0 taken 12128 times.
✓ Branch 1 taken 464 times.
12592 for (int col = 0; col < padded_width; ++col) {
46 12128 int src_x = col - 1;
47 12128 int src_y = row - 1;
48
49 12128 if (src_x < 0) {
50 src_x = -src_x - 1;
51 }
52
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 11664 times.
12128 if (src_x >= width_) {
53 464 src_x = (2 * width_) - src_x - 1;
54 }
55 12128 if (src_y < 0) {
56 src_y = -src_y - 1;
57 }
58
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 11664 times.
12128 if (src_y >= height_) {
59 464 src_y = (2 * height_) - src_y - 1;
60 }
61
62 12128 size_t padded_idx = (static_cast<size_t>(row) * static_cast<size_t>(padded_width)) + static_cast<size_t>(col);
63 12128 size_t src_idx = (static_cast<size_t>(src_y) * static_cast<size_t>(width_)) + static_cast<size_t>(src_x);
64 12128 padded_image_[padded_idx] = input.data[src_idx];
65 }
66 }
67
68 24 return true;
69 }
70
71 10368 void TerekhovDGaussVertSEQ::ProcessPixel(OutType &output, int padded_width, int row, int col) {
72 10368 size_t idx = (static_cast<size_t>(row) * static_cast<size_t>(width_)) + static_cast<size_t>(col);
73
74 float sum = 0.0F;
75
76
2/2
✓ Branch 0 taken 31104 times.
✓ Branch 1 taken 10368 times.
41472 for (int ky = -1; ky <= 1; ++ky) {
77
2/2
✓ Branch 0 taken 93312 times.
✓ Branch 1 taken 31104 times.
124416 for (int kx = -1; kx <= 1; ++kx) {
78 93312 int px = col + kx + 1;
79 93312 int py = row + ky + 1;
80
81 93312 int kernel_idx = ((ky + 1) * 3) + (kx + 1);
82 93312 size_t padded_idx = (static_cast<size_t>(py) * static_cast<size_t>(padded_width)) + static_cast<size_t>(px);
83 93312 int pixel_value = padded_image_[padded_idx];
84
85 93312 sum += static_cast<float>(pixel_value) * kGaussKernel[static_cast<size_t>(kernel_idx)];
86 }
87 }
88
89 10368 output.data[idx] = static_cast<int>(std::lround(sum));
90 10368 }
91
92 96 void TerekhovDGaussVertSEQ::ProcessBand(OutType &output, int padded_width, int band, int band_width) {
93 96 int start_x = band * band_width;
94
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 72 times.
96 int end_x = (band == kNumBands - 1) ? width_ : ((band + 1) * band_width);
95
96
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 96 times.
1760 for (int row = 0; row < height_; ++row) {
97
2/2
✓ Branch 0 taken 10368 times.
✓ Branch 1 taken 1664 times.
12032 for (int col = start_x; col < end_x; ++col) {
98 10368 ProcessPixel(output, padded_width, row, col);
99 }
100 }
101 96 }
102
103 24 void TerekhovDGaussVertSEQ::ProcessBands(OutType &output) {
104 24 int padded_width = width_ + 2;
105
106
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int band_width = width_ / kNumBands;
107 band_width = std::max(band_width, 1);
108
109
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for (int band = 0; band < kNumBands; ++band) {
110 96 ProcessBand(output, padded_width, band, band_width);
111 }
112 24 }
113
114
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 bool TerekhovDGaussVertSEQ::RunImpl() {
115 const auto &input = GetInput();
116 auto &output = GetOutput();
117
118
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
24 if (input.data.empty() || width_ <= 0 || height_ <= 0) {
119 return false;
120 }
121
122 24 ProcessBands(output); // 1
123 24 return true;
124 }
125
126 24 bool TerekhovDGaussVertSEQ::PostProcessingImpl() {
127 24 return GetOutput().data.size() == (static_cast<size_t>(GetOutput().width) * static_cast<size_t>(GetOutput().height));
128 }
129
130 } // namespace terekhov_d_seq_gauss_vert
131