GCC Code Coverage Report


Directory: ./
File: tasks/marin_l_linear_filter_vertical/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 6 6 100.0%
Branches: 16 20 80.0%

Line Branch Exec Source
1 #include "marin_l_linear_filter_vertical/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <array>
5 #include <cstddef>
6 #include <cstdint>
7 #include <vector>
8
9 #include "marin_l_linear_filter_vertical/common/include/common.hpp"
10
11 namespace marin_l_linear_filter_vertical {
12
13 namespace {
14 constexpr std::array<std::array<int, 3>, 3> kGaussKernel = {{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}};
15 constexpr int kKernelSum = 16;
16
17 112112 uint8_t ApplyKernel(const std::vector<uint8_t> &pixels, int width, int height, int row, int col) {
18 int sum = 0;
19
2/2
✓ Branch 0 taken 336336 times.
✓ Branch 1 taken 112112 times.
448448 for (int ky = -1; ky <= 1; ++ky) {
20
2/2
✓ Branch 0 taken 1009008 times.
✓ Branch 1 taken 336336 times.
1345344 for (int kx = -1; kx <= 1; ++kx) {
21 1009008 int ny = row + ky;
22 1009008 int nx = col + kx;
23 uint8_t pixel_value = 0;
24
4/4
✓ Branch 0 taken 996912 times.
✓ Branch 1 taken 12096 times.
✓ Branch 2 taken 985200 times.
✓ Branch 3 taken 11712 times.
1009008 if (ny >= 0 && ny < height && nx >= 0 && nx < width) {
25 985200 pixel_value = pixels[(ny * width) + nx];
26 }
27 1009008 sum += pixel_value * kGaussKernel.at(ky + 1).at(kx + 1);
28 }
29 }
30
1/2
✓ Branch 0 taken 112112 times.
✗ Branch 1 not taken.
112112 return static_cast<uint8_t>(std::clamp(sum / kKernelSum, 0, 255));
31 }
32 } // namespace
33
34
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
96 MarinLLinearFilterVerticalSEQ::MarinLLinearFilterVerticalSEQ(const InType &in) {
35 SetTypeOfTask(GetStaticTypeOfTask());
36 GetInput() = in;
37 GetOutput() = {};
38 96 }
39
40 96 bool MarinLLinearFilterVerticalSEQ::ValidationImpl() {
41 const auto &input = GetInput();
42
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if (input.width <= 0 || input.height <= 0) {
43 return false;
44 }
45 96 auto expected_size = static_cast<size_t>(input.width) * static_cast<size_t>(input.height);
46 96 return input.pixels.size() == expected_size;
47 }
48
49 96 bool MarinLLinearFilterVerticalSEQ::PreProcessingImpl() {
50 const auto &input = GetInput();
51 96 width_ = input.width;
52 96 height_ = input.height;
53 96 input_pixels_ = input.pixels;
54 96 output_pixels_.resize(input_pixels_.size());
55 96 return true;
56 }
57
58 96 bool MarinLLinearFilterVerticalSEQ::RunImpl() {
59
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 96 times.
2112 for (int row = 0; row < height_; ++row) {
60
2/2
✓ Branch 0 taken 112112 times.
✓ Branch 1 taken 2016 times.
114128 for (int col = 0; col < width_; ++col) {
61 112112 output_pixels_[(row * width_) + col] = ApplyKernel(input_pixels_, width_, height_, row, col);
62 }
63 }
64 96 return true;
65 }
66
67 96 bool MarinLLinearFilterVerticalSEQ::PostProcessingImpl() {
68 96 GetOutput() = output_pixels_;
69 96 return true;
70 }
71
72 } // namespace marin_l_linear_filter_vertical
73