New letterbox resizer
[jpcrr.git] / streamtools / resizer-letterbox.cpp
blobe31151d1201fc7d2e275274cf52d80edd72aa440
1 #include "resize-linear-separable.hpp"
2 #include <stdint.h>
3 #include <cmath>
4 #include <stdexcept>
6 namespace
8 void compute_coefficients_letterbox(float* coeffs, position_t num, position_t denum, position_t width,
9 position_t twidth, unsigned& count, unsigned& base)
11 position_t relpos = num / width - (twidth - width) / 2;
12 *coeffs = 0;
13 count = 1;
14 base = 0;
15 if(relpos >= 0 && relpos < width) {
16 *coeffs = 1;
17 base = (unsigned)relpos;
21 simple_resizer_linear_separable r_letterbox("letterbox", compute_coefficients_letterbox);