Keys bicubic kernel (a = -0.5) - matches PyTorch antialias=True
| 12 | |
| 13 | // Keys bicubic kernel (a = -0.5) - matches PyTorch antialias=True |
| 14 | inline float bicubic_kernel(float x) { |
| 15 | const float a = -0.5f; |
| 16 | x = std::fabs(x); |
| 17 | if (x < 1.0f) |
| 18 | return ((a + 2.0f) * x - (a + 3.0f)) * x * x + 1.0f; |
| 19 | else if (x < 2.0f) |
| 20 | return ((a * x - 5.0f * a) * x + 8.0f * a) * x - 4.0f * a; |
| 21 | else |
| 22 | return 0.0f; |
| 23 | } |
| 24 | |
| 25 | inline int clamp(int x, int lo, int hi) { |
| 26 | return std::max(lo, std::min(x, hi)); |
no outgoing calls
no test coverage detected