diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-05 20:56:14 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-05 21:09:40 +0200 |
| commit | cbbb9e63b7ec7a5c34f186ceafe5da6be8faa739 (patch) | |
| tree | 79ccaa11973954138df02c2022b2ea25c0717b9d /src/transfer_function.cc | |
| parent | ad7244de981a7dd0b9b4f8f3d62d4704f1968012 (diff) | |
Allow LUTs to be created with a particular range.
Diffstat (limited to 'src/transfer_function.cc')
| -rw-r--r-- | src/transfer_function.cc | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/transfer_function.cc b/src/transfer_function.cc index dd3512ec..c1343ff2 100644 --- a/src/transfer_function.cc +++ b/src/transfer_function.cc @@ -51,15 +51,35 @@ using namespace dcp; vector<double> const& -TransferFunction::lut (int bit_depth, bool inverse) const +TransferFunction::lut (double from, double to, int bit_depth, bool inverse) const { boost::mutex::scoped_lock lm (_mutex); - auto i = _luts.find (make_pair (bit_depth, inverse)); - if (i != _luts.end ()) { + auto const descriptor = LUTDescriptor{from, to, bit_depth, inverse}; + + auto i = _luts.find(descriptor); + if (i != _luts.end()) { return i->second; } - _luts[make_pair(bit_depth, inverse)] = make_lut (bit_depth, inverse); - return _luts[make_pair(bit_depth, inverse)]; + _luts[descriptor] = make_lut(from, to, bit_depth, inverse); + return _luts[descriptor]; +} + + +bool +TransferFunction::LUTDescriptor::operator==(TransferFunction::LUTDescriptor const& other) const +{ + return from == other.from && to == other.to && bit_depth == other.bit_depth && inverse == other.inverse; +} + + +std::size_t +TransferFunction::LUTDescriptorHasher::operator()(TransferFunction::LUTDescriptor const& desc) const +{ + return std::hash<double>()(desc.from) ^ + std::hash<double>()(desc.to) ^ + std::hash<int>()(desc.bit_depth) ^ + std::hash<bool>()(desc.inverse); } + |
