From 5db5da477ce02166481d79df322bbfb7abc8f24c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 29 Nov 2024 21:04:45 +0100 Subject: Fix mis-handling of reels with Atmos content (#2901). We must have reel boundaries at least on Atmos content boundaries as I don't know for sure how to insert silence into an Atmos stream. --- src/lib/film.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/lib/film.h | 1 + 2 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index 5b845d8b4..a4734d4c3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1610,6 +1610,51 @@ Film::playlist_change (ChangeType type) set_dirty (true); } + +void +Film::check_reel_boundaries_for_atmos() +{ + /* Find Atmos boundaries */ + std::set atmos_boundaries; + for (auto i: content()) { + if (i->atmos) { + atmos_boundaries.insert(i->position()); + atmos_boundaries.insert(i->end(shared_from_this())); + } + } + + /* Find reel boundaries */ + vector reel_boundaries; + bool first = true; + for (auto period: reels()) { + if (first) { + reel_boundaries.push_back(period.from); + first = false; + } + reel_boundaries.push_back(period.to); + } + + /* There must be a reel boundary at all the Atmos boundaries */ + auto remake_boundaries = std::any_of(atmos_boundaries.begin(), atmos_boundaries.end(), [&reel_boundaries](dcpomatic::DCPTime time) { + return std::find(reel_boundaries.begin(), reel_boundaries.end(), time) == reel_boundaries.end(); + }); + + if (remake_boundaries) { + vector required_boundaries; + std::copy_if(atmos_boundaries.begin(), atmos_boundaries.end(), std::back_inserter(required_boundaries), [this](dcpomatic::DCPTime time) { + return time.get() != 0 && time != length(); + }); + if (!required_boundaries.empty()) { + set_reel_type(ReelType::CUSTOM); + set_custom_reel_boundaries(required_boundaries); + } else { + set_reel_type(ReelType::SINGLE); + } + Message(variant::insert_dcpomatic("%1 had to change your reel settings to accomodate the Atmos content")); + } +} + + /** Check for (and if necessary fix) impossible settings combinations, like * video set to being referenced when it can't be. */ diff --git a/src/lib/film.h b/src/lib/film.h index 815c6ae74..8718e8f7d 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -502,6 +502,7 @@ private: void maybe_set_container_and_resolution (); void set_dirty (bool dirty); void write_ui_state() const; + void check_reel_boundaries_for_atmos(); /** Log to write to */ std::shared_ptr _log; -- cgit v1.2.3