22 #define M_PI 3.14159265358979323846264338327950288
26 #define NUMEL(x) (sizeof(x)/sizeof(*(x)))
36 if(-0.5f <= x && x < 0.5f)
44 static float BilinearKernel(
float x)
56 static float BicubicKernel(
float x)
58 const float alpha = -0.5f;
65 return ((alpha + 2)*x - (alpha + 3))*x*x + 1;
67 return ((alpha*x - 5*alpha)*x + 8*alpha)*x - 4*alpha;
75 static float Lanczos2Kernel(
float x)
90 static float Lanczos3Kernel(
float x)
105 static float Lanczos4Kernel(
float x)
120 static const float BSpline2Prefilter[1] =
121 {-1.715728752538099e-1};
124 static float BSpline2Kernel(
float x)
141 static float Schaum2Kernel(
float x)
152 return (x - 3)*x/2 + 1;
161 static float Schaum3Kernel(
float x)
166 return ((x - 2)*x - 1)*x/2 + 1;
168 return ((-x + 6)*x - 11)*x/6 + 1;
176 static const float BSpline3Prefilter[1] =
177 {-2.679491924311227e-1};
180 static float BSpline3Kernel(
float x)
185 return (x/2 - 1)*x*x + 0.66666666666666667f;
197 static const float BSpline5Prefilter[2] =
198 {-4.309628820326465e-2,
199 -4.305753470999738e-1};
202 static float BSpline5Kernel(
float x)
209 return (((-10*x + 30)*xSqr - 60)*xSqr + 66) / 120;
214 return (1 + (5 + (10 + (10 + (5 - 5*x)*x)*x)*x)*x) / 120;
221 return xSqr*xSqr*x / 120;
229 static const float BSpline7Prefilter[3] =
230 {-9.148694809608277e-3, -1.225546151923267e-1, -5.352804307964382e-1};
233 static float BSpline7Kernel(
float x)
240 return ((((35*x - 140)*xSqr + 560)*xSqr - 1680)*xSqr + 2416) / 5040;
245 return (120 + (392 + (504 + (280 + (-84 + (-42 +
246 21*x)*x)*x*x)*x)*x)*x) / 5040;
251 return (((((((-7*x + 7)*x + 21)*x + 35)*x + 35)*x
252 + 21)*x + 7)*x + 1) / 5040;
259 return xSqr*xSqr*xSqr*x / 5040;
267 static const float BSpline9Prefilter[4] =
268 {-2.121306903180818e-3, -4.322260854048175e-2,
269 -2.017505201931532e-1, -6.079973891686259e-1};
272 static float BSpline9Kernel(
float x)
279 return (((((-63*x + 315)*xSqr - 2100)*xSqr + 11970)*xSqr
280 - 44100)*xSqr + 78095) / 181440;
285 return (14608 + (36414 + (34272 + (11256 + (-4032 + (-4284 + (-672
286 + (504 + (252 - 84*x)*x)*x)*x)*x)*x)*x)*x)*x) / 362880;
291 return (502 + (2214 + (4248 + (4536 + (2772 + (756 + (-168 + (-216
292 + (-72 + 36*x)*x)*x)*x)*x)*x)*x)*x)*x) / 362880;
297 return (1 + (9 + (36 + (84 + (126 + (126 + (84 + (36 + (9
298 - 9*x)*x)*x)*x)*x)*x)*x)*x)*x) / 362880;
305 return xCube*xCube*xCube / 362880;
313 static const float BSpline11Prefilter[5] =
314 {-5.105575344465021e-4, -1.666962736623466e-2, -8.975959979371331e-2,
315 -2.721803492947859e-1, -6.612660689007345e-1};
318 static float BSpline11Kernel(
float x)
325 return (15724248 + (-7475160 + (1718640 + (-255024 + (27720
326 + (-2772 + 462*x)*xSqr)*xSqr)*xSqr)*xSqr)*xSqr) / 39916800;
331 return (2203488 + (4480872 + (3273600 + (574200 + (-538560
332 + (-299376 + (39600 + (7920 + (-2640 + (-1320
333 + 330*x)*x)*x)*x)*x*x)*x)*x)*x)*x)*x) / 39916800;
338 return (152637 + (515097 + (748275 + (586575 + (236610 + (12474
339 + (-34650 + (-14850 + (-495 + (1485
340 + (495-165*x)*x)*x)*x)*x)*x)*x)*x)*x)*x)*x) / 39916800;
345 return (2036 + (11132 + (27500 + (40260 + (38280 + (24024 + (9240
346 + (1320 + (-660 + (-440 + (-110
347 + 55*x)*x)*x)*x)*x)*x)*x)*x)*x)*x)*x) / 39916800;
352 return (1 + (11 + (55 + (165 + (330 + (462 + (462 + (330 + (165
353 + (55 + (11 - 11*x)*x)*x)*x)*x)*x)*x)*x)*x)*x)*x) / 39916800;
361 return xPow4*xPow4*xSqr*x / 39916800;
369 static const float OMoms3Prefilter[1] =
370 {-3.441311542550502e-1};
373 static float OMoms3Kernel(
float x)
378 return ((x/2 - 1)*x + 1/14.0f)*x + 13/21.0f;
380 return ((-x/6 + 1)*x - 85/42.0f)*x + 29/21.0f;
387 static const float OMoms5Prefilter[2] =
388 {-7.092571896868541e-2, -4.758127100084396e-1};
391 static float OMoms5Kernel(
float x)
396 return (((((-10*x + 30)*x - (200/33.0f))*x
397 - (540/11.0f))*x - (5/33.0f))*x + (687/11.0)) / 120;
399 return (((((330*x - 2970)*x + 10100)*x
400 - 14940)*x + 6755)*x + 2517)/7920;
406 return ((xSqr + (20/33.0f))*xSqr + (1/66.0f))*x / 120;
413 static const float OMoms7Prefilter[3] =
414 {-1.976842538386140e-2, -1.557007746773578e-1, -5.685376180022930e-1};
417 static float OMoms7Kernel(
float x)
422 return (((((((15015*x - 60060)*x + 21021)*x + 180180)*x + 2695)*x
423 - 629244)*x + 21)*x + 989636) / 2162160;
427 return (x*(x*(x*(x*(x*(x*(5005*x - 10010) - 13013) - 10010) + 54285)
428 + 119350) + 106267) + 36606) / 1201200;
433 return (x*(x*(x*(x*(x*(x*(-15015*x + 15015) + 24024) + 90090)
434 + 102410) + 76230) + 31164) + 5536) / 10810800;
441 return (x*(xSqr*(xSqr*(2145*xSqr + 3003) + 385) + 3)) / 10810800;
451 {
"bilinear", BilinearKernel, 1, 0, 0, 0, 1},
452 {
"bicubic", BicubicKernel, 2, 0, 0, 0, 1},
453 {
"lanczos2", Lanczos2Kernel, 2, 1, 0, 0, 1},
454 {
"lanczos3", Lanczos3Kernel, 3, 1, 0, 0, 1},
455 {
"lanczos4", Lanczos4Kernel, 4, 1, 0, 0, 1},
456 {
"schaum2", Schaum2Kernel, 1.51f, 0, 0, 0, 1},
457 {
"schaum3", Schaum3Kernel, 2, 0, 0, 0, 1},
458 {
"bspline2", BSpline2Kernel, 1.5f, 0,
459 NUMEL(BSpline2Prefilter), BSpline2Prefilter, 8},
460 {
"bspline3", BSpline3Kernel, 2, 0,
461 NUMEL(BSpline3Prefilter), BSpline3Prefilter, 6},
462 {
"bspline5", BSpline5Kernel, 3, 0,
463 NUMEL(BSpline5Prefilter), BSpline5Prefilter, 120},
464 {
"bspline7", BSpline7Kernel, 4, 0,
465 NUMEL(BSpline7Prefilter), BSpline7Prefilter, 5040},
466 {
"bspline9", BSpline9Kernel, 5, 0,
467 NUMEL(BSpline9Prefilter), BSpline9Prefilter, 362880},
468 {
"bspline11", BSpline11Kernel, 6, 0,
469 NUMEL(BSpline11Prefilter), BSpline11Prefilter, 39916800},
470 {
"omoms3", OMoms3Kernel, 2, 0,
471 NUMEL(OMoms3Prefilter), OMoms3Prefilter, 21/4.0f},
472 {
"omoms5", OMoms5Kernel, 3, 0,
473 NUMEL(OMoms5Prefilter), OMoms5Prefilter, 7920/107.0f},
474 {
"omoms7", OMoms7Kernel, 4, 0,
475 NUMEL(OMoms7Prefilter), OMoms7Prefilter, 675675/346.0f}};
496 for(i = 0; i < (int)
NUMEL(InterpMethodTable); i++)
497 if(!strcmp(InterpMethodTable[i].Name, Name))
498 return &InterpMethodTable[i];