MCPcopy Create free account
hub / github.com/alibaba/MNN / _sampleBilinearCommon

Function _sampleBilinearCommon

source/backend/cpu/compute/ImageProcessFunction.cpp:743–777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741}
742
743static void _sampleBilinearCommon(const unsigned char* source, unsigned char* dest, MNN::CV::Point* points, size_t count,
744 size_t iw, size_t ih, size_t yStride, size_t bpp) {
745 float dy = points[1].fY;
746 float dx = points[1].fX;
747 float xMax = iw - 1;
748 float yMax = ih - 1;
749
750 MNN::CV::Point curPoints;
751 curPoints.fX = points[0].fX;
752 curPoints.fY = points[0].fY;
753 for (int i = 0; i < count; ++i) {
754 float y = __clamp(curPoints.fY, 0, yMax);
755 float x = __clamp(curPoints.fX, 0, xMax);
756 int y0 = (int)y;
757 int x0 = (int)x;
758 int y1 = (int)ceilf(y);
759 int x1 = (int)ceilf(x);
760 float xF = x - (float)x0;
761 float yF = y - (float)y0;
762
763 for (int b = 0; b < bpp; ++b) {
764 unsigned char c00 = source[y0 * yStride + bpp * x0 + b];
765 unsigned char c01 = source[y0 * yStride + bpp * x1 + b];
766 unsigned char c10 = source[y1 * yStride + bpp * x0 + b];
767 unsigned char c11 = source[y1 * yStride + bpp * x1 + b];
768
769 float v =
770 (1.0f - xF) * (1.0f - yF) * c00 + xF * (1.0f - yF) * c01 + yF * (1.0 - xF) * c10 + xF * yF * (c11);
771 v = std::min(std::max(v, 0.0f), 255.0f);
772 dest[bpp * i + b] = (unsigned char)roundf(v);
773 }
774 curPoints.fY += dy;
775 curPoints.fX += dx;
776 }
777}
778
779void MNNSamplerC4Bilinear(const unsigned char* source, unsigned char* dest, MNN::CV::Point* points, size_t sta,
780 size_t count, size_t capacity, size_t iw, size_t ih, size_t yStride) {

Callers 3

MNNSamplerC4BilinearFunction · 0.85
MNNSamplerC3BilinearFunction · 0.85
MNNSamplerC1BilinearFunction · 0.85

Calls 3

__clampFunction · 0.70
minFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected