GCC Code Coverage Report


Directory: ./
File: tasks/vdovin_a_gauss_block/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 39 40 97.5%
Functions: 6 6 100.0%
Branches: 27 34 79.4%

Line Branch Exec Source
1 #include "vdovin_a_gauss_block/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstdint>
6 #include <vector>
7
8 #include "vdovin_a_gauss_block/common/include/common.hpp"
9
10 namespace vdovin_a_gauss_block {
11
12 namespace {
13 constexpr int kChannels = 3;
14 constexpr int kKernelSize = 3;
15 constexpr int kKernelSum = 16;
16 constexpr std::array<std::array<int, kKernelSize>, kKernelSize> kKernel = {{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}};
17 } // namespace
18
19 80 VdovinAGaussBlockSEQ::VdovinAGaussBlockSEQ(const InType &in) {
20 SetTypeOfTask(GetStaticTypeOfTask());
21 80 GetInput() = in;
22 GetOutput() = 0;
23 80 }
24
25 80 bool VdovinAGaussBlockSEQ::ValidationImpl() {
26 80 return GetInput() >= 3;
27 }
28
29 80 bool VdovinAGaussBlockSEQ::PreProcessingImpl() {
30 80 width_ = GetInput();
31 80 height_ = GetInput();
32
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (width_ < 3 || height_ < 3) {
33 input_image_.clear();
34 output_image_.clear();
35 return false;
36 }
37 80 int total = width_ * height_ * kChannels;
38 80 input_image_.assign(total, 100);
39 80 output_image_.assign(total, 0);
40 80 return true;
41 }
42
43 105592 void VdovinAGaussBlockSEQ::ApplyGaussianToPixel(int py, int px) {
44
2/2
✓ Branch 0 taken 316776 times.
✓ Branch 1 taken 105592 times.
422368 for (int ch = 0; ch < kChannels; ch++) {
45 int sum = 0;
46
2/2
✓ Branch 0 taken 950328 times.
✓ Branch 1 taken 316776 times.
1267104 for (int ky = -1; ky <= 1; ky++) {
47
2/2
✓ Branch 0 taken 2850984 times.
✓ Branch 1 taken 950328 times.
3801312 for (int kx = -1; kx <= 1; kx++) {
48 2850984 int ny = std::clamp(py + ky, 0, height_ - 1);
49 2850984 int nx = std::clamp(px + kx, 0, width_ - 1);
50 2850984 sum += input_image_[(((ny * width_) + nx) * kChannels) + ch] * kKernel.at(ky + 1).at(kx + 1);
51 }
52 }
53
1/2
✓ Branch 0 taken 316776 times.
✗ Branch 1 not taken.
633552 output_image_[(((py * width_) + px) * kChannels) + ch] = static_cast<uint8_t>(std::clamp(sum / kKernelSum, 0, 255));
54 }
55 105592 }
56
57
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 bool VdovinAGaussBlockSEQ::RunImpl() {
58
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if (input_image_.empty() || output_image_.empty()) {
59 return false;
60 }
61
62
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
80 int block_height = std::max(1, height_ / 4);
63
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
80 int block_width = std::max(1, width_ / 4);
64
65
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 80 times.
456 for (int block_y = 0; block_y < height_; block_y += block_height) {
66
2/2
✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 376 times.
2240 for (int block_x = 0; block_x < width_; block_x += block_width) {
67 1864 int y_end = std::min(block_y + block_height, height_);
68 1864 int x_end = std::min(block_x + block_width, width_);
69
2/2
✓ Branch 0 taken 7576 times.
✓ Branch 1 taken 1864 times.
9440 for (int py = block_y; py < y_end; py++) {
70
2/2
✓ Branch 0 taken 105592 times.
✓ Branch 1 taken 7576 times.
113168 for (int px = block_x; px < x_end; px++) {
71 105592 ApplyGaussianToPixel(py, px);
72 }
73 }
74 }
75 }
76
77 return true;
78 }
79
80
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 bool VdovinAGaussBlockSEQ::PostProcessingImpl() {
81
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if (output_image_.empty()) {
82 return false;
83 }
84 auto total = static_cast<int64_t>(output_image_.size());
85 if (total == 0) {
86 return false;
87 }
88 int64_t sum = 0;
89
2/2
✓ Branch 0 taken 316776 times.
✓ Branch 1 taken 80 times.
316856 for (int64_t idx = 0; idx < total; idx++) {
90 316776 sum += output_image_[idx];
91 }
92 80 GetOutput() = static_cast<int>(sum / total);
93 80 return true;
94 }
95
96 } // namespace vdovin_a_gauss_block
97