X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcolour_conversion.cc;h=de69c21139c565dc74263087d1faa157bd263210;hb=d39880eef211a296fa8ef4712cdef5945d08527c;hp=be5e999c4955b54f175a826553393fa4f4d666dd;hpb=d927e9b913606f4fc982885c7582ecaf0e3c5a1a;p=libdcp.git diff --git a/src/colour_conversion.cc b/src/colour_conversion.cc index be5e999c..de69c211 100644 --- a/src/colour_conversion.cc +++ b/src/colour_conversion.cc @@ -34,13 +34,14 @@ #include "colour_conversion.h" #include "gamma_transfer_function.h" #include "modified_gamma_transfer_function.h" -#include "colour_matrix.h" +#include "s_gamut3_transfer_function.h" +#include "identity_transfer_function.h" #include "dcp_assert.h" #include #include #include -using boost::shared_ptr; +using std::shared_ptr; using boost::optional; using namespace dcp; @@ -53,8 +54,7 @@ ColourConversion::srgb_to_xyz () Chromaticity (0.64, 0.33), Chromaticity (0.3, 0.6), Chromaticity (0.15, 0.06), - /* D65 */ - Chromaticity (0.3127, 0.329), + Chromaticity::D65 (), optional (), shared_ptr (new GammaTransferFunction (2.6)) ); @@ -70,8 +70,7 @@ ColourConversion::rec601_to_xyz () Chromaticity (0.64, 0.33), Chromaticity (0.3, 0.6), Chromaticity (0.15, 0.06), - /* D65 */ - Chromaticity (0.3127, 0.329), + Chromaticity::D65 (), optional (), shared_ptr (new GammaTransferFunction (2.6)) ); @@ -87,8 +86,7 @@ ColourConversion::rec709_to_xyz () Chromaticity (0.64, 0.33), Chromaticity (0.3, 0.6), Chromaticity (0.15, 0.06), - /* D65 */ - Chromaticity (0.3127, 0.329), + Chromaticity::D65 (), optional (), shared_ptr (new GammaTransferFunction (2.6)) ); @@ -123,8 +121,7 @@ ColourConversion::rec1886_to_xyz () Chromaticity (0.64, 0.33), Chromaticity (0.3, 0.6), Chromaticity (0.15, 0.06), - /* D65 */ - Chromaticity (0.3127, 0.329), + Chromaticity::D65 (), optional (), shared_ptr (new GammaTransferFunction (2.6)) ); @@ -134,21 +131,38 @@ ColourConversion::rec1886_to_xyz () ColourConversion const & ColourConversion::rec2020_to_xyz () { - /* From Wikipedia */ static ColourConversion* c = new ColourConversion ( - shared_ptr (new ModifiedGammaTransferFunction (1 / 0.45, 0.08145, 0.0993, 4.5)), + shared_ptr (new GammaTransferFunction (2.4)), 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), + Chromaticity::D65 (), optional (), shared_ptr (new GammaTransferFunction (2.6)) ); return *c; } +/** Sony S-Gamut3/S-Log3 */ +ColourConversion const & +ColourConversion::s_gamut3_to_xyz () +{ + static ColourConversion* c = new ColourConversion ( + shared_ptr (new SGamut3TransferFunction ()), + YUV_TO_RGB_REC709, + Chromaticity (0.73, 0.280), + Chromaticity (0.140, 0.855), + Chromaticity (0.100, -0.050), + Chromaticity::D65 (), + optional (), + shared_ptr (new IdentityTransferFunction ()) + ); + return *c; +} + + + ColourConversion::ColourConversion ( shared_ptr in, YUVToRGB yuv_to_rgb, @@ -180,7 +194,9 @@ ColourConversion::about_equal (ColourConversion const & other, float epsilon) co !_green.about_equal (other._green, epsilon) || !_blue.about_equal (other._blue, epsilon) || !_white.about_equal (other._white, epsilon) || - !_out->about_equal (other._out, epsilon)) { + (!_out && other._out) || + (_out && !other._out) || + (_out && !_out->about_equal (other._out, epsilon))) { return false; }