diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-04-22 14:29:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-04-22 14:29:31 +0100 |
| commit | 31f491c0f13d23506fd810f61982976a9a60e44d (patch) | |
| tree | 76fad30419e4f75fabc5581bbcc988c9366bae0d /src/lib | |
| parent | 8031edf0ce27b75727438e504128448b0884b426 (diff) | |
Select active channels on opening audio analysis (#802).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 69 | ||||
| -rw-r--r-- | src/lib/film.h | 2 |
2 files changed, 37 insertions, 34 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 1775f7c7f..b80962ead 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -493,6 +493,32 @@ Film::file (boost::filesystem::path f) const return p; } +list<int> +Film::mapped_audio_channels () const +{ + list<int> mapped; + + if (audio_processor ()) { + /* Processors are mapped 1:1 to DCP outputs so we can work out mappings from there */ + for (int i = 0; i < audio_processor()->out_channels(); ++i) { + mapped.push_back (i); + } + } else { + BOOST_FOREACH (shared_ptr<Content> i, content ()) { + shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i); + if (ac) { + list<int> c = ac->audio_mapping().mapped_output_channels (); + copy (c.begin(), c.end(), back_inserter (mapped)); + } + } + + mapped.sort (); + mapped.unique (); + } + + return mapped; +} + /** @return a ISDCF-compliant name for a DCP of this film */ string Film::isdcf_name (bool if_created_now) const @@ -646,46 +672,21 @@ Film::isdcf_name (bool if_created_now) const } } - /* Find all mapped channels */ + /* Count mapped audio channels */ int non_lfe = 0; int lfe = 0; - if (audio_processor ()) { - /* Processors are mapped 1:1 to DCP outputs so we can guess the number of LFE/ - non-LFE from the channel counts. - */ - non_lfe = audio_processor()->out_channels (); - if (non_lfe >= 4) { - --non_lfe; - ++lfe; - } - } else { - list<int> mapped; - BOOST_FOREACH (shared_ptr<Content> i, content ()) { - shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i); - if (ac) { - list<int> c = ac->audio_mapping().mapped_output_channels (); - copy (c.begin(), c.end(), back_inserter (mapped)); - } + BOOST_FOREACH (int i, mapped_audio_channels ()) { + if (i >= audio_channels()) { + /* This channel is mapped but is not included in the DCP */ + continue; } - mapped.sort (); - mapped.unique (); - - /* Count them */ - - for (list<int>::const_iterator i = mapped.begin(); i != mapped.end(); ++i) { - if (*i >= audio_channels()) { - /* This channel is mapped but is not included in the DCP */ - continue; - } - - if (static_cast<dcp::Channel> (*i) == dcp::LFE) { - ++lfe; - } else { - ++non_lfe; - } + if (static_cast<dcp::Channel> (i) == dcp::LFE) { + ++lfe; + } else { + ++non_lfe; } } diff --git a/src/lib/film.h b/src/lib/film.h index b8e31a420..4ad905758 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -154,6 +154,8 @@ public: std::list<DCPTimePeriod> reels () const; + std::list<int> mapped_audio_channels () const; + /** Identifiers for the parts of our state; used for signalling changes. */ |
