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

Function interpolate_lanczos4

dnn/src/x86/resize/resize_cv.cpp:1413–1436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411 coeffs[3] = 1.f - coeffs[0] - coeffs[1] - coeffs[2];
1412}
1413static inline void interpolate_lanczos4(float x, float* coeffs) {
1414 static const double s45 = 0.70710678118654752440084436210485;
1415 static const double cs[][2] = {{1, 0}, {-s45, -s45}, {0, 1}, {s45, -s45},
1416 {-1, 0}, {s45, s45}, {0, -1}, {-s45, s45}};
1417
1418 if (x < FLT_EPSILON) {
1419 for (int i = 0; i < 8; i++)
1420 coeffs[i] = 0;
1421 coeffs[3] = 1;
1422 return;
1423 }
1424
1425 float sum = 0;
1426 double y0 = -(x + 3) * MEGCV_PI * 0.25, s0 = sin(y0), c0 = cos(y0);
1427 for (int i = 0; i < 8; i++) {
1428 double y = -(x + 3 - i) * MEGCV_PI * 0.25;
1429 coeffs[i] = (float)((cs[i][0] * s0 + cs[i][1] * c0) / (y * y));
1430 sum += coeffs[i];
1431 }
1432
1433 sum = 1.f / sum;
1434 for (int i = 0; i < 8; i++)
1435 coeffs[i] *= sum;
1436}
1437
1438template <typename T, typename WT, typename AT>
1439struct HResizeLanczos4 {

Callers 1

resize_opencvFunction · 0.70

Calls 2

sinFunction · 0.50
cosFunction · 0.50

Tested by

no test coverage detected