| 30 | namespace test = nvcv::test; |
| 31 | |
| 32 | static void PadAndStack(std::vector<uint8_t> &hDst, const std::vector<std::vector<uint8_t>> &hBatchSrc, |
| 33 | const nvcv::TensorDataAccessStridedImagePlanar &dDstData, const int srcWidth, |
| 34 | const int srcHeight, const int srcRowStride, const int srcPixPitch, |
| 35 | const std::vector<int> &topVec, const std::vector<int> &leftVec, |
| 36 | const NVCVBorderType borderType, const float borderValue) |
| 37 | { |
| 38 | int dstPixPitch = dDstData.numChannels(); |
| 39 | int dstRowStride = dDstData.rowStride() / sizeof(uint8_t); |
| 40 | int dstImgPitch = dDstData.sampleStride() / sizeof(uint8_t); |
| 41 | |
| 42 | int2 coord, size{srcWidth, srcHeight}; |
| 43 | |
| 44 | for (int db = 0; db < dDstData.numSamples(); db++) |
| 45 | { |
| 46 | for (int di = 0; di < dDstData.numRows(); di++) |
| 47 | { |
| 48 | coord.y = di - topVec[db]; |
| 49 | |
| 50 | for (int dj = 0; dj < dDstData.numCols(); dj++) |
| 51 | { |
| 52 | coord.x = dj - leftVec[db]; |
| 53 | |
| 54 | for (int dk = 0; dk < dDstData.numChannels(); dk++) |
| 55 | { |
| 56 | uint8_t out = 0; |
| 57 | |
| 58 | if (coord.x >= 0 && coord.x < size.x && coord.y >= 0 && coord.y < size.y) |
| 59 | { |
| 60 | out = hBatchSrc[db][coord.y * srcRowStride + coord.x * srcPixPitch + dk]; |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | if (borderType == NVCV_BORDER_CONSTANT) |
| 65 | { |
| 66 | out = static_cast<uint8_t>(borderValue); |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | if (borderType == NVCV_BORDER_REPLICATE) |
| 71 | { |
| 72 | test::ReplicateBorderIndex(coord, size); |
| 73 | } |
| 74 | else if (borderType == NVCV_BORDER_WRAP) |
| 75 | { |
| 76 | test::WrapBorderIndex(coord, size); |
| 77 | } |
| 78 | else if (borderType == NVCV_BORDER_REFLECT) |
| 79 | { |
| 80 | test::ReflectBorderIndex(coord, size); |
| 81 | } |
| 82 | else if (borderType == NVCV_BORDER_REFLECT101) |
| 83 | { |
| 84 | test::Reflect101BorderIndex(coord, size); |
| 85 | } |
| 86 | |
| 87 | out = hBatchSrc[db][coord.y * srcRowStride + coord.x * srcPixPitch + dk]; |
| 88 | } |
| 89 | } |
no test coverage detected