}
-ColourConversion::ColourConversion (cxml::NodePtr node)
+ColourConversion::ColourConversion (cxml::NodePtr node, int version)
{
shared_ptr<dcp::TransferFunction> in;
-
- cxml::ConstNodePtr in_node = node->node_child ("InputTransferFunction");
- string in_type = in_node->string_child ("Type");
- if (in_type == "Gamma") {
- _in.reset (new dcp::GammaTransferFunction (false, in_node->number_child<double> ("Gamma")));
- } else if (in_type == "ModifiedGamma") {
- _in.reset (new dcp::ModifiedGammaTransferFunction (
- false,
- in_node->number_child<double> ("Power"),
- in_node->number_child<double> ("Threshold"),
- in_node->number_child<double> ("A"),
- in_node->number_child<double> ("B")
- ));
+
+ if (version >= 32) {
+
+ /* Version 2.x */
+
+ cxml::ConstNodePtr in_node = node->node_child ("InputTransferFunction");
+ string in_type = in_node->string_child ("Type");
+ if (in_type == "Gamma") {
+ _in.reset (new dcp::GammaTransferFunction (false, in_node->number_child<double> ("Gamma")));
+ } else if (in_type == "ModifiedGamma") {
+ _in.reset (new dcp::ModifiedGammaTransferFunction (
+ false,
+ in_node->number_child<double> ("Power"),
+ in_node->number_child<double> ("Threshold"),
+ in_node->number_child<double> ("A"),
+ in_node->number_child<double> ("B")
+ ));
+ }
+
+ } else {
+
+ /* Version 1.x */
+
+ if (node->bool_child ("InputGammaLinearised")) {
+ _in.reset (new dcp::ModifiedGammaTransferFunction (false, node->number_child<float> ("InputGamma"), 0.04045, 0.055, 12.92));
+ } else {
+ _in.reset (new dcp::GammaTransferFunction (false, node->number_child<float> ("InputGamma")));
+ }
}
list<cxml::NodePtr> m = node->node_children ("Matrix");
int const tj = (*i)->number_attribute<int> ("j");
_matrix(ti, tj) = raw_convert<double> ((*i)->content ());
}
-
+
_out.reset (new dcp::GammaTransferFunction (true, node->number_child<double> ("OutputGamma")));
}
boost::optional<ColourConversion>
-ColourConversion::from_xml (cxml::NodePtr node)
+ColourConversion::from_xml (cxml::NodePtr node, int version)
{
if (!node->optional_node_child ("InputTransferFunction")) {
return boost::optional<ColourConversion> ();
}
- return ColourConversion (node);
+ return ColourConversion (node, version);
}
void
}
-PresetColourConversion::PresetColourConversion (cxml::NodePtr node)
- : conversion (node)
+PresetColourConversion::PresetColourConversion (cxml::NodePtr node, int version)
+ : conversion (node, version)
{
name = node->string_child ("Name");
}
public:
ColourConversion ();
ColourConversion (dcp::ColourConversion);
- ColourConversion (cxml::NodePtr);
+ ColourConversion (cxml::NodePtr, int version);
virtual void as_xml (xmlpp::Node *) const;
std::string identifier () const;
boost::optional<size_t> preset () const;
- static boost::optional<ColourConversion> from_xml (cxml::NodePtr);
+ static boost::optional<ColourConversion> from_xml (cxml::NodePtr, int version);
};
class PresetColourConversion
public:
PresetColourConversion ();
PresetColourConversion (std::string, dcp::ColourConversion);
- PresetColourConversion (cxml::NodePtr);
+ PresetColourConversion (cxml::NodePtr node, int version);
void as_xml (xmlpp::Node *) const;
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "image_proxy.h"
#include "j2k_image_proxy.h"
#include "scaler.h"
+#include "film.h"
using std::string;
using std::cout;
_scaler = Scaler::from_id (node->string_child ("Scaler"));
_eyes = (Eyes) node->number_child<int> ("Eyes");
_part = (Part) node->number_child<int> ("Part");
- _colour_conversion = ColourConversion::from_xml (node);
+
+ /* Assume that the ColourConversion uses the current state version */
+ _colour_conversion = ColourConversion::from_xml (node, Film::current_state_version);
_in = image_proxy_factory (node->node_child ("In"), socket);