MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / MIDOUT_BEGIN

Function MIDOUT_BEGIN

dnn/src/common/warp_common.h:434–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432 const Mat<T>& _src, Mat<T>& _dst, const Mat<short>& _xy,
433 const Mat<ushort>& _fxy, const void* _wtab, const T* bvalue) {
434 MIDOUT_BEGIN(remapBilinear_bmode, midout_iv(bmode)) {
435 typedef typename CastOp::type1 WT;
436 const AT* wtab = (const AT*)_wtab;
437 const T* S0 = _src.ptr();
438 size_t sstep = _src.step();
439 int dx, dy;
440 CastOp castOp;
441 VecOp vecOp;
442 int swidth = _src.width(), sheight = _src.height();
443 int dwidth = _dst.width(), dheight = _dst.height();
444 unsigned width1 = std::max(swidth - 1, 0), height1 = std::max(sheight - 1, 0);
445 for (dy = 0; dy < dheight; dy++) {
446 T* D = _dst.ptr(dy);
447 const short* XY = _xy.ptr(dy);
448 const ushort* FXY = _fxy.ptr(dy);
449 int X0 = 0;
450 bool prevInlier = false;
451
452 for (dx = 0; dx <= dwidth; dx++) {
453 bool curInlier = dx < dwidth
454 ? (unsigned)XY[dx * 2] < width1 &&
455 (unsigned)XY[dx * 2 + 1] < height1
456 : !prevInlier;
457 if (curInlier == prevInlier)
458 continue;
459
460 int X1 = dx;
461 dx = X0;
462 X0 = X1;
463 prevInlier = curInlier;
464
465 if (!curInlier) {
466 int len = vecOp(_src, D, XY + dx * 2, FXY + dx, wtab, X1 - dx);
467 D += len * CH;
468 dx += len;
469
470 if (CH == 1) {
471 MIDOUT_BEGIN(remapBilinear_bmode, 0, 1) {
472 for (; dx < X1; dx++, D++) {
473 int sx = XY[dx * 2], sy = XY[dx * 2 + 1];
474 const AT* w = wtab + FXY[dx] * 4;
475 const T* S = S0 + sy * sstep + sx;
476 *D = castOp(
477 WT(S[0] * w[0] + S[1] * w[1] + S[sstep] * w[2] +
478 S[sstep + 1] * w[3]));
479 }
480 }
481 MIDOUT_END();
482 } else if (CH == 2) {
483 MIDOUT_BEGIN(remapBilinear_bmode, 0, 2) {
484 for (; dx < X1; dx++, D += 2) {
485 int sx = XY[dx * 2], sy = XY[dx * 2 + 1];
486 const AT* w = wtab + FXY[dx] * 4;
487 const T* S = S0 + sy * sstep + sx * 2;
488 WT t0 = S[0] * w[0] + S[2] * w[1] + S[sstep] * w[2] +
489 S[sstep + 2] * w[3];
490 WT t1 = S[1] * w[0] + S[3] * w[1] +
491 S[sstep + 1] * w[2] + S[sstep + 3] * w[3];

Callers 2

get_funcsMethod · 0.70
get_funcsMethod · 0.70

Calls 6

maxFunction · 0.85
saturateFunction · 0.70
ptrMethod · 0.45
stepMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected