summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-03-01 23:36:22 +0000
committerCarl Hetherington <cth@carlh.net>2013-03-01 23:36:22 +0000
commitab1a666e724911c41dfe08fc96748b38ace839c1 (patch)
tree3b9bd2f9fe80156e5dfaf4e5cb72080e21ba9816 /src/lib/util.cc
parentb1b3e2e30ce8152b03c9cd3502a00b1814c654ea (diff)
parentff950a024d0bfd892354d53e851c3915a68d2c89 (diff)
Merge.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc85
1 files changed, 72 insertions, 13 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 3d70a3122..de69636da 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -450,19 +450,6 @@ dcp_audio_sample_rate (int fs)
return 96000;
}
-int
-dcp_audio_channels (int f)
-{
- if (f == 1) {
- /* The source is mono, so to put the mono channel into
- the centre we need to generate a 5.1 soundtrack.
- */
- return 6;
- }
-
- return f;
-}
-
bool operator== (Crop const & a, Crop const & b)
{
return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
@@ -903,3 +890,75 @@ cpu_info ()
return info;
}
+
+string
+audio_channel_name (int c)
+{
+ assert (MAX_AUDIO_CHANNELS == 6);
+
+ /* TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency
+ enhancement channel (sub-woofer)./
+ */
+ string const channels[] = {
+ "Left",
+ "Right",
+ "Centre",
+ "Lfe (sub)",
+ "Left surround",
+ "Right surround",
+ };
+
+ return channels[c];
+}
+
+AudioMapping::AudioMapping (int c)
+ : _source_channels (c)
+{
+
+}
+
+optional<libdcp::Channel>
+AudioMapping::source_to_dcp (int c) const
+{
+ if (c >= _source_channels) {
+ return optional<libdcp::Channel> ();
+ }
+
+ if (_source_channels == 1) {
+ /* mono sources to centre */
+ return libdcp::CENTRE;
+ }
+
+ return static_cast<libdcp::Channel> (c);
+}
+
+optional<int>
+AudioMapping::dcp_to_source (libdcp::Channel c) const
+{
+ if (_source_channels == 1) {
+ if (c == libdcp::CENTRE) {
+ return 0;
+ } else {
+ return optional<int> ();
+ }
+ }
+
+ if (static_cast<int> (c) >= _source_channels) {
+ return optional<int> ();
+ }
+
+ return static_cast<int> (c);
+}
+
+int
+AudioMapping::dcp_channels () const
+{
+ if (_source_channels == 1) {
+ /* The source is mono, so to put the mono channel into
+ the centre we need to generate a 5.1 soundtrack.
+ */
+ return 6;
+ }
+
+ return _source_channels;
+}