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

Function interpolate_lanczos4

dnn/src/fallback/resize/gi/resize_cv.cpp:618–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616 coeffs[3] = 1.f - coeffs[0] - coeffs[1] - coeffs[2];
617}
618static GI_FORCEINLINE void interpolate_lanczos4(float x, float* coeffs) {
619 static const double s45 = 0.70710678118654752440084436210485;
620 static const double cs[][2] = {{1, 0}, {-s45, -s45}, {0, 1}, {s45, -s45},
621 {-1, 0}, {s45, s45}, {0, -1}, {-s45, s45}};
622
623 if (x < FLT_EPSILON) {
624 for (int i = 0; i < 8; i++)
625 coeffs[i] = 0;
626 coeffs[3] = 1;
627 return;
628 }
629
630 float sum = 0;
631 double y0 = -(x + 3) * MEGCV_PI * 0.25, s0 = sin(y0), c0 = cos(y0);
632 for (int i = 0; i < 8; i++) {
633 double y = -(x + 3 - i) * MEGCV_PI * 0.25;
634 coeffs[i] = (float)((cs[i][0] * s0 + cs[i][1] * c0) / (y * y));
635 sum += coeffs[i];
636 }
637
638 sum = 1.f / sum;
639 for (int i = 0; i < 8; i++)
640 coeffs[i] *= sum;
641}
642
643template <typename T, typename WT, typename AT>
644struct HResizeLanczos4 {

Callers 1

resize_opencvFunction · 0.70

Calls 2

sinFunction · 0.50
cosFunction · 0.50

Tested by

no test coverage detected