diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-25 20:52:20 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-25 20:52:20 +0000 |
| commit | eac941aed6e6eed7f0329e42c7a036ed620f8df0 (patch) | |
| tree | 5a494d82b2ba88223f162e8f8c01ad016ba293b0 /src/lib/encoder.cc | |
| parent | 6e0f2a39c9deeb51f05c0c8c9bd46632c2c6483a (diff) | |
Try to tidy up channel mapping a bit.
Diffstat (limited to 'src/lib/encoder.cc')
| -rw-r--r-- | src/lib/encoder.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index f25256379..07139968d 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -423,18 +423,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; } |
