| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "iskhakov_d_vertical_gauss_filter/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <array> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <utility> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "iskhakov_d_vertical_gauss_filter/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace iskhakov_d_vertical_gauss_filter { | ||
| 12 | |||
| 13 | namespace { | ||
| 14 | const int kDivConst = 16; | ||
| 15 | const std::array<std::array<int, 3>, 3> kGaussKernel = {{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}}; | ||
| 16 | const int kNumBands = 1; | ||
| 17 | |||
| 18 | uint8_t IskhakovDGetPixelMirrorSeq(const std::vector<uint8_t> &res, int col, int row, int width, int height) { | ||
| 19 | 2808 | if (col < 0) { | |
| 20 | ✗ | col = -col - 1; | |
| 21 |
12/18✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 208 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 208 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 312 times.
✓ Branch 10 taken 104 times.
✓ Branch 11 taken 208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 208 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 312 times.
✓ Branch 16 taken 104 times.
✓ Branch 17 taken 208 times.
|
2496 | } else if (col >= width) { |
| 22 | 312 | col = (2 * width) - col - 1; | |
| 23 | } | ||
| 24 | 936 | if (row < 0) { | |
| 25 | row = -row - 1; | ||
| 26 |
6/6✓ Branch 0 taken 104 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 208 times.
|
936 | } else if (row >= height) { |
| 27 | 312 | row = (2 * height) - row - 1; | |
| 28 | } | ||
| 29 |
10/16✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 208 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 312 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 312 times.
✓ Branch 10 taken 104 times.
✓ Branch 11 taken 208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 312 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 312 times.
|
2808 | return res[(row * width) + col]; |
| 30 | } | ||
| 31 | } // namespace | ||
| 32 | |||
| 33 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | IskhakovDVerticalGaussFilterSEQ::IskhakovDVerticalGaussFilterSEQ(const InType &in) { |
| 34 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 35 | GetInput() = in; | ||
| 36 | 40 | GetOutput() = OutType{}; | |
| 37 | 40 | } | |
| 38 | |||
| 39 | 40 | bool IskhakovDVerticalGaussFilterSEQ::ValidationImpl() { | |
| 40 | const auto &in = GetInput(); | ||
| 41 | |||
| 42 |
2/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
|
40 | if (in.width <= 0 || in.height <= 0) { |
| 43 | return false; | ||
| 44 | } | ||
| 45 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
|
40 | if (in.data.size() != static_cast<size_t>(in.width) * static_cast<size_t>(in.height)) { |
| 46 | ✗ | return false; | |
| 47 | } | ||
| 48 | return true; | ||
| 49 | } | ||
| 50 | |||
| 51 | 40 | bool IskhakovDVerticalGaussFilterSEQ::PreProcessingImpl() { | |
| 52 | 40 | return true; | |
| 53 | } | ||
| 54 | |||
| 55 | 40 | bool IskhakovDVerticalGaussFilterSEQ::RunImpl() { | |
| 56 | const auto &in = GetInput(); | ||
| 57 | |||
| 58 | 40 | int width = in.width; | |
| 59 | 40 | int height = in.height; | |
| 60 | const std::vector<uint8_t> &matrix = in.data; | ||
| 61 | 40 | std::vector<uint8_t> result(static_cast<size_t>(width) * static_cast<size_t>(height)); | |
| 62 | |||
| 63 | int band_width = width / kNumBands; | ||
| 64 | int remainder = width % kNumBands; | ||
| 65 | int start_band = 0; | ||
| 66 | |||
| 67 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
|
80 | for (int band = 0; band < kNumBands; ++band) { |
| 68 | 40 | int cur_band_width = band_width + (band < remainder ? 1 : 0); | |
| 69 | 40 | int end_band = start_band + cur_band_width; | |
| 70 | |||
| 71 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 40 times.
|
144 | for (int horizontal_band = start_band; horizontal_band < end_band; ++horizontal_band) { |
| 72 |
2/2✓ Branch 0 taken 312 times.
✓ Branch 1 taken 104 times.
|
416 | for (int vertical_band = 0; vertical_band < height; ++vertical_band) { |
| 73 | int sum = 0; | ||
| 74 | |||
| 75 | sum += kGaussKernel[0][0] * | ||
| 76 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 312 times.
|
624 | IskhakovDGetPixelMirrorSeq(matrix, horizontal_band - 1, vertical_band - 1, width, height); |
| 77 | 312 | sum += | |
| 78 | 312 | kGaussKernel[0][1] * IskhakovDGetPixelMirrorSeq(matrix, horizontal_band, vertical_band - 1, width, height); | |
| 79 | 312 | sum += kGaussKernel[0][2] * | |
| 80 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 208 times.
|
624 | IskhakovDGetPixelMirrorSeq(matrix, horizontal_band + 1, vertical_band - 1, width, height); |
| 81 | |||
| 82 | 312 | sum += | |
| 83 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
|
312 | kGaussKernel[1][0] * IskhakovDGetPixelMirrorSeq(matrix, horizontal_band - 1, vertical_band, width, height); |
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
|
312 | sum += kGaussKernel[1][1] * IskhakovDGetPixelMirrorSeq(matrix, horizontal_band, vertical_band, width, height); |
| 85 | 312 | sum += | |
| 86 | 312 | kGaussKernel[1][2] * IskhakovDGetPixelMirrorSeq(matrix, horizontal_band + 1, vertical_band, width, height); | |
| 87 | |||
| 88 | 312 | sum += kGaussKernel[2][0] * | |
| 89 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 312 times.
|
624 | IskhakovDGetPixelMirrorSeq(matrix, horizontal_band - 1, vertical_band + 1, width, height); |
| 90 | 312 | sum += | |
| 91 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
|
312 | kGaussKernel[2][1] * IskhakovDGetPixelMirrorSeq(matrix, horizontal_band, vertical_band + 1, width, height); |
| 92 | 312 | sum += kGaussKernel[2][2] * | |
| 93 | 312 | IskhakovDGetPixelMirrorSeq(matrix, horizontal_band + 1, vertical_band + 1, width, height); | |
| 94 | |||
| 95 | 312 | result[(vertical_band * width) + horizontal_band] = static_cast<uint8_t>(sum / kDivConst); | |
| 96 | } | ||
| 97 | } | ||
| 98 | start_band = end_band; | ||
| 99 | } | ||
| 100 | 40 | GetOutput().width = width; | |
| 101 | 40 | GetOutput().height = height; | |
| 102 | 40 | GetOutput().data = std::move(result); | |
| 103 | 40 | return true; | |
| 104 | } | ||
| 105 | |||
| 106 | 40 | bool IskhakovDVerticalGaussFilterSEQ::PostProcessingImpl() { | |
| 107 | 40 | return true; | |
| 108 | } | ||
| 109 | |||
| 110 | } // namespace iskhakov_d_vertical_gauss_filter | ||
| 111 |