GCC Code Coverage Report


Directory: ./
File: tasks/rychkova_gauss/tbb/src/ops_tbb.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 7 7 100.0%
Branches: 19 24 79.2%

Line Branch Exec Source
1 #include "rychkova_gauss/tbb/include/ops_tbb.hpp"
2
3 #include <algorithm>
4 #include <cstddef>
5 #include <cstdint>
6 #include <vector>
7
8 #include "oneapi/tbb/blocked_range.h"
9 #include "oneapi/tbb/parallel_for.h"
10 #include "rychkova_gauss/common/include/common.hpp"
11
12 namespace rychkova_gauss {
13
14 namespace {
15 int Mirror(int x, int xmin, int xmax) {
16 56849472 if (x < xmin) {
17 return 1;
18 }
19
4/4
✓ Branch 0 taken 31056 times.
✓ Branch 1 taken 28362624 times.
✓ Branch 2 taken 29124 times.
✓ Branch 3 taken 28366488 times.
56789292 if (x >= xmax) {
20 60180 return xmax - 1;
21 }
22 return x;
23 };
24
25 3158304 Pixel ComputePixel(const Image &image, std::size_t x, std::size_t y, std::size_t width, std::size_t height) {
26 Pixel result = {.R = 0, .G = 0, .B = 0};
27
2/2
✓ Branch 0 taken 9474912 times.
✓ Branch 1 taken 3158304 times.
12633216 for (int shift_x = -1; shift_x < 2; shift_x++) {
28
2/2
✓ Branch 0 taken 28424736 times.
✓ Branch 1 taken 9474912 times.
37899648 for (int shift_y = -1; shift_y < 2; shift_y++) {
29
2/2
✓ Branch 0 taken 28393680 times.
✓ Branch 1 taken 31056 times.
28424736 int xn = Mirror(static_cast<int>(x) + shift_x, 0, static_cast<int>(width));
30
2/2
✓ Branch 0 taken 28395612 times.
✓ Branch 1 taken 29124 times.
28424736 int yn = Mirror(static_cast<int>(y) + shift_y, 0, static_cast<int>(height));
31 28424736 auto current = image[yn][xn];
32 28424736 result.R += static_cast<uint8_t>(static_cast<double>(current.R) * kKernel[shift_x + 1][shift_y + 1]);
33 28424736 result.G += static_cast<uint8_t>(static_cast<double>(current.G) * kKernel[shift_x + 1][shift_y + 1]);
34 28424736 result.B += static_cast<uint8_t>(static_cast<double>(current.B) * kKernel[shift_x + 1][shift_y + 1]);
35 }
36 }
37 3158304 return result;
38 }
39 } // namespace
40
41
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
32 RychkovaGaussTBB::RychkovaGaussTBB(const InType &in) {
42 SetTypeOfTask(GetStaticTypeOfTask());
43
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
32 GetInput() = in;
44 GetOutput() = {}; // cписок инициализации - пустой вектор - каждый вложенный вектор и пиксели внутри по умолчанию
45 32 }
46
47
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 bool RychkovaGaussTBB::ValidationImpl() {
48
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if (GetInput().empty()) {
49 return false;
50 }
51 const auto len = GetInput()[0].size();
52 return std::ranges::all_of(GetInput(), [len](const auto &row) { return row.size() == len; });
53 }
54
55 32 bool RychkovaGaussTBB::PreProcessingImpl() {
56 32 return true;
57 }
58
59 32 bool RychkovaGaussTBB::RunImpl() {
60 const auto &image = GetInput(); // сохран.изоб.
61 32 const auto width = image[0].size();
62 32 const auto height = image.size(); // сайз от имаге хранит количествo строк
63
1/2
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 GetOutput() = Image(height, std::vector<Pixel>(width, Pixel(0, 0, 0)));
64 8406 tbb::parallel_for(tbb::blocked_range<std::size_t>(0, height), [&](const tbb::blocked_range<std::size_t> &rng) {
65 18726 for (std::size_t j = rng.begin(); j < rng.end(); j++) {
66
2/2
✓ Branch 0 taken 3158304 times.
✓ Branch 1 taken 10352 times.
3168656 for (std::size_t i = 0; i < width; i++) {
67 3158304 GetOutput()[j][i] = ComputePixel(image, i, j, width, height);
68 }
69 }
70 8374 });
71 32 return true;
72 }
73
74 32 bool RychkovaGaussTBB::PostProcessingImpl() {
75 32 return true;
76 }
77
78 } // namespace rychkova_gauss
79