X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcolour_conversion.cc;h=de69c21139c565dc74263087d1faa157bd263210;hb=8d56ea4bbff391dd72981f86001245a595fa9c62;hp=04589cf439b62a15af1ffbb512e5d9adc33d1fc0;hpb=f9cba324c8160a70b108d9e5b60a4ccad6ee9be2;p=libdcp.git diff --git a/src/colour_conversion.cc b/src/colour_conversion.cc index 04589cf4..de69c211 100644 --- a/src/colour_conversion.cc +++ b/src/colour_conversion.cc @@ -16,18 +16,32 @@ You should have received a copy of the GNU General Public License along with libdcp. If not, see . + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the + OpenSSL library under certain conditions as described in each + individual source file, and distribute linked combinations + including the two. + + You must obey the GNU General Public License in all respects + for all of the code used other than OpenSSL. If you modify + file(s) with this exception, you may extend this exception to your + version of the file(s), but you are not obligated to do so. If you + do not wish to do so, delete this exception statement from your + version. If you delete this exception statement from all source + files in the program, then also delete it here. */ #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; @@ -40,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)) ); @@ -57,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)) ); @@ -74,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)) ); @@ -110,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)) ); @@ -121,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, @@ -167,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; }