Rename MD5Digester -> Digester.
[dcpomatic.git] / src / lib / colour_conversion.cc
index 31d4cc41a6dc3f33836015a9d87b3a68a0a39ab2..f17964ddccb0521cdcf9df31aa45832503ec2d9b 100644 (file)
@@ -1,26 +1,27 @@
 /*
     Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 #include "config.h"
 #include "colour_conversion.h"
 #include "util.h"
-#include "md5_digester.h"
+#include "digester.h"
 #include "raw_convert.h"
 #include <dcp/chromaticity.h>
 #include <dcp/colour_matrix.h>
@@ -29,6 +30,7 @@
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -80,9 +82,9 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version)
                /* Version 1.x */
 
                if (node->bool_child ("InputGammaLinearised")) {
-                       _in.reset (new dcp::ModifiedGammaTransferFunction (node->number_child<float> ("InputGamma"), 0.04045, 0.055, 12.92));
+                       _in.reset (new dcp::ModifiedGammaTransferFunction (node->number_child<double> ("InputGamma"), 0.04045, 0.055, 12.92));
                } else {
-                       _in.reset (new dcp::GammaTransferFunction (node->number_child<float> ("InputGamma")));
+                       _in.reset (new dcp::GammaTransferFunction (node->number_child<double> ("InputGamma")));
                }
        }
 
@@ -149,6 +151,7 @@ ColourConversion::as_xml (xmlpp::Node* node) const
                in_node->add_child("B")->add_child_text (raw_convert<string> (tf->B ()));
        }
 
+       node->add_child("YUVToRGB")->add_child_text (raw_convert<string> (_yuv_to_rgb));
        node->add_child("RedX")->add_child_text (raw_convert<string> (_red.x));
        node->add_child("RedY")->add_child_text (raw_convert<string> (_red.y));
        node->add_child("GreenX")->add_child_text (raw_convert<string> (_green.x));
@@ -170,7 +173,7 @@ ColourConversion::preset () const
 {
        vector<PresetColourConversion> presets = PresetColourConversion::all ();
        size_t i = 0;
-       while (i < presets.size() && (presets[i].conversion != *this)) {
+       while (i < presets.size() && presets[i].conversion != *this) {
                ++i;
        }
 
@@ -184,7 +187,7 @@ ColourConversion::preset () const
 string
 ColourConversion::identifier () const
 {
-       MD5Digester digester;
+       Digester digester;
 
        if (dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in)) {
                shared_ptr<const dcp::GammaTransferFunction> tf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in);
@@ -262,6 +265,8 @@ PresetColourConversion::setup_colour_conversion_presets ()
        _presets.push_back (PresetColourConversion (_("Rec. 601"), "rec601", dcp::ColourConversion::rec601_to_xyz ()));
        _presets.push_back (PresetColourConversion (_("Rec. 709"), "rec709", dcp::ColourConversion::rec709_to_xyz ()));
        _presets.push_back (PresetColourConversion (_("P3"), "p3", dcp::ColourConversion::p3_to_xyz ()));
+       _presets.push_back (PresetColourConversion (_("Rec. 1886"), "rec1886", dcp::ColourConversion::rec1886_to_xyz ()));
+       _presets.push_back (PresetColourConversion (_("Rec. 2020"), "rec2020", dcp::ColourConversion::rec2020_to_xyz ()));
 }
 
 PresetColourConversion
@@ -275,4 +280,3 @@ PresetColourConversion::from_id (string s)
 
        DCPOMATIC_ASSERT (false);
 }
-