summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-05-09 11:24:03 +0100
committerCarl Hetherington <cth@carlh.net>2017-05-09 11:24:03 +0100
commit89ae13638097f259f3e50b4b61068dd23451107d (patch)
treed58d8d0d10e5582b959ec41286943e6f4d81b8ac /src/lib/util.cc
parent7844347e7d89ffb256167192fb414c35d416e14d (diff)
Simple cover sheet support (#1039).
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 574d1d889..b1dfeab55 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -88,6 +88,7 @@ using std::pair;
using std::cout;
using std::bad_alloc;
using std::set_terminate;
+using std::make_pair;
using boost::shared_ptr;
using boost::thread;
using boost::optional;
@@ -706,3 +707,29 @@ careful_string_filter (string s)
return out;
}
+
+/** @param mapped List of mapped audio channels from a Film.
+ * @param channels Total number of channels in the Film.
+ * @return First: number of non-LFE channels, second: number of LFE channels.
+ */
+pair<int, int>
+audio_channel_types (list<int> mapped, int channels)
+{
+ int non_lfe = 0;
+ int lfe = 0;
+
+ BOOST_FOREACH (int i, mapped) {
+ if (i >= 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;
+ }
+ }
+
+ return make_pair (non_lfe, lfe);
+}