X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=87037f51fb97169a6293e302d262e6aadc19e136;hb=21e78df3645193f696873bdf29d39ea9f772395e;hp=c04f2996f255fd4dabd0087012efb02d1e44a036;hpb=d1957e43ef4a3966e35b9f28b8faf96e925d2310;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index c04f2996f..87037f51f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -23,6 +23,7 @@ * how they should be presented in a DCP. */ +#include "atmos_content.h" #include "film.h" #include "job.h" #include "util.h" @@ -101,6 +102,9 @@ using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; using boost::is_any_of; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif using dcp::raw_convert; using namespace dcpomatic; @@ -164,6 +168,12 @@ Film::Film (optional dir) , _user_explicit_video_frame_rate (false) , _user_explicit_container (false) , _user_explicit_resolution (false) + , _name_language (dcp::LanguageTag("en-US")) + , _audio_language (dcp::LanguageTag("en-US")) + , _release_territory (dcp::LanguageTag::RegionSubtag("US")) + , _version_number (1) + , _status (dcp::FINAL) + , _luminance (dcp::Luminance(4.5, dcp::Luminance::FOOT_LAMBERT)) , _state_version (current_state_version) , _dirty (false) , _tolerant (false) @@ -463,7 +473,19 @@ Film::metadata (bool with_content_paths) const BOOST_FOREACH (dcp::Rating i, _ratings) { i.as_xml (root->add_child("Rating")); } - root->add_child("ContentVersion")->add_child_text(_content_version); + BOOST_FOREACH (string i, _content_versions) { + root->add_child("ContentVersion")->add_child_text(i); + } + root->add_child("NameLanguage")->add_child_text(_name_language.to_string()); + root->add_child("AudioLanguage")->add_child_text(_audio_language.to_string()); + root->add_child("ReleaseTerritory")->add_child_text(_release_territory.subtag()); + root->add_child("VersionNumber")->add_child_text(raw_convert(_version_number)); + root->add_child("Status")->add_child_text(dcp::status_to_string(_status)); + root->add_child("Chain")->add_child_text(_chain); + root->add_child("Distributor")->add_child_text(_distributor); + root->add_child("Facility")->add_child_text(_facility); + root->add_child("LuminanceValue")->add_child_text(raw_convert(_luminance.value())); + root->add_child("LuminanceUnit")->add_child_text(dcp::Luminance::unit_to_string(_luminance.unit())); root->add_child("UserExplicitContainer")->add_child_text(_user_explicit_container ? "1" : "0"); root->add_child("UserExplicitResolution")->add_child_text(_user_explicit_resolution ? "1" : "0"); _playlist->as_xml (root->add_child ("Playlist"), with_content_paths); @@ -611,7 +633,39 @@ Film::read_metadata (optional path) _ratings.push_back (dcp::Rating(i)); } - _content_version = f.optional_string_child("ContentVersion").get_value_or(""); + BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("ContentVersion")) { + _content_versions.push_back (i->content()); + } + + optional name_language = f.optional_string_child("NameLanguage"); + if (name_language) { + _name_language = dcp::LanguageTag (*name_language); + } + optional audio_language = f.optional_string_child("AudioLanguage"); + if (audio_language) { + _audio_language = dcp::LanguageTag (*audio_language); + } + optional release_territory = f.optional_string_child("ReleaseTerritory"); + if (release_territory) { + _release_territory = dcp::LanguageTag::RegionSubtag (*release_territory); + } + + _version_number = f.optional_number_child("VersionNumber").get_value_or(0); + + optional status = f.optional_string_child("Status"); + if (status) { + _status = dcp::string_to_status (*status); + } + + _chain = f.optional_string_child("Chain").get_value_or(""); + _distributor = f.optional_string_child("Distributor").get_value_or(""); + _facility = f.optional_string_child("Facility").get_value_or(""); + + float value = f.optional_number_child("LuminanceValue").get_value_or(4.5); + optional unit = f.optional_string_child("LuminanceUnit"); + if (unit) { + _luminance = dcp::Luminance (value, dcp::Luminance::string_to_unit(*unit)); + } /* Disable guessing for files made in previous DCP-o-matic versions */ _user_explicit_container = f.optional_bool_child("UserExplicitContainer").get_value_or(true); @@ -1269,6 +1323,10 @@ Film::add_content (shared_ptr c) _playlist->add (shared_from_this(), c); maybe_set_container_and_resolution (); + if (c->atmos) { + set_audio_channels (14); + set_interop (false); + } } @@ -1372,6 +1430,8 @@ Film::playlist_content_change (ChangeType type, weak_ptr c, int p, bool } else { ContentChange (type, c, p, frequent); } + + _dirty = true; } void @@ -1389,6 +1449,8 @@ Film::playlist_change (ChangeType type) if (type == CHANGE_TYPE_DONE) { check_settings_consistency (); } + + _dirty = true; } /** Check for (and if necessary fix) impossible settings combinations, like @@ -1397,6 +1459,21 @@ Film::playlist_change (ChangeType type) void Film::check_settings_consistency () { + optional atmos_rate; + BOOST_FOREACH (shared_ptr i, content()) { + + if (i->atmos) { + int rate = lrintf (i->atmos->edit_rate().as_float()); + if (atmos_rate && *atmos_rate != rate) { + Message (_("You have more than one piece of Atmos content, and they do not have the same frame rate. You must remove some Atmos content.")); + } else if (!atmos_rate && rate != video_frame_rate()) { + atmos_rate = rate; + set_video_frame_rate (rate, false); + Message (_("DCP-o-matic had to change your settings so that the film's frame rate is the same as that of your Atmos content.")); + } + } + } + bool change_made = false; BOOST_FOREACH (shared_ptr i, content()) { shared_ptr d = dynamic_pointer_cast(i); @@ -1470,6 +1547,26 @@ Film::frame_size () const return fit_ratio_within (container()->ratio(), full_frame ()); } + +/** @return Area of Film::frame_size() that contains picture rather than pillar/letterboxing */ +dcp::Size +Film::active_area () const +{ + dcp::Size const frame = frame_size (); + dcp::Size active; + + BOOST_FOREACH (shared_ptr i, content()) { + if (i->video) { + dcp::Size s = i->video->scaled_size (frame); + active.width = max(active.width, s.width); + active.height = max(active.height, s.height); + } + } + + return active; +} + + /** @param recipient KDM recipient certificate. * @param trusted_devices Certificate thumbprints of other trusted devices (can be empty). * @param cpl_file CPL filename. @@ -1613,7 +1710,7 @@ Film::subtitle_language () const /** @return The names of the channels that audio contents' outputs are passed into; * this is either the DCP or a AudioProcessor. */ -vector +vector Film::audio_output_names () const { if (audio_processor ()) { @@ -1622,10 +1719,12 @@ Film::audio_output_names () const DCPOMATIC_ASSERT (MAX_DCP_AUDIO_CHANNELS == 16); - vector n; + vector n; for (int i = 0; i < audio_channels(); ++i) { - n.push_back (short_audio_channel_name (i)); + if (i != 8 && i != 9 && i != 15) { + n.push_back (NamedChannel(short_audio_channel_name(i), i)); + } } return n; @@ -1779,6 +1878,20 @@ Film::references_dcp_audio () const return false; } + +bool +Film::contains_atmos_content () const +{ + BOOST_FOREACH (shared_ptr i, _playlist->content()) { + if (i->atmos) { + return true; + } + } + + return false; +} + + list Film::closed_caption_tracks () const { @@ -1827,12 +1940,85 @@ Film::set_ratings (vector r) } void -Film::set_content_version (string v) +Film::set_content_versions (vector v) { - ChangeSignaller ch (this, CONTENT_VERSION); - _content_version = v; + ChangeSignaller ch (this, CONTENT_VERSIONS); + _content_versions = v; } + +void +Film::set_name_language (dcp::LanguageTag lang) +{ + ChangeSignaller ch (this, NAME_LANGUAGE); + _name_language = lang; +} + + +void +Film::set_audio_language (dcp::LanguageTag lang) +{ + ChangeSignaller ch (this, AUDIO_LANGUAGE); + _audio_language = lang; +} + + +void +Film::set_release_territory (dcp::LanguageTag::RegionSubtag region) +{ + ChangeSignaller ch (this, RELEASE_TERRITORY); + _release_territory = region; +} + + +void +Film::set_status (dcp::Status s) +{ + ChangeSignaller ch (this, STATUS); + _status = s; +} + + +void +Film::set_version_number (int v) +{ + ChangeSignaller ch (this, VERSION_NUMBER); + _version_number = v; +} + + +void +Film::set_chain (string c) +{ + ChangeSignaller ch (this, CHAIN); + _chain = c; +} + + +void +Film::set_distributor (string d) +{ + ChangeSignaller ch (this, DISTRIBUTOR); + _distributor = d; +} + + +void +Film::set_luminance (dcp::Luminance l) +{ + ChangeSignaller ch (this, LUMINANCE); + _luminance = l; +} + + +void +Film::set_facility (string f) +{ + ChangeSignaller ch (this, FACILITY); + _facility = f; +} + + optional Film::marker (dcp::Marker type) const {