X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=d43024128915d19046c1e6150cc87bcb31f20250;hp=2b7b81cfeec2a3b067ab482c264eeea49a30ec6b;hb=6d25faad09cec21a39fd81d140c57542eceb0a6f;hpb=e491397c0028a80ac4a48a92007f783746553c1a diff --git a/src/lib/config.cc b/src/lib/config.cc index 2b7b81cfe..d43024128 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -17,16 +17,6 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "config.h" #include "server.h" #include "scaler.h" @@ -38,6 +28,16 @@ #include "cinema.h" #include "util.h" #include "cross.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "i18n.h" @@ -52,8 +52,7 @@ using std::exception; using std::cerr; using boost::shared_ptr; using boost::optional; -using boost::algorithm::is_any_of; -using boost::algorithm::split; +using boost::algorithm::trim; using dcp::raw_convert; Config* Config::_instance = 0; @@ -67,9 +66,8 @@ Config::Config () , _cinema_sound_processor (CinemaSoundProcessor::from_id (N_("dolby_cp750"))) , _allow_any_dcp_frame_rate (false) , _default_still_length (10) - , _default_scale (VideoContentScale (Ratio::from_id ("185"))) , _default_container (Ratio::from_id ("185")) - , _default_dcp_content_type (DCPContentType::from_isdcf_name ("TST")) + , _default_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")) , _default_j2k_bandwidth (100000000) , _default_audio_delay (0) , _check_for_updates (false) @@ -87,9 +85,8 @@ Config::Config () _allowed_dcp_frame_rates.push_back (50); _allowed_dcp_frame_rates.push_back (60); - _colour_conversions.push_back (PresetColourConversion (_("sRGB"), 2.4, true, dcp::colour_matrix::srgb_to_xyz, 2.6)); - _colour_conversions.push_back (PresetColourConversion (_("sRGB non-linearised"), 2.4, false, dcp::colour_matrix::srgb_to_xyz, 2.6)); - _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), 2.2, false, dcp::colour_matrix::rec709_to_xyz, 2.6)); + _colour_conversions.push_back (PresetColourConversion (_("sRGB"), dcp::ColourConversion::srgb_to_xyz ())); + _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), dcp::ColourConversion::rec709_to_xyz ())); reset_kdm_email (); } @@ -148,11 +145,6 @@ Config::read () _language = f.optional_string_child ("Language"); - c = f.optional_string_child ("DefaultScale"); - if (c) { - _default_scale = VideoContentScale::from_id (c.get ()); - } - c = f.optional_string_child ("DefaultContainer"); if (c) { _default_container = Ratio::from_id (c.get ()); @@ -184,16 +176,15 @@ Config::read () if (!cc.empty ()) { _colour_conversions.clear (); } - - for (list::iterator i = cc.begin(); i != cc.end(); ++i) { - _colour_conversions.push_back (PresetColourConversion (*i)); - } - if (!version) { - /* Loading version 0 (before Rec. 709 was added as a preset). - Add it in. - */ - _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), 2.2, false, dcp::colour_matrix::rec709_to_xyz, 2.6)); + try { + for (list::iterator i = cc.begin(); i != cc.end(); ++i) { + _colour_conversions.push_back (PresetColourConversion (*i)); + } + } catch (cxml::Error) { + /* Probably failed to load an old-style ColourConversion tag; just give up */ + _colour_conversions.push_back (PresetColourConversion (_("sRGB"), dcp::ColourConversion::srgb_to_xyz ())); + _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), dcp::ColourConversion::rec709_to_xyz ())); } list cin = f.node_children ("Cinema"); @@ -331,7 +322,6 @@ Config::write () const if (_language) { root->add_child("Language")->add_child_text (_language.get()); } - root->add_child("DefaultScale")->add_child_text (_default_scale.id ()); if (_default_container) { root->add_child("DefaultContainer")->add_child_text (_default_container->id ()); } @@ -386,8 +376,14 @@ Config::write () const for (vector::const_iterator i = _history.begin(); i != _history.end(); ++i) { root->add_child("History")->add_child_text (i->string ()); } - - doc.write_to_file_formatted (file().string ()); + + try { + doc.write_to_file_formatted (file().string ()); + } catch (xmlpp::exception& e) { + string s = e.what (); + trim (s); + throw FileError (s, file ()); + } } boost::filesystem::path