44 using std::dynamic_pointer_cast;
46 using std::shared_ptr;
51 ModifiedGammaTransferFunction::ModifiedGammaTransferFunction (
double power,
double threshold,
double A,
double B)
53 , _threshold (threshold)
62 ModifiedGammaTransferFunction::make_double_lut(
double from,
double to,
int bit_depth,
bool inverse)
const
64 int const bit_length = int(std::pow(2.0f, bit_depth));
65 auto lut = vector<double>(bit_length);
67 double const threshold = _threshold / _B;
68 for (
int i = 0; i < bit_length; ++i) {
69 double const p =
static_cast<double>(i) / (bit_length - 1);
70 double const q = (p * (to - from)) + from;
72 lut[i] = (1 + _A) * pow (q, 1 / _power) - _A;
78 for (
int i = 0; i < bit_length; ++i) {
79 double const p =
static_cast<double>(i) / (bit_length - 1);
80 double const q = (p * (to - from)) + from;
82 lut[i] = pow ((q + _A) / (1 + _A), _power);
94 ModifiedGammaTransferFunction::about_equal (shared_ptr<const TransferFunction> other,
double epsilon)
const
96 auto o = dynamic_pointer_cast<const ModifiedGammaTransferFunction>(other);
102 fabs(_power - o->_power) < epsilon &&
103 fabs(_threshold - o->_threshold) < epsilon &&
104 fabs(_A - o->_A) < epsilon &&
105 fabs(_B - o->_B) < epsilon
ModifiedGammaTransferFunction class.
Namespace for everything in libdcp.