X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=94d8a69a289018f1b2e67d9f3a06bd76c65a9ae8;hb=b6235aa37eac2c91358ff058389b4391b52f4615;hp=2b7b81cfeec2a3b067ab482c264eeea49a30ec6b;hpb=b6c780d3107557d452c6612d715d01e2be52dbda;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index 2b7b81cfe..94d8a69a2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington 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 @@ -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,15 +66,14 @@ 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) , _check_for_test_updates (false) , _maximum_j2k_bandwidth (250000000) - , _log_types (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR) + , _log_types (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR | Log::TYPE_DEBUG) #ifdef DCPOMATIC_WINDOWS , _win32_console (false) #endif @@ -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,18 @@ 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) { + /* This is a bit of a hack; use 32 (the first Film state file version for the 2.x branch) + for version 2 and 10 (the current Film state version for the 1.x branch) for version 1. + */ + _colour_conversions.push_back (PresetColourConversion (*i, version == 2 ? 32 : 10)); + } + } 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 +325,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 +379,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