Streamtools: Refactor rescaling code
[jpcrr.git] / streamtools / rescalers / linear-separable.hpp
blob7e094642b67a82efd2de476ac73e7d0ad30dfccd
1 #ifndef _rescalers__linear_separable__hpp__included__
2 #define _rescalers__linear_separable__hpp__included__
4 #include "rescalers/factory.hpp"
5 #include "bound-method.hpp"
7 #define MAXCOEFFICIENTS 256
9 typedef signed long long position_t;
11 typedef bound_method<void, float*, position_t, position_t, position_t, position_t, unsigned&, unsigned&>
12 bound_coeff_function_t;
15 class rescaler_linear_separable : public rescaler
17 public:
18 void operator()(uint8_t* target, uint32_t twidth, uint32_t theight,
19 const uint8_t* source, uint32_t swidth, uint32_t sheight);
20 protected:
21 //Fill coeffs, base and coeffcount. Coeffs is set of floating-point coefficients for pixels
22 //starting from pixel number base (zero-based) and numbering coeffcount. Take care not to refer
23 //to pixel outside range [0,width). Twidth is target width.
24 //num / denum gives position of pixel being approximated. The coordinate range is [0, width),
25 //width giving the width of original data.
26 virtual void compute_coeffs(float* coeffs, position_t num, position_t denum, position_t width,
27 position_t twidth, unsigned& base, unsigned& coeffcount) = 0;
30 class simple_rescaler_linear_separable : public rescaler_factory
32 public:
33 simple_rescaler_linear_separable(const std::string& type, bound_coeff_function_t _coeffs_fn);
34 rescaler& make(const std::string& type);
35 private:
36 bound_coeff_function_t coeffs_fn;
39 #endif