diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-05-24 12:25:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-05-24 12:25:22 +0100 |
| commit | 85c699d29aab7ca7f7218b3f7f859e10c9025e37 (patch) | |
| tree | 0789324c390795f6628f2008d645b54000e4e088 /src | |
| parent | 043d382cb7360f35e97b9057045c6a255b905443 (diff) | |
Add somewhat speculative Rec 1886 and Rec 2020 colour conversions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/colour_conversion.cc | 38 | ||||
| -rw-r--r-- | src/colour_conversion.h | 2 | ||||
| -rw-r--r-- | src/modified_gamma_transfer_function.h | 7 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/colour_conversion.cc b/src/colour_conversion.cc index 8c48c2e1..46bc717e 100644 --- a/src/colour_conversion.cc +++ b/src/colour_conversion.cc @@ -97,6 +97,44 @@ ColourConversion::p3_to_xyz () return *c; } +ColourConversion const & +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 ColourConversion* c = new ColourConversion ( + shared_ptr<const TransferFunction> (new GammaTransferFunction (2.4)), + YUV_TO_RGB_REC709, + Chromaticity (0.64, 0.33), + Chromaticity (0.3, 0.6), + Chromaticity (0.15, 0.06), + /* D65 */ + Chromaticity (0.3127, 0.329), + optional<Chromaticity> (), + shared_ptr<const TransferFunction> (new GammaTransferFunction (2.6)) + ); + return *c; +} + +ColourConversion const & +ColourConversion::rec2020_to_xyz () +{ + /* From Wikipedia */ + static ColourConversion* c = new ColourConversion ( + shared_ptr<const TransferFunction> (new ModifiedGammaTransferFunction (1 / 0.45, 0.08145, 0.0993, 4.5)), + YUV_TO_RGB_REC709, + Chromaticity (0.708, 0.292), + Chromaticity (0.170, 0.797), + Chromaticity (0.131, 0.046), + /* D65 */ + Chromaticity (0.3127, 0.329), + optional<Chromaticity> (), + shared_ptr<const TransferFunction> (new GammaTransferFunction (2.6)) + ); + return *c; +} + ColourConversion::ColourConversion ( shared_ptr<const TransferFunction> in, YUVToRGB yuv_to_rgb, diff --git a/src/colour_conversion.h b/src/colour_conversion.h index 47071dd1..f974a182 100644 --- a/src/colour_conversion.h +++ b/src/colour_conversion.h @@ -139,6 +139,8 @@ public: 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 (); protected: /** Input transfer function (probably a gamma function, or something similar) */ diff --git a/src/modified_gamma_transfer_function.h b/src/modified_gamma_transfer_function.h index e8875d4b..c200743a 100644 --- a/src/modified_gamma_transfer_function.h +++ b/src/modified_gamma_transfer_function.h @@ -25,10 +25,15 @@ namespace dcp { -/** A transfer function which for an input x gives an output y where +/** A transfer function which for an input x gives a linear output y where * * y = x / B for x <= threshold * y = ((x + A) / (1 + A))^power for x > threshold + * + * The reverse transform is + * + * x = y * B for y <= threshold / B + * x = (1 + A) * y ^ (1 / power) - A for y > threshold / B */ class ModifiedGammaTransferFunction : public TransferFunction { |
