GCC Code Coverage Report


Directory: ./
File: tasks/pylaeva_s_inc_contrast_img_by_lsh/tbb/src/ops_tbb.cpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 7 7 100.0%
Branches: 15 22 68.2%

Line Branch Exec Source
1 #include "pylaeva_s_inc_contrast_img_by_lsh/tbb/include/ops_tbb.hpp"
2
3 #include <tbb/tbb.h>
4
5 #include <algorithm>
6 #include <cmath>
7 #include <cstddef>
8 #include <cstdint>
9 #include <utility>
10 #include <vector>
11
12 #include "oneapi/tbb/parallel_for.h"
13 #include "pylaeva_s_inc_contrast_img_by_lsh/common/include/common.hpp"
14
15 namespace pylaeva_s_inc_contrast_img_by_lsh {
16
17
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 PylaevaSIncContrastImgByLshTBB::PylaevaSIncContrastImgByLshTBB(const InType &in) {
18 SetTypeOfTask(GetStaticTypeOfTask());
19
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 GetInput() = in;
20 GetOutput() = {};
21 72 }
22
23 72 bool PylaevaSIncContrastImgByLshTBB::ValidationImpl() {
24 72 return !(GetInput().empty());
25 }
26
27 72 bool PylaevaSIncContrastImgByLshTBB::PreProcessingImpl() {
28 72 GetOutput().resize(GetInput().size());
29 72 return true;
30 }
31
32
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 bool PylaevaSIncContrastImgByLshTBB::RunImpl() {
33 const auto &input = GetInput();
34 auto &output = GetOutput();
35
36 size_t size = input.size();
37
38
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if (size == 0) {
39 return false;
40 }
41
42 using MinMax = std::pair<uint8_t, uint8_t>;
43
44 72 auto [min_pixel, max_pixel] = tbb::parallel_reduce(tbb::blocked_range<size_t>(1, size), MinMax{input[0], input[0]},
45 72 [&](const auto &range, MinMax init) -> MinMax {
46
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 292 times.
584 for (size_t i = range.begin(); i != range.end(); ++i) {
47
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 128 times.
292 init.first = std::min(init.first, input[i]);
48 292 init.second = std::max(init.second, input[i]);
49 }
50 292 return init;
51 72 }, [](const MinMax &a, const MinMax &b) -> MinMax {
52 return {std::min(a.first, b.first), std::max(a.second, b.second)};
53 });
54
55
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 44 times.
72 if (min_pixel == max_pixel) {
56 28 tbb::parallel_for(tbb::blocked_range<size_t>(0, size), [&](const auto &r) {
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 const uint8_t *src = input.data() + r.begin();
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 uint8_t *dst = output.data() + r.begin();
59 std::copy(src, src + r.size(), dst);
60 136 }, tbb::simple_partitioner());
61 28 return true;
62 }
63
64 44 const float scale = 255.0F / static_cast<float>(max_pixel - min_pixel);
65
66 204 tbb::parallel_for(tbb::blocked_range<size_t>(0, size), [&](const auto &r) {
67
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 160 times.
416 for (auto i = r.begin(); i != r.end(); ++i) {
68 256 output[i] = static_cast<uint8_t>(std::round((input[i] - min_pixel) * scale));
69 }
70 204 }, tbb::static_partitioner());
71
72 44 return true;
73 }
74
75 72 bool PylaevaSIncContrastImgByLshTBB::PostProcessingImpl() {
76 72 return true;
77 }
78
79 } // namespace pylaeva_s_inc_contrast_img_by_lsh
80