summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-05-04 21:18:54 +0200
committerCarl Hetherington <cth@carlh.net>2025-05-04 21:18:54 +0200
commit6281e3d5e9ef094d7c8495dfa56a58c47be163ec (patch)
tree3d7db08be2a4e227e2b9d14f9c6db7f65feee5e2 /src
parent87cd4af7a2171000bb190c274633f28cf35e2223 (diff)
White space: colour_conversion.{cc,h}
Diffstat (limited to 'src')
-rw-r--r--src/colour_conversion.cc178
-rw-r--r--src/colour_conversion.h64
2 files changed, 121 insertions, 121 deletions
diff --git a/src/colour_conversion.cc b/src/colour_conversion.cc
index 5946273e..5c442d77 100644
--- a/src/colour_conversion.cc
+++ b/src/colour_conversion.cc
@@ -55,99 +55,99 @@ using namespace dcp;
ColourConversion const &
-ColourConversion::srgb_to_xyz ()
+ColourConversion::srgb_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<ModifiedGammaTransferFunction>(2.4, 0.04045, 0.055, 12.92),
YUVToRGB::REC601,
- Chromaticity (0.64, 0.33),
- Chromaticity (0.3, 0.6),
- Chromaticity (0.15, 0.06),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.64, 0.33),
+ Chromaticity(0.3, 0.6),
+ Chromaticity(0.15, 0.06),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
}
ColourConversion const &
-ColourConversion::rec601_to_xyz ()
+ColourConversion::rec601_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<GammaTransferFunction>(2.2),
YUVToRGB::REC601,
- Chromaticity (0.64, 0.33),
- Chromaticity (0.3, 0.6),
- Chromaticity (0.15, 0.06),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.64, 0.33),
+ Chromaticity(0.3, 0.6),
+ Chromaticity(0.15, 0.06),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
}
ColourConversion const &
-ColourConversion::rec709_to_xyz ()
+ColourConversion::rec709_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<GammaTransferFunction>(2.2),
YUVToRGB::REC709,
- Chromaticity (0.64, 0.33),
- Chromaticity (0.3, 0.6),
- Chromaticity (0.15, 0.06),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.64, 0.33),
+ Chromaticity(0.3, 0.6),
+ Chromaticity(0.15, 0.06),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
}
ColourConversion const &
-ColourConversion::p3_to_xyz ()
+ColourConversion::p3_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<GammaTransferFunction>(2.6),
YUVToRGB::REC709,
- Chromaticity (0.68, 0.32),
- Chromaticity (0.265, 0.69),
- Chromaticity (0.15, 0.06),
- Chromaticity (0.314, 0.351),
- optional<Chromaticity> (),
+ Chromaticity(0.68, 0.32),
+ Chromaticity(0.265, 0.69),
+ Chromaticity(0.15, 0.06),
+ Chromaticity(0.314, 0.351),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
}
ColourConversion const &
-ColourConversion::rec1886_to_xyz ()
+ColourConversion::rec1886_to_xyz()
{
/* According to Olivier on DCP-o-matic bug #832, Rec. 1886 is Rec. 709 with
2.4 gamma, so here goes ...
*/
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<GammaTransferFunction>(2.4),
YUVToRGB::REC709,
- Chromaticity (0.64, 0.33),
- Chromaticity (0.3, 0.6),
- Chromaticity (0.15, 0.06),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.64, 0.33),
+ Chromaticity(0.3, 0.6),
+ Chromaticity(0.15, 0.06),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
}
ColourConversion const &
-ColourConversion::rec2020_to_xyz ()
+ColourConversion::rec2020_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<GammaTransferFunction>(2.4),
YUVToRGB::REC2020,
- Chromaticity (0.708, 0.292),
- Chromaticity (0.170, 0.797),
- Chromaticity (0.131, 0.046),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.708, 0.292),
+ Chromaticity(0.170, 0.797),
+ Chromaticity(0.131, 0.046),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<GammaTransferFunction>(2.6)
);
return *c;
@@ -155,16 +155,16 @@ ColourConversion::rec2020_to_xyz ()
/** Sony S-Gamut3/S-Log3 */
ColourConversion const &
-ColourConversion::s_gamut3_to_xyz ()
+ColourConversion::s_gamut3_to_xyz()
{
- static auto c = new ColourConversion (
+ static auto c = new ColourConversion(
make_shared<SGamut3TransferFunction>(),
YUVToRGB::REC709,
- Chromaticity (0.73, 0.280),
- Chromaticity (0.140, 0.855),
- Chromaticity (0.100, -0.050),
- Chromaticity::D65 (),
- optional<Chromaticity> (),
+ Chromaticity(0.73, 0.280),
+ Chromaticity(0.140, 0.855),
+ Chromaticity(0.100, -0.050),
+ Chromaticity::D65(),
+ optional<Chromaticity>(),
make_shared<IdentityTransferFunction>()
);
return *c;
@@ -172,7 +172,7 @@ ColourConversion::s_gamut3_to_xyz ()
-ColourConversion::ColourConversion (
+ColourConversion::ColourConversion(
shared_ptr<const TransferFunction> in,
YUVToRGB yuv_to_rgb,
Chromaticity red,
@@ -182,31 +182,31 @@ ColourConversion::ColourConversion (
optional<Chromaticity> adjusted_white,
shared_ptr<const TransferFunction> out
)
- : _in (in)
- , _yuv_to_rgb (yuv_to_rgb)
- , _red (red)
- , _green (green)
- , _blue (blue)
- , _white (white)
- , _adjusted_white (adjusted_white)
- , _out (out)
+ : _in(in)
+ , _yuv_to_rgb(yuv_to_rgb)
+ , _red(red)
+ , _green(green)
+ , _blue(blue)
+ , _white(white)
+ , _adjusted_white(adjusted_white)
+ , _out(out)
{
}
bool
-ColourConversion::about_equal (ColourConversion const & other, float epsilon) const
+ColourConversion::about_equal(ColourConversion const & other, float epsilon) const
{
- if (!_in->about_equal (other._in, epsilon) ||
+ if (!_in->about_equal(other._in, epsilon) ||
_yuv_to_rgb != other._yuv_to_rgb ||
- !_red.about_equal (other._red, epsilon) ||
- !_green.about_equal (other._green, epsilon) ||
- !_blue.about_equal (other._blue, epsilon) ||
- !_white.about_equal (other._white, epsilon) ||
+ !_red.about_equal(other._red, epsilon) ||
+ !_green.about_equal(other._green, epsilon) ||
+ !_blue.about_equal(other._blue, epsilon) ||
+ !_white.about_equal(other._white, epsilon) ||
(!_out && other._out) ||
(_out && !other._out) ||
- (_out && !_out->about_equal (other._out, epsilon))) {
+ (_out && !_out->about_equal(other._out, epsilon))) {
return false;
}
@@ -216,8 +216,8 @@ ColourConversion::about_equal (ColourConversion const & other, float epsilon) co
if (
_adjusted_white && other._adjusted_white &&
- fabs (_adjusted_white.get().x - other._adjusted_white.get().x) < epsilon &&
- fabs (_adjusted_white.get().y - other._adjusted_white.get().y) < epsilon
+ fabs(_adjusted_white.get().x - other._adjusted_white.get().x) < epsilon &&
+ fabs(_adjusted_white.get().y - other._adjusted_white.get().y) < epsilon
) {
return true;
}
@@ -228,7 +228,7 @@ ColourConversion::about_equal (ColourConversion const & other, float epsilon) co
boost::numeric::ublas::matrix<double>
-ColourConversion::rgb_to_xyz () const
+ColourConversion::rgb_to_xyz() const
{
/* See doc/design/colour.tex */
@@ -237,7 +237,7 @@ ColourConversion::rgb_to_xyz () const
double const F = (_white.x - _green.x) * (_white.y - _blue.y) - (_white.x - _blue.x) * (_white.y - _green.y);
double const P = _red.y + _green.y * D / F + _blue.y * E / F;
- boost::numeric::ublas::matrix<double> C (3, 3);
+ boost::numeric::ublas::matrix<double> C(3, 3);
C(0, 0) = _red.x / P;
C(0, 1) = _green.x * D / (F * P);
C(0, 2) = _blue.x * E / (F * P);
@@ -252,33 +252,33 @@ ColourConversion::rgb_to_xyz () const
boost::numeric::ublas::matrix<double>
-ColourConversion::xyz_to_rgb () const
+ColourConversion::xyz_to_rgb() const
{
- boost::numeric::ublas::matrix<double> A (rgb_to_xyz());
+ boost::numeric::ublas::matrix<double> A(rgb_to_xyz());
/* permutation matrix for the LU-factorization */
- boost::numeric::ublas::permutation_matrix<std::size_t> pm (A.size1());
+ boost::numeric::ublas::permutation_matrix<std::size_t> pm(A.size1());
/* perform LU-factorization */
- int const r = lu_factorize (A, pm);
- DCP_ASSERT (r == 0);
+ int const r = lu_factorize(A, pm);
+ DCP_ASSERT(r == 0);
/* create identity matrix of inverse */
- boost::numeric::ublas::matrix<double> xyz_to_rgb (3, 3);
- xyz_to_rgb.assign (boost::numeric::ublas::identity_matrix<double> (A.size1()));
+ boost::numeric::ublas::matrix<double> xyz_to_rgb(3, 3);
+ xyz_to_rgb.assign(boost::numeric::ublas::identity_matrix<double>(A.size1()));
/* backsubstitute to get the inverse */
- lu_substitute (A, pm, xyz_to_rgb);
+ lu_substitute(A, pm, xyz_to_rgb);
return xyz_to_rgb;
}
boost::numeric::ublas::matrix<double>
-ColourConversion::bradford () const
+ColourConversion::bradford() const
{
- if (!_adjusted_white || fabs (_adjusted_white.get().x) < 1e-6 || fabs (_adjusted_white.get().y) < 1e-6) {
- boost::numeric::ublas::matrix<double> B = boost::numeric::ublas::zero_matrix<double> (3, 3);
+ if (!_adjusted_white || fabs(_adjusted_white.get().x) < 1e-6 || fabs(_adjusted_white.get().y) < 1e-6) {
+ boost::numeric::ublas::matrix<double> B = boost::numeric::ublas::zero_matrix<double>(3, 3);
B(0, 0) = 1;
B(1, 1) = 1;
B(2, 2) = 1;
@@ -287,7 +287,7 @@ ColourConversion::bradford () const
/* See doc/design/colour.tex */
- boost::numeric::ublas::matrix<double> M (3, 3);
+ boost::numeric::ublas::matrix<double> M(3, 3);
M(0, 0) = 0.8951;
M(0, 1) = 0.2664;
M(0, 2) = -0.1614;
@@ -298,7 +298,7 @@ ColourConversion::bradford () const
M(2, 1) = -0.0685;
M(2, 2) = 1.0296;
- boost::numeric::ublas::matrix<double> Mi (3, 3);
+ boost::numeric::ublas::matrix<double> Mi(3, 3);
Mi(0, 0) = 0.9869929055;
Mi(0, 1) = -0.1470542564;
Mi(0, 2) = 0.1599626517;
@@ -309,25 +309,25 @@ ColourConversion::bradford () const
Mi(2, 1) = 0.0400428217;
Mi(2, 2) = 0.9684866958;
- boost::numeric::ublas::matrix<double> Gp (3, 1);
+ boost::numeric::ublas::matrix<double> Gp(3, 1);
Gp(0, 0) = _white.x / _white.y;
Gp(1, 0) = 1;
Gp(2, 0) = (1 - _white.x - _white.y) / _white.y;
- boost::numeric::ublas::matrix<double> G = boost::numeric::ublas::prod (M, Gp);
+ boost::numeric::ublas::matrix<double> G = boost::numeric::ublas::prod(M, Gp);
- boost::numeric::ublas::matrix<double> Hp (3, 1);
+ boost::numeric::ublas::matrix<double> Hp(3, 1);
Hp(0, 0) = _adjusted_white.get().x / _adjusted_white.get().y;
Hp(1, 0) = 1;
Hp(2, 0) = (1 - _adjusted_white.get().x - _adjusted_white.get().y) / _adjusted_white.get().y;
- boost::numeric::ublas::matrix<double> H = boost::numeric::ublas::prod (M, Hp);
+ boost::numeric::ublas::matrix<double> H = boost::numeric::ublas::prod(M, Hp);
- boost::numeric::ublas::matrix<double> C = boost::numeric::ublas::zero_matrix<double> (3, 3);
+ boost::numeric::ublas::matrix<double> C = boost::numeric::ublas::zero_matrix<double>(3, 3);
C(0, 0) = H(0, 0) / G(0, 0);
C(1, 1) = H(1, 0) / G(1, 0);
C(2, 2) = H(2, 0) / G(2, 0);
- boost::numeric::ublas::matrix<double> CM = boost::numeric::ublas::prod (C, M);
- return boost::numeric::ublas::prod (Mi, CM);
+ boost::numeric::ublas::matrix<double> CM = boost::numeric::ublas::prod(C, M);
+ return boost::numeric::ublas::prod(Mi, CM);
}
diff --git a/src/colour_conversion.h b/src/colour_conversion.h
index 29140541..3cfbf969 100644
--- a/src/colour_conversion.h
+++ b/src/colour_conversion.h
@@ -71,11 +71,11 @@ enum class YUVToRGB {
class ColourConversion
{
public:
- ColourConversion ()
- : _yuv_to_rgb (YUVToRGB::REC601)
+ ColourConversion()
+ : _yuv_to_rgb(YUVToRGB::REC601)
{}
- ColourConversion (
+ ColourConversion(
std::shared_ptr<const TransferFunction> in,
YUVToRGB yuv_to_rgb,
Chromaticity red,
@@ -86,87 +86,87 @@ public:
std::shared_ptr<const TransferFunction> out
);
- std::shared_ptr<const TransferFunction> in () const {
+ std::shared_ptr<const TransferFunction> in() const {
return _in;
}
- YUVToRGB yuv_to_rgb () const {
+ YUVToRGB yuv_to_rgb() const {
return _yuv_to_rgb;
}
- Chromaticity red () const {
+ Chromaticity red() const {
return _red;
}
- Chromaticity green () const {
+ Chromaticity green() const {
return _green;
}
- Chromaticity blue () const {
+ Chromaticity blue() const {
return _blue;
}
- Chromaticity white () const {
+ Chromaticity white() const {
return _white;
}
- boost::optional<Chromaticity> adjusted_white () const {
+ boost::optional<Chromaticity> adjusted_white() const {
return _adjusted_white;
}
- std::shared_ptr<const TransferFunction> out () const {
+ std::shared_ptr<const TransferFunction> out() const {
return _out;
}
- void set_in (std::shared_ptr<const TransferFunction> f) {
+ void set_in(std::shared_ptr<const TransferFunction> f) {
_in = f;
}
- void set_yuv_to_rgb (YUVToRGB y) {
+ void set_yuv_to_rgb(YUVToRGB y) {
_yuv_to_rgb = y;
}
- void set_red (Chromaticity red) {
+ void set_red(Chromaticity red) {
_red = red;
}
- void set_green (Chromaticity green) {
+ void set_green(Chromaticity green) {
_green = green;
}
- void set_blue (Chromaticity blue) {
+ void set_blue(Chromaticity blue) {
_blue = blue;
}
- void set_white (Chromaticity white) {
+ void set_white(Chromaticity white) {
_white = white;
}
- void set_adjusted_white (Chromaticity adjusted_white) {
+ void set_adjusted_white(Chromaticity adjusted_white) {
_adjusted_white = adjusted_white;
}
- void unset_adjusted_white () {
- _adjusted_white = boost::optional<Chromaticity> ();
+ void unset_adjusted_white() {
+ _adjusted_white = boost::optional<Chromaticity>();
}
- void set_out (std::shared_ptr<const TransferFunction> f) {
+ void set_out(std::shared_ptr<const TransferFunction> f) {
_out = f;
}
- bool about_equal (ColourConversion const & other, float epsilon) const;
+ bool about_equal(ColourConversion const & other, float epsilon) const;
- boost::numeric::ublas::matrix<double> rgb_to_xyz () const;
- boost::numeric::ublas::matrix<double> xyz_to_rgb () const;
- boost::numeric::ublas::matrix<double> bradford () const;
+ boost::numeric::ublas::matrix<double> rgb_to_xyz() const;
+ boost::numeric::ublas::matrix<double> xyz_to_rgb() const;
+ boost::numeric::ublas::matrix<double> bradford() const;
- static ColourConversion const & srgb_to_xyz ();
- static ColourConversion const & rec601_to_xyz ();
- static ColourConversion const & rec709_to_xyz ();
- static ColourConversion const & p3_to_xyz ();
- static ColourConversion const & rec1886_to_xyz ();
- static ColourConversion const & rec2020_to_xyz ();
- static ColourConversion const & s_gamut3_to_xyz ();
+ static ColourConversion const & srgb_to_xyz();
+ static ColourConversion const & rec601_to_xyz();
+ static ColourConversion const & rec709_to_xyz();
+ static ColourConversion const & p3_to_xyz();
+ static ColourConversion const & rec1886_to_xyz();
+ static ColourConversion const & rec2020_to_xyz();
+ static ColourConversion const & s_gamut3_to_xyz();
protected:
/** Input transfer function (probably a gamma function, or something similar) */