#include <cmath>
+using std::dynamic_pointer_cast;
using std::pow;
using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::vector;
using namespace dcp;
}
-double *
+vector<double>
GammaTransferFunction::make_lut (int bit_depth, bool inverse) const
{
int const bit_length = int(std::pow(2.0f, bit_depth));
- auto lut = new double[bit_length];
+ auto lut = vector<double>(bit_length);
double const gamma = inverse ? (1 / _gamma) : _gamma;
for (int i = 0; i < bit_length; ++i) {
lut[i] = pow(double(i) / (bit_length - 1), gamma);
bool about_equal (std::shared_ptr<const TransferFunction> other, double epsilon) const override;
protected:
- double * make_lut (int bit_depth, bool inverse) const override;
+ std::vector<double> make_lut (int bit_depth, bool inverse) const override;
private:
double _gamma;
#include <cmath>
+using std::dynamic_pointer_cast;
using std::pow;
using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::vector;
using namespace dcp;
-double *
+vector<double>
IdentityTransferFunction::make_lut (int bit_depth, bool) const
{
int const bit_length = int(std::pow(2.0f, bit_depth));
- auto lut = new double[bit_length];
+ auto lut = vector<double>(bit_length);
for (int i = 0; i < bit_length; ++i) {
lut[i] = double(i) / (bit_length - 1);
}
bool about_equal (std::shared_ptr<const TransferFunction> other, double epsilon) const override;
protected:
- double * make_lut (int bit_depth, bool inverse) const override;
+ std::vector<double> make_lut (int bit_depth, bool inverse) const override;
};
#include <cmath>
+using std::dynamic_pointer_cast;
using std::pow;
using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::vector;
using namespace dcp;
}
-double *
+vector<double>
ModifiedGammaTransferFunction::make_lut (int bit_depth, bool inverse) const
{
int const bit_length = int(std::pow(2.0f, bit_depth));
- double* lut = new double[bit_length];
+ auto lut = vector<double>(bit_length);
if (inverse) {
double const threshold = _threshold / _B;
for (int i = 0; i < bit_length; ++i) {
bool about_equal (std::shared_ptr<const TransferFunction>, double epsilon) const override;
protected:
- double * make_lut (int bit_depth, bool inverse) const override;
+ std::vector<double> make_lut (int bit_depth, bool inverse) const override;
private:
double _power;
int* xyz_y = xyz_image->data (1);
int* xyz_z = xyz_image->data (2);
- double const * lut_in = conversion.out()->lut (12, false);
- double const * lut_out = conversion.in()->lut (16, true);
+ auto lut_in = conversion.out()->lut (12, false);
+ auto lut_out = conversion.in()->lut (16, true);
boost::numeric::ublas::matrix<double> const matrix = conversion.xyz_to_rgb ();
double fast_matrix[9] = {
int* xyz_y = xyz_image->data (1);
int* xyz_z = xyz_image->data (2);
- double const * lut_in = conversion.out()->lut (12, false);
- double const * lut_out = conversion.in()->lut (16, true);
+ auto lut_in = conversion.out()->lut (12, false);
+ auto lut_out = conversion.in()->lut (16, true);
auto const matrix = conversion.xyz_to_rgb ();
double fast_matrix[9] = {
double x, y, z;
} d;
- auto const * lut_in = conversion.in()->lut (12, false);
- auto const * lut_out = conversion.out()->lut (16, true);
+ auto lut_in = conversion.in()->lut (12, false);
+ auto lut_out = conversion.out()->lut (16, true);
/* This is is the product of the RGB to XYZ matrix, the Bradford transform and the DCI companding */
double fast_matrix[9];
#include <cmath>
+using std::dynamic_pointer_cast;
using std::pow;
using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::vector;
using namespace dcp;
-double *
+vector<double>
SGamut3TransferFunction::make_lut (int bit_depth, bool inverse) const
{
int const bit_length = int(std::pow(2.0f, bit_depth));
- double* lut = new double[bit_length];
+ auto lut = vector<double>(bit_length);
if (inverse) {
for (int i = 0; i < bit_length; ++i) {
auto const p = static_cast<double>(i) / (bit_length - 1);
bool about_equal (std::shared_ptr<const TransferFunction> other, double epsilon) const override;
protected:
- double * make_lut (int bit_depth, bool inverse) const override;
+ std::vector<double> make_lut (int bit_depth, bool inverse) const override;
};
#include <cmath>
-using std::pow;
+using std::make_pair;
using std::map;
using std::pair;
-using std::make_pair;
+using std::pow;
using std::shared_ptr;
+using std::vector;
using namespace dcp;
-TransferFunction::~TransferFunction ()
-{
- boost::mutex::scoped_lock lm (_mutex);
-
- for (auto const& i: _luts) {
- delete[] i.second;
- }
-
- _luts.clear ();
-}
-
-
-double const *
+vector<double> const&
TransferFunction::lut (int bit_depth, bool inverse) const
{
boost::mutex::scoped_lock lm (_mutex);
#include <boost/thread/mutex.hpp>
#include <map>
#include <memory>
+#include <vector>
namespace dcp {
public:
TransferFunction () {}
- TransferFunction (TransferFunction const&) = delete;
- TransferFunction& operator= (TransferFunction const&) = delete;
-
- virtual ~TransferFunction ();
+ virtual ~TransferFunction () {}
/** @return A look-up table (of size 2^bit_depth) whose values range from 0 to 1 */
- double const * lut (int bit_depth, bool inverse) const;
+ std::vector<double> const& lut (int bit_depth, bool inverse) const;
virtual bool about_equal (std::shared_ptr<const TransferFunction> other, double epsilon) const = 0;
protected:
/** Make a LUT and return an array allocated by new */
- virtual double * make_lut (int bit_depth, bool inverse) const = 0;
+ virtual std::vector<double> make_lut (int bit_depth, bool inverse) const = 0;
private:
- mutable std::map<std::pair<int, bool>, double*> _luts;
+ mutable std::map<std::pair<int, bool>, std::vector<double>> _luts;
/** mutex to protect _luts */
mutable boost::mutex _mutex;
};
static void
check_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, bool inverse, float gamma)
{
- double const * lut = tf->lut (bit_depth, inverse);
+ auto lut = tf->lut (bit_depth, inverse);
int const count = rint (pow (2.0, bit_depth));
for (int i = 0; i < count; ++i) {
static void
check_modified_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, bool inverse, double power, double threshold, double A, double B)
{
- double const * lut = tf->lut (bit_depth, inverse);
+ auto lut = tf->lut (bit_depth, inverse);
int const count = rint (pow (2.0, bit_depth));
for (int i = 0; i < count; ++i) {