summaryrefslogtreecommitdiff
path: root/src/modified_gamma_transfer_function.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-24 04:15:26 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-24 04:15:26 +0100
commitceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 (patch)
treec55e4b85ee30138ce83263045d77d01631378b2e /src/modified_gamma_transfer_function.cc
parent6c37cc1979b2a01205a888c4c98f3334685ee8dd (diff)
Tidying.
Diffstat (limited to 'src/modified_gamma_transfer_function.cc')
-rw-r--r--src/modified_gamma_transfer_function.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/modified_gamma_transfer_function.cc b/src/modified_gamma_transfer_function.cc
index bb388689..039e9284 100644
--- a/src/modified_gamma_transfer_function.cc
+++ b/src/modified_gamma_transfer_function.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -31,14 +31,22 @@
files in the program, then also delete it here.
*/
+
+/** @file src/modified_gamma_transfer_function.cc
+ * @brief ModifiedGammaTransferFunction class
+ */
+
+
#include "modified_gamma_transfer_function.h"
#include <cmath>
+
using std::pow;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using namespace dcp;
+
ModifiedGammaTransferFunction::ModifiedGammaTransferFunction (double power, double threshold, double A, double B)
: _power (power)
, _threshold (threshold)
@@ -48,6 +56,7 @@ ModifiedGammaTransferFunction::ModifiedGammaTransferFunction (double power, doub
}
+
double *
ModifiedGammaTransferFunction::make_lut (int bit_depth, bool inverse) const
{
@@ -56,7 +65,7 @@ ModifiedGammaTransferFunction::make_lut (int bit_depth, bool inverse) const
if (inverse) {
double const threshold = _threshold / _B;
for (int i = 0; i < bit_length; ++i) {
- double const p = static_cast<double> (i) / (bit_length - 1);
+ double const p = static_cast<double>(i) / (bit_length - 1);
if (p > threshold) {
lut[i] = (1 + _A) * pow (p, 1 / _power) - _A;
} else {
@@ -65,7 +74,7 @@ ModifiedGammaTransferFunction::make_lut (int bit_depth, bool inverse) const
}
} else {
for (int i = 0; i < bit_length; ++i) {
- double const p = static_cast<double> (i) / (bit_length - 1);
+ double const p = static_cast<double>(i) / (bit_length - 1);
if (p > _threshold) {
lut[i] = pow ((p + _A) / (1 + _A), _power);
} else {
@@ -77,18 +86,19 @@ ModifiedGammaTransferFunction::make_lut (int bit_depth, bool inverse) const
return lut;
}
+
bool
ModifiedGammaTransferFunction::about_equal (shared_ptr<const TransferFunction> other, double epsilon) const
{
- shared_ptr<const ModifiedGammaTransferFunction> o = dynamic_pointer_cast<const ModifiedGammaTransferFunction> (other);
+ auto o = dynamic_pointer_cast<const ModifiedGammaTransferFunction>(other);
if (!o) {
return false;
}
return (
- fabs (_power - o->_power) < epsilon &&
- fabs (_threshold - o->_threshold) < epsilon &&
- fabs (_A - o->_A) < epsilon &&
- fabs (_B - o->_B) < epsilon
+ fabs(_power - o->_power) < epsilon &&
+ fabs(_threshold - o->_threshold) < epsilon &&
+ fabs(_A - o->_A) < epsilon &&
+ fabs(_B - o->_B) < epsilon
);
}