From: Carl Hetherington Date: Wed, 16 Jul 2014 16:02:25 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' into 1.0 X-Git-Tag: v2.0.48~716 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=1f82930e73679d6aec5223caa255f564339a1a2a;hp=-c Merge remote-tracking branch 'origin/master' into 1.0 --- 1f82930e73679d6aec5223caa255f564339a1a2a diff --combined ChangeLog index 5265423fc,e225fb565..a15a44fe2 --- a/ChangeLog +++ b/ChangeLog @@@ -1,19 -1,7 +1,21 @@@ +2014-07-15 Carl Hetherington + + * A variety of changes were made on the 2.0 branch + but not documented in the ChangeLog. Most sigificantly: + + - DCP import + - Creation of DCPs with proper XML subtitles + - Import of .srt and .xml subtitles + - Audio processing framework (with some basic processors). + +2014-03-07 Carl Hetherington + + * Add subtitle view. + 2014-07-16 Carl Hetherington + * Add default scaling setting to preferences (#384). + * Version 1.72.3 released. 2014-07-16 Carl Hetherington @@@ -37,7 -25,6 +39,7 @@@ 2014-07-10 Carl Hetherington * Version 1.72.2 released. +>>>>>>> origin/master 2014-07-10 Carl Hetherington diff --combined src/lib/config.cc index 71431ec0d,0588f01da..f2f25efe9 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@@ -23,8 -23,8 +23,8 @@@ #include #include #include -#include -#include +#include +#include #include #include "config.h" #include "server.h" @@@ -32,7 -32,7 +32,7 @@@ #include "filter.h" #include "ratio.h" #include "dcp_content_type.h" -#include "sound_processor.h" +#include "cinema_sound_processor.h" #include "colour_conversion.h" #include "cinema.h" #include "util.h" @@@ -50,7 -50,7 +50,7 @@@ using boost::shared_ptr using boost::optional; using boost::algorithm::is_any_of; using boost::algorithm::split; -using libdcp::raw_convert; +using dcp::raw_convert; Config* Config::_instance = 0; @@@ -60,9 -60,10 +60,10 @@@ Config::Config ( , _server_port_base (6192) , _use_any_servers (true) , _tms_path (".") - , _sound_processor (SoundProcessor::from_id (N_("dolby_cp750"))) + , _cinema_sound_processor (CinemaSoundProcessor::from_id (N_("dolby_cp750"))) , _allow_any_dcp_frame_rate (false) , _default_still_length (10) + , _default_scale (Ratio::from_id ("185")) , _default_container (Ratio::from_id ("185")) , _default_dcp_content_type (DCPContentType::from_isdcf_name ("TST")) , _default_j2k_bandwidth (100000000) @@@ -79,9 -80,9 +80,9 @@@ _allowed_dcp_frame_rates.push_back (50); _allowed_dcp_frame_rates.push_back (60); - _colour_conversions.push_back (PresetColourConversion (_("sRGB"), 2.4, true, libdcp::colour_matrix::srgb_to_xyz, 2.6)); - _colour_conversions.push_back (PresetColourConversion (_("sRGB non-linearised"), 2.4, false, libdcp::colour_matrix::srgb_to_xyz, 2.6)); - _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), 2.2, false, libdcp::colour_matrix::rec709_to_xyz, 2.6)); + _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)); reset_kdm_email (); } @@@ -90,6 -91,7 +91,6 @@@ voi Config::read () { if (!boost::filesystem::exists (file (false))) { - read_old_metadata (); return; } @@@ -127,15 -129,16 +128,20 @@@ c = f.optional_string_child ("SoundProcessor"); if (c) { - _sound_processor = SoundProcessor::from_id (c.get ()); + _cinema_sound_processor = CinemaSoundProcessor::from_id (c.get ()); + } + c = f.optional_string_child ("CinemaSoundProcessor"); + if (c) { + _cinema_sound_processor = CinemaSoundProcessor::from_id (c.get ()); } _language = f.optional_string_child ("Language"); + c = f.optional_string_child ("DefaultScale"); + if (c) { + _default_scale = Ratio::from_id (c.get ()); + } + c = f.optional_string_child ("DefaultContainer"); if (c) { _default_container = Ratio::from_id (c.get ()); @@@ -173,7 -176,7 +179,7 @@@ /* Loading version 0 (before Rec. 709 was added as a preset). Add it in. */ - _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), 2.2, false, libdcp::colour_matrix::rec709_to_xyz, 2.6)); + _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), 2.2, false, dcp::colour_matrix::rec709_to_xyz, 2.6)); } list cin = f.node_children ("Cinema"); @@@ -203,6 -206,70 +209,6 @@@ _log_types = f.optional_number_child ("LogTypes").get_value_or (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR); } -void -Config::read_old_metadata () -{ - /* XXX: this won't work with non-Latin filenames */ - ifstream f (file(true).string().c_str ()); - string line; - - while (getline (f, line)) { - if (line.empty ()) { - continue; - } - - if (line[0] == '#') { - continue; - } - - size_t const s = line.find (' '); - if (s == string::npos) { - continue; - } - - string const k = line.substr (0, s); - string const v = line.substr (s + 1); - - if (k == N_("num_local_encoding_threads")) { - _num_local_encoding_threads = atoi (v.c_str ()); - } else if (k == N_("default_directory")) { - _default_directory = v; - } else if (k == N_("server_port")) { - _server_port_base = atoi (v.c_str ()); - } else if (k == N_("server")) { - vector b; - split (b, v, is_any_of (" ")); - if (b.size() == 2) { - _servers.push_back (b[0]); - } - } else if (k == N_("tms_ip")) { - _tms_ip = v; - } else if (k == N_("tms_path")) { - _tms_path = v; - } else if (k == N_("tms_user")) { - _tms_user = v; - } else if (k == N_("tms_password")) { - _tms_password = v; - } else if (k == N_("sound_processor")) { - _sound_processor = SoundProcessor::from_id (v); - } else if (k == "language") { - _language = v; - } else if (k == "default_container") { - _default_container = Ratio::from_id (v); - } else if (k == "default_dcp_content_type") { - _default_dcp_content_type = DCPContentType::from_isdcf_name (v); - } else if (k == "dcp_metadata_issuer") { - _dcp_metadata.issuer = v; - } else if (k == "dcp_metadata_creator") { - _dcp_metadata.creator = v; - } else if (k == "dcp_metadata_issue_date") { - _dcp_metadata.issue_date = v; - } - - _default_isdcf_metadata.read_old_metadata (k, v); - } -} - /** @return Filename to write configuration to */ boost::filesystem::path Config::file (bool old) const @@@ -274,12 -341,15 +280,15 @@@ Config::write () cons root->add_child("TMSPath")->add_child_text (_tms_path); root->add_child("TMSUser")->add_child_text (_tms_user); root->add_child("TMSPassword")->add_child_text (_tms_password); - if (_sound_processor) { - root->add_child("SoundProcessor")->add_child_text (_sound_processor->id ()); + if (_cinema_sound_processor) { + root->add_child("CinemaSoundProcessor")->add_child_text (_cinema_sound_processor->id ()); } if (_language) { root->add_child("Language")->add_child_text (_language.get()); } + if (_default_scale) { + root->add_child("DefaultScale")->add_child_text (_default_scale->id ()); + } if (_default_container) { root->add_child("DefaultContainer")->add_child_text (_default_container->id ()); } diff --combined src/lib/config.h index 66ff66214,44936172c..03dd9c0fe --- a/src/lib/config.h +++ b/src/lib/config.h @@@ -28,14 -28,15 +28,14 @@@ #include #include #include -#include +#include #include "isdcf_metadata.h" #include "colour_conversion.h" -#include "server.h" class ServerDescription; class Scaler; class Filter; -class SoundProcessor; +class CinemaSoundProcessor; class DCPContentType; class Ratio; class Cinema; @@@ -103,9 -104,9 +103,9 @@@ public return _tms_password; } - /** @return The sound processor that we are using */ - SoundProcessor const * sound_processor () const { - return _sound_processor; + /** @return The cinema sound processor that we are using */ + CinemaSoundProcessor const * cinema_sound_processor () const { + return _cinema_sound_processor; } std::list > cinemas () const { @@@ -132,6 -133,10 +132,10 @@@ return _default_still_length; } + Ratio const * default_scale () const { + return _default_scale; + } + Ratio const * default_container () const { return _default_container; } @@@ -140,7 -145,7 +144,7 @@@ return _default_dcp_content_type; } - libdcp::XMLMetadata dcp_metadata () const { + dcp::XMLMetadata dcp_metadata () const { return _dcp_metadata; } @@@ -281,6 -286,11 +285,11 @@@ changed (); } + void set_default_scale (Ratio const * s) { + _default_scale = s; + changed (); + } + void set_default_container (Ratio const * c) { _default_container = c; changed (); @@@ -291,7 -301,7 +300,7 @@@ changed (); } - void set_dcp_metadata (libdcp::XMLMetadata m) { + void set_dcp_metadata (dcp::XMLMetadata m) { _dcp_metadata = m; changed (); } @@@ -380,6 -390,7 +389,6 @@@ private Config (); boost::filesystem::path file (bool) const; void read (); - void read_old_metadata (); void write () const; /** number of threads to use for J2K encoding on the local machine */ @@@ -402,8 -413,8 +411,8 @@@ std::string _tms_user; /** Password to log into the TMS with */ std::string _tms_password; - /** Our sound processor */ - SoundProcessor const * _sound_processor; + /** Our cinema sound processor */ + CinemaSoundProcessor const * _cinema_sound_processor; std::list _allowed_dcp_frame_rates; /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */ bool _allow_any_dcp_frame_rate; @@@ -411,9 -422,10 +420,10 @@@ ISDCFMetadata _default_isdcf_metadata; boost::optional _language; int _default_still_length; + Ratio const * _default_scale; Ratio const * _default_container; DCPContentType const * _default_dcp_content_type; - libdcp::XMLMetadata _dcp_metadata; + dcp::XMLMetadata _dcp_metadata; int _default_j2k_bandwidth; int _default_audio_delay; std::vector _colour_conversions; diff --combined src/lib/video_content.cc index a2a4e6c6b,15e1ca791..a8590ce55 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@@ -19,8 -19,8 +19,8 @@@ #include #include -#include -#include +#include +#include #include "video_content.h" #include "video_examiner.h" #include "compose.hpp" @@@ -31,12 -31,9 +31,12 @@@ #include "film.h" #include "exceptions.h" #include "frame_rate_change.h" +#include "log.h" #include "i18n.h" +#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); + int const VideoContentProperty::VIDEO_SIZE = 0; int const VideoContentProperty::VIDEO_FRAME_RATE = 1; int const VideoContentProperty::VIDEO_FRAME_TYPE = 2; @@@ -54,26 -51,28 +54,26 @@@ using std::max using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; -using libdcp::raw_convert; +using dcp::raw_convert; vector VideoContentScale::_scales; VideoContent::VideoContent (shared_ptr f) : Content (f) , _video_length (0) - , _original_video_frame_rate (0) , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) - , _scale (Ratio::from_id ("185")) + , _scale (Config::instance()->default_scale ()) { setup_default_colour_conversion (); } -VideoContent::VideoContent (shared_ptr f, Time s, VideoContent::Frame len) +VideoContent::VideoContent (shared_ptr f, DCPTime s, ContentTime len) : Content (f, s) , _video_length (len) - , _original_video_frame_rate (0) , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) - , _scale (Ratio::from_id ("185")) + , _scale (Config::instance()->default_scale ()) { setup_default_colour_conversion (); } @@@ -81,27 -80,22 +81,27 @@@ VideoContent::VideoContent (shared_ptr f, boost::filesystem::path p) : Content (f, p) , _video_length (0) - , _original_video_frame_rate (0) , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) - , _scale (Ratio::from_id ("185")) + , _scale (Config::instance()->default_scale ()) { setup_default_colour_conversion (); } -VideoContent::VideoContent (shared_ptr f, shared_ptr node, int version) +VideoContent::VideoContent (shared_ptr f, cxml::ConstNodePtr node, int version) : Content (f, node) { - _video_length = node->number_child ("VideoLength"); _video_size.width = node->number_child ("VideoWidth"); _video_size.height = node->number_child ("VideoHeight"); _video_frame_rate = node->number_child ("VideoFrameRate"); - _original_video_frame_rate = node->optional_number_child ("OriginalVideoFrameRate").get_value_or (_video_frame_rate); + + if (version < 32) { + /* DCP-o-matic 1.0 branch */ + _video_length = ContentTime::from_frames (node->number_child ("VideoLength"), _video_frame_rate); + } else { + _video_length = ContentTime (node->number_child ("VideoLength")); + } + _video_frame_type = static_cast (node->number_child ("VideoFrameType")); _crop.left = node->number_child ("LeftCrop"); _crop.right = node->number_child ("RightCrop"); @@@ -158,6 -152,7 +158,6 @@@ VideoContent::VideoContent (shared_ptr< } _video_size = ref->video_size (); - _original_video_frame_rate = ref->original_video_frame_rate (); _video_frame_rate = ref->video_frame_rate (); _video_frame_type = ref->video_frame_type (); _crop = ref->crop (); @@@ -169,10 -164,11 +169,10 @@@ voi VideoContent::as_xml (xmlpp::Node* node) const { boost::mutex::scoped_lock lm (_mutex); - node->add_child("VideoLength")->add_child_text (raw_convert (_video_length)); + node->add_child("VideoLength")->add_child_text (raw_convert (_video_length.get ())); node->add_child("VideoWidth")->add_child_text (raw_convert (_video_size.width)); node->add_child("VideoHeight")->add_child_text (raw_convert (_video_size.height)); node->add_child("VideoFrameRate")->add_child_text (raw_convert (_video_frame_rate)); - node->add_child("OriginalVideoFrameRate")->add_child_text (raw_convert (_original_video_frame_rate)); node->add_child("VideoFrameType")->add_child_text (raw_convert (static_cast (_video_frame_type))); _crop.as_xml (node); _scale.as_xml (node->add_child("Scale")); @@@ -182,31 -178,25 +182,31 @@@ void VideoContent::setup_default_colour_conversion () { - _colour_conversion = PresetColourConversion (_("sRGB"), 2.4, true, libdcp::colour_matrix::srgb_to_xyz, 2.6).conversion; + _colour_conversion = PresetColourConversion (_("sRGB"), 2.4, true, dcp::colour_matrix::srgb_to_xyz, 2.6).conversion; } void VideoContent::take_from_video_examiner (shared_ptr d) { /* These examiner calls could call other content methods which take a lock on the mutex */ - libdcp::Size const vs = d->video_size (); + dcp::Size const vs = d->video_size (); float const vfr = d->video_frame_rate (); + ContentTime vl = d->video_length (); { boost::mutex::scoped_lock lm (_mutex); _video_size = vs; _video_frame_rate = vfr; - _original_video_frame_rate = vfr; + _video_length = vl; } + + shared_ptr film = _film.lock (); + assert (film); + LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length.frames (_video_frame_rate)); signal_changed (VideoContentProperty::VIDEO_SIZE); signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); + signal_changed (ContentProperty::LENGTH); } @@@ -337,17 -327,14 +337,17 @@@ VideoContent::technical_summary () cons { return String::compose ( "video: length %1, size %2x%3, rate %4", - video_length_after_3d_combine(), video_size().width, video_size().height, video_frame_rate() + video_length_after_3d_combine().seconds(), + video_size().width, + video_size().height, + video_frame_rate() ); } -libdcp::Size +dcp::Size VideoContent::video_size_after_3d_split () const { - libdcp::Size const s = video_size (); + dcp::Size const s = video_size (); switch (video_frame_type ()) { case VIDEO_FRAME_TYPE_2D: case VIDEO_FRAME_TYPE_3D_ALTERNATE: @@@ -355,9 -342,9 +355,9 @@@ case VIDEO_FRAME_TYPE_3D_RIGHT: return s; case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT: - return libdcp::Size (s.width / 2, s.height); + return dcp::Size (s.width / 2, s.height); case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM: - return libdcp::Size (s.width, s.height / 2); + return dcp::Size (s.width, s.height / 2); } assert (false); @@@ -375,21 -362,28 +375,21 @@@ VideoContent::set_colour_conversion (Co } /** @return Video size after 3D split and crop */ -libdcp::Size +dcp::Size VideoContent::video_size_after_crop () const { return crop().apply (video_size_after_3d_split ()); } /** @param t A time offset from the start of this piece of content. - * @return Corresponding frame index. + * @return Corresponding time with respect to the content. */ -VideoContent::Frame -VideoContent::time_to_content_video_frames (Time t) const +ContentTime +VideoContent::dcp_time_to_content_time (DCPTime t) const { shared_ptr film = _film.lock (); assert (film); - - FrameRateChange frc (video_frame_rate(), film->video_frame_rate()); - - /* Here we are converting from time (in the DCP) to a frame number in the content. - Hence we need to use the DCP's frame rate and the double/skip correction, not - the source's rate. - */ - return t * film->video_frame_rate() / (frc.factor() * TIME_HZ); + return ContentTime (t, FrameRateChange (video_frame_rate(), film->video_frame_rate())); } void @@@ -454,7 -448,7 +454,7 @@@ VideoContentScale::VideoContentScale (b } -VideoContentScale::VideoContentScale (shared_ptr node) +VideoContentScale::VideoContentScale (cxml::NodePtr node) : _ratio (0) , _scale (true) { @@@ -507,14 -501,14 +507,14 @@@ VideoContentScale::name () cons /** @param display_container Size of the container that we are displaying this content in. * @param film_container The size of the film's image. */ -libdcp::Size -VideoContentScale::size (shared_ptr c, libdcp::Size display_container, libdcp::Size film_container) const +dcp::Size +VideoContentScale::size (shared_ptr c, dcp::Size display_container, dcp::Size film_container) const { if (_ratio) { return fit_ratio_within (_ratio->ratio (), display_container); } - libdcp::Size const ac = c->video_size_after_crop (); + dcp::Size const ac = c->video_size_after_crop (); /* Force scale if the film_container is smaller than the content's image */ if (_scale || film_container.width < ac.width || film_container.height < ac.height) { @@@ -524,7 -518,7 +524,7 @@@ /* Scale the image so that it will be in the right place in film_container, even if display_container is a different size. */ - return libdcp::Size ( + return dcp::Size ( c->video_size().width * float(display_container.width) / film_container.width, c->video_size().height * float(display_container.height) / film_container.height ); diff --combined src/wx/config_dialog.cc index 360e80572,00f6a2668..306e1f208 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@@ -28,14 -28,13 +28,14 @@@ #include #include #include -#include +#include #include "lib/config.h" #include "lib/ratio.h" #include "lib/scaler.h" #include "lib/filter.h" #include "lib/dcp_content_type.h" #include "lib/colour_conversion.h" +#include "lib/log.h" #include "config_dialog.h" #include "wx_util.h" #include "editable_list.h" @@@ -267,6 -266,10 +267,10 @@@ public add_label_to_sizer (table, panel, _("Default ISDCF name details"), true); _isdcf_metadata_button = new wxButton (panel, wxID_ANY, _("Edit...")); table->Add (_isdcf_metadata_button); + + add_label_to_sizer (table, panel, _("Default scale to"), true); + _scale = new wxChoice (panel, wxID_ANY); + table->Add (_scale); add_label_to_sizer (table, panel, _("Default container"), true); _container = new wxChoice (panel, wxID_ANY); @@@ -316,6 -319,10 +320,10 @@@ vector ratio = Ratio::all (); int n = 0; for (vector::iterator i = ratio.begin(); i != ratio.end(); ++i) { + _scale->Append (std_to_wx ((*i)->nickname ())); + if (*i == config->default_scale ()) { + _scale->SetSelection (n); + } _container->Append (std_to_wx ((*i)->nickname ())); if (*i == config->default_container ()) { _container->SetSelection (n); @@@ -323,6 -330,7 +331,7 @@@ ++n; } + _scale->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::scale_changed, this)); _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::container_changed, this)); vector const ct = DCPContentType::all (); @@@ -381,6 -389,12 +390,12 @@@ private { Config::instance()->set_default_still_length (_still_length->GetValue ()); } + + void scale_changed () + { + vector ratio = Ratio::all (); + Config::instance()->set_default_scale (ratio[_scale->GetSelection()]); + } void container_changed () { @@@ -396,14 -410,14 +411,14 @@@ void issuer_changed () { - libdcp::XMLMetadata m = Config::instance()->dcp_metadata (); + dcp::XMLMetadata m = Config::instance()->dcp_metadata (); m.issuer = wx_to_std (_issuer->GetValue ()); Config::instance()->set_dcp_metadata (m); } void creator_changed () { - libdcp::XMLMetadata m = Config::instance()->dcp_metadata (); + dcp::XMLMetadata m = Config::instance()->dcp_metadata (); m.creator = wx_to_std (_creator->GetValue ()); Config::instance()->set_dcp_metadata (m); } @@@ -417,6 -431,7 +432,7 @@@ #else wxDirPickerCtrl* _directory; #endif + wxChoice* _scale; wxChoice* _container; wxChoice* _dcp_content_type; wxTextCtrl* _issuer;