*/
+/** @file src/gamma_transfer_function.cc
+ * @brief GammaTransferFunction class.
+ */
+
#include "gamma_transfer_function.h"
#include <cmath>
using boost::dynamic_pointer_cast;
using namespace dcp;
-GammaTransferFunction::GammaTransferFunction (float gamma)
+GammaTransferFunction::GammaTransferFunction (double gamma)
: _gamma (gamma)
{
}
-float *
-GammaTransferFunction::make_lut (int bit_depth) const
+double *
+GammaTransferFunction::make_lut (int bit_depth, bool inverse) const
{
- int const bit_length = pow (2, bit_depth);
- float* lut = new float[int(std::pow(2.0f, bit_depth))];
+ int const bit_length = int(std::pow(2.0f, bit_depth));
+ double* lut = new double[bit_length];
+ double const gamma = inverse ? (1 / _gamma) : _gamma;
for (int i = 0; i < bit_length; ++i) {
- lut[i] = pow(float(i) / (bit_length - 1), _gamma);
+ lut[i] = pow(double(i) / (bit_length - 1), gamma);
}
return lut;
}
bool
-GammaTransferFunction::about_equal (shared_ptr<const TransferFunction> other, float epsilon) const
+GammaTransferFunction::about_equal (shared_ptr<const TransferFunction> other, double epsilon) const
{
shared_ptr<const GammaTransferFunction> o = dynamic_pointer_cast<const GammaTransferFunction> (other);
if (!o) {