45 using std::shared_ptr;
46 using std::dynamic_pointer_cast;
50 ModifiedGammaTransferFunction::ModifiedGammaTransferFunction (
double power,
double threshold,
double A,
double B)
52 , _threshold (threshold)
61 ModifiedGammaTransferFunction::make_lut (
int bit_depth,
bool inverse)
const
63 int const bit_length = int(std::pow(2.0f, bit_depth));
64 double*
lut =
new double[bit_length];
66 double const threshold = _threshold / _B;
67 for (
int i = 0; i < bit_length; ++i) {
68 double const p =
static_cast<double>(i) / (bit_length - 1);
70 lut[i] = (1 + _A) * pow (p, 1 / _power) - _A;
76 for (
int i = 0; i < bit_length; ++i) {
77 double const p =
static_cast<double>(i) / (bit_length - 1);
79 lut[i] = pow ((p + _A) / (1 + _A), _power);
91 ModifiedGammaTransferFunction::about_equal (shared_ptr<const TransferFunction> other,
double epsilon)
const
93 auto o = dynamic_pointer_cast<const ModifiedGammaTransferFunction>(other);
99 fabs(_power - o->_power) < epsilon &&
100 fabs(_threshold - o->_threshold) < epsilon &&
101 fabs(_A - o->_A) < epsilon &&
102 fabs(_B - o->_B) < epsilon
double const * lut(int bit_depth, bool inverse) const
ModifiedGammaTransferFunction class.
Namespace for everything in libdcp.