diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-10-21 23:05:56 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-10-22 00:05:28 +0200 |
| commit | e171a0bbaf0dedbab261279561888e7259a40df7 (patch) | |
| tree | bba0d25b7cd85d8c70843ba88f3935f1d13585fc /src/piecewise_lut.h | |
| parent | 251f7a934525e0c846c95cc729664e95928e8aa5 (diff) | |
Use an integer LUT for PiecewiseLUT2, hence removing a lrint and a multiply from the rgb -> xyz loop.
Diffstat (limited to 'src/piecewise_lut.h')
| -rw-r--r-- | src/piecewise_lut.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/piecewise_lut.h b/src/piecewise_lut.h index f2f21a92..3bea6bb8 100644 --- a/src/piecewise_lut.h +++ b/src/piecewise_lut.h @@ -47,24 +47,24 @@ namespace dcp { class PiecewiseLUT2 { public: - PiecewiseLUT2(std::shared_ptr<const TransferFunction> fn, double boundary, int low_bits, int high_bits, bool inverse) + PiecewiseLUT2(std::shared_ptr<const TransferFunction> fn, double boundary, int low_bits, int high_bits, bool inverse, int scale) : _boundary(boundary) - , _low(fn->double_lut(0, boundary, low_bits, inverse)) - , _high(fn->double_lut(boundary, 1, high_bits, inverse)) + , _low(fn->int_lut(0, boundary, low_bits, inverse, scale)) + , _high(fn->int_lut(boundary, 1, high_bits, inverse, scale)) , _low_scale(static_cast<int>(std::pow(2.0f, low_bits)) - 1) , _high_scale(static_cast<int>(std::pow(2.0f, high_bits)) - 1) { } - inline double lookup(double x) const { + inline int lookup(double x) const { return x < _boundary ? _low[lrint((x / _boundary) * _low_scale)] : _high[lrint(((x - _boundary) / (1 - _boundary)) * _high_scale)]; } private: double _boundary; - std::vector<double> _low; - std::vector<double> _high; + std::vector<int> _low; + std::vector<int> _high; int _low_scale; int _high_scale; }; |
