1 #include "rescalers/linear-separable.hpp"
8 void compute_coefficients_bicubic(float* coeffs
, position_t num
, position_t denum
, position_t width
,
9 position_t twidth
, unsigned& count
, unsigned& base
)
12 float t1
= (num
% denum
) / (float)denum
;
17 In matrix form, the equation is:
20 p(t) = 0.5 * [1, t, t², t³] | 2, -5, 4, -1 | |a_1 |
21 \-1, 3, -3, 1 / \a_2 /
22 Due to implicit muliplications, only the first part needs to be computed.
24 float c1
= t2
- 0.5 * (t1
+ t3
);
25 float c2
= 1 - 2.5 * t2
+ 1.5 * t3
;
26 float c3
= 0.5 * t1
+ 2 * t2
- 1.5 * t3
;
27 float c4
= 0.5 * (t3
- t2
);
30 if(base
< width
- 1) coeffs
[count
++] = c3
;
31 if(base
< width
- 2) coeffs
[count
++] = c4
;
36 if(base
< width
- 2) coeffs
[count
++] = c3
;
37 if(base
< width
- 3) coeffs
[count
++] = c4
;
41 simple_rescaler_linear_separable
r_bicubic("bicubic", make_bound_method(compute_coefficients_bicubic
));