From: Carl Hetherington Date: Thu, 7 Feb 2013 22:02:16 +0000 (+0000) Subject: Possibly fix legacy dcp_trim_start tags; use DCI name for content type to be a little... X-Git-Tag: v2.0.48~1337^2~697 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=67ac2b512788c5c331ff57b2d8bf571fd58d0ebf Possibly fix legacy dcp_trim_start tags; use DCI name for content type to be a little more i18n friendly. --- diff --git a/src/lib/dcp_content_type.cc b/src/lib/dcp_content_type.cc index aae805308..1c96979e4 100644 --- a/src/lib/dcp_content_type.cc +++ b/src/lib/dcp_content_type.cc @@ -63,6 +63,18 @@ DCPContentType::from_pretty_name (string n) return 0; } +DCPContentType const * +DCPContentType::from_dci_name (string n) +{ + for (vector::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) { + if ((*i)->dci_name() == n) { + return *i; + } + } + + return 0; +} + DCPContentType const * DCPContentType::from_index (int n) { diff --git a/src/lib/dcp_content_type.h b/src/lib/dcp_content_type.h index 2b6e60a19..960bb0129 100644 --- a/src/lib/dcp_content_type.h +++ b/src/lib/dcp_content_type.h @@ -50,6 +50,7 @@ public: } static DCPContentType const * from_pretty_name (std::string); + static DCPContentType const * from_dci_name (std::string); static DCPContentType const * from_index (int); static int as_index (DCPContentType const *); static std::vector all (); diff --git a/src/lib/film.cc b/src/lib/film.cc index e759b761c..59f79e666 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -72,7 +72,7 @@ using boost::starts_with; using boost::optional; using libdcp::Size; -int const Film::state_version = 2; +int const Film::state_version = 3; /** Construct a Film object in a given directory, reading any metadata * file that exists in that directory. An exception will be thrown if @@ -374,7 +374,7 @@ Film::write_metadata () const f << "content " << _content << "\n"; f << "trust_content_header " << (_trust_content_header ? "1" : "0") << "\n"; if (_dcp_content_type) { - f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n"; + f << "dcp_content_type " << _dcp_content_type->dci_name () << "\n"; } if (_format) { f << "format " << _format->as_metadata () << "\n"; @@ -478,7 +478,11 @@ Film::read_metadata () } else if (k == "trust_content_header") { _trust_content_header = (v == "1"); } else if (k == "dcp_content_type") { - _dcp_content_type = DCPContentType::from_pretty_name (v); + if (version < 3) { + _dcp_content_type = DCPContentType::from_pretty_name (v); + } else { + _dcp_content_type = DCPContentType::from_dci_name (v); + } } else if (k == "format") { _format = Format::from_metadata (v); } else if (k == "left_crop") { @@ -493,9 +497,9 @@ Film::read_metadata () _filters.push_back (Filter::from_id (v)); } else if (k == "scaler") { _scaler = Scaler::from_id (v); - } else if ( ((!version || version < 2) && k == "trim_start") || k == "trim_start") { + } else if ( ((!version || version < 2) && k == "dcp_trim_start") || k == "trim_start") { _trim_start = atoi (v.c_str ()); - } else if ( ((!version || version < 2) && k == "trim_end") || k == "trim_end") { + } else if ( ((!version || version < 2) && k == "dcp_trim_end") || k == "trim_end") { _trim_end = atoi (v.c_str ()); } else if (k == "dcp_ab") { _dcp_ab = (v == "1");