GCC Code Coverage Report


Directory: ./
File: tasks/chaschin_vladimir_linear_image_filtration_seq/tbb/src/ops_tbb.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 38 38 100.0%
Functions: 9 9 100.0%
Branches: 18 24 75.0%

Line Branch Exec Source
1 #include "chaschin_vladimir_linear_image_filtration_seq/tbb/include/ops_tbb.hpp"
2
3 #include <tbb/tbb.h>
4
5 #include <cstddef>
6 #include <utility>
7 #include <vector>
8
9 #include "chaschin_vladimir_linear_image_filtration_seq/common/include/common.hpp"
10
11 namespace chaschin_v_linear_image_filtration_tbb {
12
13
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 ChaschinVLinearFiltrationTBB::ChaschinVLinearFiltrationTBB(const chaschin_v_linear_image_filtration_seq::InType &in) {
14 SetTypeOfTask(GetStaticTypeOfTask());
15 auto in_copy = in;
16 GetInput() = std::move(in_copy);
17 this->GetOutput().clear();
18 20 }
19
20 20 bool ChaschinVLinearFiltrationTBB::ValidationImpl() {
21 const auto &in = GetInput();
22 const auto &image = std::get<0>(in);
23 20 return !image.empty();
24 }
25
26 20 bool ChaschinVLinearFiltrationTBB::PreProcessingImpl() {
27 20 return true;
28 }
29
30 19840 inline float HorizontalFilterAtTBB(const std::vector<float> &img, int n, int x, int y) {
31 19840 const int idx = (y * n) + x;
32
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 19360 times.
19840 if (x == 0) {
33 480 return ((2.F * img[idx]) + img[idx + 1]) / 3.F;
34 }
35
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18880 times.
19360 if (x == n - 1) {
36 480 return (img[idx - 1] + (2.F * img[idx])) / 3.F;
37 }
38 18880 return (img[idx - 1] + (2.F * img[idx]) + img[idx + 1]) / 4.F;
39 }
40
41 19840 inline float VerticalFilterAtTBB(const std::vector<float> &temp, int n, int m, int x, int y) {
42 19840 const int idx = (y * n) + x;
43
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 19360 times.
19840 if (y == 0) {
44 480 return ((2.F * temp[idx]) + temp[idx + n]) / 3.F;
45 }
46
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18880 times.
19360 if (y == m - 1) {
47 480 return (temp[idx - n] + (2.F * temp[idx])) / 3.F;
48 }
49 18880 return (temp[idx - n] + (2.F * temp[idx]) + temp[idx + n]) / 4.F;
50 }
51
52 20 bool ChaschinVLinearFiltrationTBB::RunImpl() {
53 const auto &in = GetInput();
54 const auto &image = std::get<0>(in);
55 20 int n = std::get<1>(in);
56 20 int m = std::get<2>(in);
57
58 auto &out = GetOutput();
59 20 out.resize(static_cast<size_t>(n) * m);
60
61 20 std::vector<float> temp(static_cast<size_t>(n) * m);
62
63 // ---------- горизонтальная фильтрация ----------
64
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
500 tbb::parallel_for(tbb::blocked_range<int>(0, m), [&](const tbb::blocked_range<int> &r) {
65 960 for (int yi = r.begin(); yi < r.end(); ++yi) {
66
2/2
✓ Branch 0 taken 19840 times.
✓ Branch 1 taken 480 times.
20320 for (int xf = 0; xf < n; ++xf) {
67 19840 temp[(yi * n) + xf] = HorizontalFilterAtTBB(image, n, xf, yi);
68 }
69 }
70 480 });
71
72 // ---------- вертикальная фильтрация ----------
73
2/6
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
500 tbb::parallel_for(tbb::blocked_range<int>(0, m), [&](const tbb::blocked_range<int> &r) {
74
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 480 times.
960 for (int yi = r.begin(); yi < r.end(); ++yi) {
75
2/2
✓ Branch 0 taken 19840 times.
✓ Branch 1 taken 480 times.
20320 for (int xy = 0; xy < n; ++xy) {
76 19840 out[(yi * n) + xy] = VerticalFilterAtTBB(temp, n, m, xy, yi);
77 }
78 }
79 480 });
80
81 20 return true;
82 }
83
84 20 bool ChaschinVLinearFiltrationTBB::PostProcessingImpl() {
85 20 return true;
86 }
87
88 } // namespace chaschin_v_linear_image_filtration_tbb
89