47 using std::shared_ptr;
55 boost::mutex::scoped_lock lm (
_mutex);
56 return double_lut_unlocked(from, to, bit_depth, inverse);
61 TransferFunction::double_lut_unlocked(
double from,
double to,
int bit_depth,
bool inverse)
const
63 auto const descriptor = LUTDescriptor{from, to, bit_depth, inverse, 1};
65 auto i = _double_luts.find(descriptor);
66 if (i != _double_luts.end()) {
70 _double_luts[descriptor] = make_double_lut(from, to, bit_depth, inverse);
71 return _double_luts[descriptor];
76 TransferFunction::int_lut(
double from,
double to,
int bit_depth,
bool inverse,
int scale)
const
78 boost::mutex::scoped_lock lm (
_mutex);
80 auto const descriptor = LUTDescriptor{from, to, bit_depth, inverse, scale};
82 auto i = _int_luts.find(descriptor);
83 if (i != _int_luts.end()) {
87 _int_luts[descriptor] = make_int_lut(from, to, bit_depth, inverse, scale);
88 return _int_luts[descriptor];
94 TransferFunction::make_int_lut(
double from,
double to,
int bit_depth,
bool inverse,
int scale)
const
96 auto source_lut = double_lut_unlocked(from, to, bit_depth, inverse);
97 auto const size = source_lut.size();
98 vector<int> lut(size);
99 for (
size_t i = 0; i < size; ++i) {
100 lut[i] = lrint(source_lut[i] * scale);
110 return from == other.from && to == other.to && bit_depth == other.bit_depth && inverse == other.inverse && scale == other.scale;
117 return std::hash<double>()(desc.from) ^
118 std::hash<double>()(desc.to) ^
119 std::hash<int>()(desc.bit_depth) ^
120 std::hash<bool>()(desc.inverse) ^
121 std::hash<int>()(desc.scale);
std::vector< double > const & double_lut(double from, double to, int bit_depth, bool inverse) const
Namespace for everything in libdcp.