From cbbb9e63b7ec7a5c34f186ceafe5da6be8faa739 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 5 May 2022 20:56:14 +0200 Subject: Allow LUTs to be created with a particular range. --- src/transfer_function.cc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/transfer_function.cc') 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 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()(desc.from) ^ + std::hash()(desc.to) ^ + std::hash()(desc.bit_depth) ^ + std::hash()(desc.inverse); } + -- cgit v1.2.3