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/s_gamut3_transfer_function.cc | |
| parent | ad7244de981a7dd0b9b4f8f3d62d4704f1968012 (diff) | |
Allow LUTs to be created with a particular range.
Diffstat (limited to 'src/s_gamut3_transfer_function.cc')
| -rw-r--r-- | src/s_gamut3_transfer_function.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/s_gamut3_transfer_function.cc b/src/s_gamut3_transfer_function.cc index b2e82b51..512a2951 100644 --- a/src/s_gamut3_transfer_function.cc +++ b/src/s_gamut3_transfer_function.cc @@ -49,26 +49,28 @@ using namespace dcp; vector<double> -SGamut3TransferFunction::make_lut (int bit_depth, bool inverse) const +SGamut3TransferFunction::make_lut (double from, double to, int bit_depth, bool inverse) const { int const bit_length = int(std::pow(2.0f, bit_depth)); auto lut = vector<double>(bit_length); if (inverse) { for (int i = 0; i < bit_length; ++i) { auto const p = static_cast<double>(i) / (bit_length - 1); - if (p >= (0.01125 / 1023)) { - lut[i] = (420 + log10((p + 0.01) / (0.18 + 0.01)) * 261.5) / 1023; + auto const q = (p * (to - from)) + from; + if (q >= (0.01125 / 1023)) { + lut[i] = (420 + log10((q + 0.01) / (0.18 + 0.01)) * 261.5) / 1023; } else { - lut[i] = (p * (171.2102946929 - 95) / 0.01125000 + 95) / 1023; + lut[i] = (q * (171.2102946929 - 95) / 0.01125000 + 95) / 1023; } } } else { for (int i = 0; i < bit_length; ++i) { auto const p = static_cast<double>(i) / (bit_length - 1); - if (p >= (171.2102946929 / 1023)) { + auto const q = (p * (to - from)) + from; + if (q >= (171.2102946929 / 1023)) { lut[i] = pow(10, ((p * 1023 - 420) / 261.5)) * (0.18 + 0.01) - 0.01; } else { - lut[i] = (p * 1023 - 95) * 0.01125000 / (171.2102946929 - 95); + lut[i] = (q * 1023 - 95) * 0.01125000 / (171.2102946929 - 95); } } } |
