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

Function interpolate_lanczos4

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

Source from the content-addressed store, hash-verified

1006 coeffs[3] = 1.f - coeffs[0] - coeffs[1] - coeffs[2];
1007}
1008static inline void interpolate_lanczos4(float x, float* coeffs) {
1009 static const double s45 = 0.70710678118654752440084436210485;
1010 static const double cs[][2] = {{1, 0}, {-s45, -s45}, {0, 1}, {s45, -s45},
1011 {-1, 0}, {s45, s45}, {0, -1}, {-s45, s45}};
1012
1013 if (x < FLT_EPSILON) {
1014 for (int i = 0; i < 8; i++)
1015 coeffs[i] = 0;
1016 coeffs[3] = 1;
1017 return;
1018 }
1019
1020 float sum = 0;
1021 double y0 = -(x + 3) * MEGCV_PI * 0.25, s0 = sin(y0), c0 = cos(y0);
1022 for (int i = 0; i < 8; i++) {
1023 double y = -(x + 3 - i) * MEGCV_PI * 0.25;
1024 coeffs[i] = (float)((cs[i][0] * s0 + cs[i][1] * c0) / (y * y));
1025 sum += coeffs[i];
1026 }
1027
1028 sum = 1.f / sum;
1029 for (int i = 0; i < 8; i++)
1030 coeffs[i] *= sum;
1031}
1032
1033template <typename T, typename WT, typename AT>
1034struct HResizeLanczos4 {

Callers 1

resize_opencvFunction · 0.70

Calls 2

sinFunction · 0.50
cosFunction · 0.50

Tested by

no test coverage detected