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

Function resizeGeneric_

dnn/src/arm_common/resize/resize_cv.cpp:1358–1416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1356
1357template <class HResize, class VResize, class MT>
1358void resizeGeneric_(
1359 const Mat<MT>& src, Mat<MT>& dst, const int* xofs, const void* _alpha,
1360 const int* yofs, const void* _beta, int xmin, int xmax, int ksize) {
1361 typedef typename HResize::value_type T;
1362 typedef typename HResize::buf_type WT;
1363 typedef typename HResize::alpha_type AT;
1364
1365 const AT* beta = static_cast<const AT*>(_beta);
1366 const AT* alpha = static_cast<const AT*>(_alpha);
1367 int swidth = src.width();
1368 int sheight = src.height();
1369 int dwidth = dst.width();
1370 int dheight = dst.height();
1371 int cn = src.channels();
1372 swidth *= cn;
1373 dwidth *= cn;
1374 xmin *= cn;
1375 xmax *= cn;
1376 // image resize is a separable operation. In case of not too strong
1377 // dsize.height
1378 int dy;
1379 HResize hresize;
1380 VResize vresize;
1381
1382 int bufstep = static_cast<int>(align_size(dwidth, 16));
1383 AlignedVector<WT> _buffer(bufstep * ksize);
1384 WT* buffer = _buffer.data();
1385 const T* srows[16] = {0};
1386 WT* rows[16] = {0};
1387 int prev_sy[16];
1388
1389 for (int k = 0; k < ksize; ++k) {
1390 prev_sy[k] = -1;
1391 rows[k] = buffer + bufstep * k;
1392 }
1393
1394 for (dy = 0; dy < dheight; ++dy, beta += ksize) {
1395 int sy0 = yofs[dy], k0 = ksize, k1 = 0, ksize2 = ksize / 2;
1396
1397 for (int k = 0; k < ksize; ++k) {
1398 int sy = saturate(sy0 - ksize2 + 1 + k, 0, sheight);
1399 for (k1 = std::max(k1, k); k1 < ksize; ++k1) {
1400 if (sy == prev_sy[k1]) {
1401 if (k1 > k)
1402 memcpy(rows[k], rows[k1], bufstep * sizeof(rows[0][0]));
1403 break;
1404 }
1405 }
1406 if (k1 == ksize)
1407 k0 = std::min(k0, k);
1408 srows[k] = src.ptr(sy);
1409 prev_sy[k] = sy;
1410 }
1411 if (k0 < ksize)
1412 hresize(srows + k0, rows + k0, ksize - k0, xofs, alpha, swidth, dwidth, cn,
1413 xmin, xmax);
1414 vresize((const WT**)(rows), dst.ptr(dy), beta, dwidth);
1415 }

Callers

nothing calls this directly

Calls 9

maxFunction · 0.85
align_sizeFunction · 0.50
saturateFunction · 0.50
minFunction · 0.50
widthMethod · 0.45
heightMethod · 0.45
channelsMethod · 0.45
dataMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected