GCC Code Coverage Report


Directory: ./
File: tasks/shakirova_e_sobel_edge_detection/tbb/src/ops_tbb.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 6 6 100.0%
Branches: 6 8 75.0%

Line Branch Exec Source
1 #include "shakirova_e_sobel_edge_detection/tbb/include/ops_tbb.hpp"
2
3 #include <oneapi/tbb/blocked_range.h>
4 #include <oneapi/tbb/parallel_for.h>
5
6 #include <algorithm>
7 #include <cmath>
8 #include <cstddef>
9 #include <vector>
10
11 #include "shakirova_e_sobel_edge_detection/common/include/common.hpp"
12
13 namespace shakirova_e_sobel_edge_detection {
14
15
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 ShakirovaESobelEdgeDetectionTBB::ShakirovaESobelEdgeDetectionTBB(const InType &in) {
16 SetTypeOfTask(GetStaticTypeOfTask());
17 GetInput() = in;
18 GetOutput().clear();
19 24 }
20
21
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 bool ShakirovaESobelEdgeDetectionTBB::ValidationImpl() {
22 24 return GetInput().IsValid();
23 }
24
25 24 bool ShakirovaESobelEdgeDetectionTBB::PreProcessingImpl() {
26 const auto &img = GetInput();
27 24 GetOutput().assign(static_cast<size_t>(img.width) * static_cast<size_t>(img.height), 0);
28 24 return true;
29 }
30
31 24 bool ShakirovaESobelEdgeDetectionTBB::RunImpl() {
32 const auto &img = GetInput();
33 24 const int h = img.height;
34 24 const int w = img.width;
35 const int *inp = img.pixels.data();
36 int *out = GetOutput().data();
37
38 1060 tbb::parallel_for(tbb::blocked_range<int>(1, h - 1, 8), [inp, out, w](const tbb::blocked_range<int> &r) {
39
2/2
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 1036 times.
7280 for (int row = r.begin(); row < r.end(); ++row) {
40 6244 const int *prev = inp + static_cast<ptrdiff_t>((row - 1) * w);
41 6244 const int *curr = inp + static_cast<ptrdiff_t>((row)*w);
42 6244 const int *next = inp + static_cast<ptrdiff_t>((row + 1) * w);
43 6244 int *out_row = out + static_cast<ptrdiff_t>((row)*w);
44
45
2/2
✓ Branch 0 taken 3258356 times.
✓ Branch 1 taken 6244 times.
3264600 for (int col = 1; col < w - 1; ++col) {
46 3258356 const int gx =
47 3258356 -prev[col - 1] + prev[col + 1] - (2 * curr[col - 1]) + (2 * curr[col + 1]) - next[col - 1] + next[col + 1];
48 3258356 const int gy =
49 3258356 -prev[col - 1] - (2 * prev[col]) - prev[col + 1] + next[col - 1] + (2 * next[col]) + next[col + 1];
50
51 3258356 const int agx = std::abs(gx);
52 3258356 const int agy = std::abs(gy);
53 3258356 const int magnitude = ((std::max(agx, agy) * 123) + (std::min(agx, agy) * 51)) >> 7;
54 3258356 out_row[col] = magnitude > 255 ? 255 : magnitude;
55 }
56 }
57 1036 });
58
59 24 return true;
60 }
61
62 24 bool ShakirovaESobelEdgeDetectionTBB::PostProcessingImpl() {
63 24 return true;
64 }
65
66 } // namespace shakirova_e_sobel_edge_detection
67