Move luminance to Interop/SMPTE metadata and remove the ISDCF metadata dialogue.
[dcpomatic.git] / src / lib / reel_writer.cc
index 136d2405e3aabff47f266b27409a751b5babdc67..2c55f0f064214bbd6e6764724a3642d46fe379a8 100644 (file)
@@ -178,17 +178,11 @@ ReelWriter::ReelWriter (
 
                DCPOMATIC_ASSERT (film()->directory());
 
-               vector<dcp::Channel> active;
-               for (auto i: film()->mapped_audio_channels()) {
-                       active.push_back (static_cast<dcp::Channel>(i));
-               }
-
                /* Write the sound asset into the film directory so that we leave the creation
                   of the DCP directory until the last minute.
                */
                _sound_asset_writer = _sound_asset->start_write (
                        film()->directory().get() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
-                       active,
                        film()->contains_atmos_content()
                        );
        }
@@ -629,8 +623,8 @@ ReelWriter::create_reel_text (
 
        if (subtitle) {
                /* We have a subtitle asset that we either made or are referencing */
-               if (!film()->subtitle_languages().empty()) {
-                       subtitle->set_language (film()->subtitle_languages().front());
+               if (auto main_language = film()->subtitle_languages().first) {
+                       subtitle->set_language (*main_language);
                }
        } else if (ensure_subtitles) {
                /* We had no subtitle asset, but we've been asked to make sure there is one */
@@ -691,10 +685,9 @@ ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const
        if (!reel_markers.empty ()) {
                auto ma = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(film()->video_frame_rate(), 1), reel->duration(), 0);
                for (auto const& i: reel_markers) {
-                       int h, m, s, f;
                        DCPTime relative = i.second - _period.from;
-                       relative.split (film()->video_frame_rate(), h, m, s, f);
-                       ma->set (i.first, dcp::Time(h, m, s, f, film()->video_frame_rate()));
+                       auto hmsf = relative.split (film()->video_frame_rate());
+                       ma->set (i.first, dcp::Time(hmsf.h, hmsf.m, hmsf.s, hmsf.f, film()->video_frame_rate()));
                }
                reel->add (ma);
        }
@@ -783,7 +776,7 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track) const
                auto s = make_shared<dcp::InteropSubtitleAsset>();
                s->set_movie_title (film()->name());
                if (type == TextType::OPEN_SUBTITLE) {
-                       s->set_language (lang.empty() ? "Unknown" : lang.front().to_string());
+                       s->set_language (lang.first ? lang.first->to_string() : "Unknown");
                } else if (!track->language.empty()) {
                        s->set_language (track->language);
                }
@@ -793,8 +786,8 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track) const
                auto s = make_shared<dcp::SMPTESubtitleAsset>();
                s->set_content_title_text (film()->name());
                s->set_metadata (mxf_metadata());
-               if (type == TextType::OPEN_SUBTITLE && !lang.empty()) {
-                       s->set_language (lang.front());
+               if (type == TextType::OPEN_SUBTITLE && lang.first) {
+                       s->set_language (*lang.first);
                } else if (track && !track->language.empty()) {
                        s->set_language (dcp::LanguageTag(track->language));
                }
@@ -868,19 +861,21 @@ ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track,
                DCPOMATIC_ASSERT (false);
        }
 
+       /* timecode rate for subtitles we emit; we might as well stick to ms accuracy here, I think */
+       auto const tcr = 1000;
+
        for (auto i: subs.string) {
-               /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
-               i.set_in  (i.in()  - dcp::Time (_period.from.seconds(), i.in().tcr));
-               i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
-               asset->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
+               i.set_in  (dcp::Time(period.from.seconds() - _period.from.seconds(), tcr));
+               i.set_out (dcp::Time(period.to.seconds() - _period.from.seconds(), tcr));
+               asset->add (make_shared<dcp::SubtitleString>(i));
        }
 
        for (auto i: subs.bitmap) {
                asset->add (
                        make_shared<dcp::SubtitleImage>(
                                i.image->as_png(),
-                               dcp::Time(period.from.seconds() - _period.from.seconds(), film()->video_frame_rate()),
-                               dcp::Time(period.to.seconds() - _period.from.seconds(), film()->video_frame_rate()),
+                               dcp::Time(period.from.seconds() - _period.from.seconds(), tcr),
+                               dcp::Time(period.to.seconds() - _period.from.seconds(), tcr),
                                i.rectangle.x, dcp::HAlign::LEFT, i.rectangle.y, dcp::VAlign::TOP,
                                dcp::Time(), dcp::Time()
                                )