summaryrefslogtreecommitdiff
path: root/src/lib/encoder.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/encoder.cc
parentb1b3e2e30ce8152b03c9cd3502a00b1814c654ea (diff)
parentff950a024d0bfd892354d53e851c3915a68d2c89 (diff)
Merge.
Diffstat (limited to 'src/lib/encoder.cc')
-rw-r--r--src/lib/encoder.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index d4a27d01b..3cc643cd6 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -425,18 +425,20 @@ Encoder::encoder_thread (ServerDescription* server)
void
Encoder::write_audio (shared_ptr<const AudioBuffers> data)
{
- if (_film->audio_channels() == 1) {
- /* We need to switch things around so that the mono channel is on
- the centre channel of a 5.1 set (with other channels silent).
- */
-
- shared_ptr<AudioBuffers> b (new AudioBuffers (6, data->frames ()));
- b->make_silent (libdcp::LEFT);
- b->make_silent (libdcp::RIGHT);
- memcpy (b->data()[libdcp::CENTRE], data->data()[0], data->frames() * sizeof(float));
- b->make_silent (libdcp::LFE);
- b->make_silent (libdcp::LS);
- b->make_silent (libdcp::RS);
+ AudioMapping m (_film->audio_channels ());
+ if (m.dcp_channels() != _film->audio_channels()) {
+
+ /* Remap (currently just for mono -> 5.1) */
+
+ shared_ptr<AudioBuffers> b (new AudioBuffers (m.dcp_channels(), data->frames ()));
+ for (int i = 0; i < m.dcp_channels(); ++i) {
+ optional<int> s = m.dcp_to_source (static_cast<libdcp::Channel> (i));
+ if (!s) {
+ b->make_silent (i);
+ } else {
+ memcpy (b->data()[i], data->data()[s.get()], data->frames() * sizeof(float));
+ }
+ }
data = b;
}