From bcc9e32cd3c886fbe02f1b2573bd19ca9ec340dc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Oct 2025 22:19:24 +0100 Subject: Don't report channels as mapped when they are not included in the film's channel count. So e.g. if you map the 7.1 surrounds but have a 6-channel film it should consider those channels un-mapped. --- src/lib/film.cc | 16 ++++++++++++---- src/lib/film.h | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index c6a6f3cce..8dc55c590 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -797,11 +797,18 @@ list Film::mapped_audio_channels() const { list mapped; + auto const highest_channel = audio_channels() - 1; + + auto maybe_add = [&mapped, highest_channel](int channel) { + if (channel <= highest_channel) { + mapped.push_back(channel); + } + }; if (audio_processor()) { /* Assume all a processor's declared output channels are mapped */ for (int i = 0; i < audio_processor()->out_channels(); ++i) { - mapped.push_back(i); + maybe_add(i); } /* Check to see if channels that the processor passes through are mapped */ @@ -810,7 +817,7 @@ Film::mapped_audio_channels() const if (i->audio) { for (auto c: i->audio->mapping().mapped_output_channels()) { if (std::find(pass.begin(), pass.end(), dcp::Channel(c)) != pass.end()) { - mapped.push_back(c); + maybe_add(c); } } } @@ -819,8 +826,9 @@ Film::mapped_audio_channels() const } else { for (auto i: content()) { if (i->audio) { - auto c = i->audio->mapping().mapped_output_channels(); - copy(c.begin(), c.end(), back_inserter(mapped)); + for (auto c: i->audio->mapping().mapped_output_channels()) { + maybe_add(c); + } } } diff --git a/src/lib/film.h b/src/lib/film.h index 8574c700f..6d04da9bf 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -173,6 +173,11 @@ public: } std::vector reels() const; + + /** @return List of channel indicies that are mapped to the DCP. This takes the + * value of audio_channels() into account, so even if a channel above audio_channels() + * is mapped it will not be returned here. + */ std::list mapped_audio_channels() const; boost::optional audio_language() const { -- cgit v1.2.3