diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-24 22:00:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-24 22:00:53 +0100 |
| commit | 4f03da3aa12525cb8389ddefee629f5d0b2ac0aa (patch) | |
| tree | 0552aa98738c47c9328c4b86adad7348607ea8a4 /src/lib/audio_decoder.cc | |
| parent | 5b44e42b4a90331c88b15ed02a7f3d333690b9eb (diff) | |
Partial addition of DCP audio channel count to Film.
Diffstat (limited to 'src/lib/audio_decoder.cc')
| -rw-r--r-- | src/lib/audio_decoder.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 6712e0624..8950e1546 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -112,8 +112,6 @@ AudioDecoder::process_end () void AudioDecoder::audio (shared_ptr<const AudioBuffers> data, Time time) { - /* XXX: map audio to 5.1 */ - /* Maybe resample */ if (_swr_context) { @@ -122,7 +120,7 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, Time time) (int64_t) data->frames() * _audio_content->output_audio_frame_rate() / _audio_content->content_audio_frame_rate() ) + 32; - shared_ptr<AudioBuffers> resampled (new AudioBuffers (MAX_AUDIO_CHANNELS, max_resampled_frames)); + shared_ptr<AudioBuffers> resampled (new AudioBuffers (data->channels(), max_resampled_frames)); /* Resample audio */ int const resampled_frames = swr_convert ( @@ -139,10 +137,18 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, Time time) data = resampled; } - Audio (data, time); - shared_ptr<const Film> film = _film.lock (); assert (film); + + /* Remap channels */ + shared_ptr<AudioBuffers> dcp_mapped (film->dcp_audio_channels(), data->frames()); + dcp_mapped->make_silent (); + list<pair<int, libdcp::Channel> > map = _audio_content->audio_mapping().content_to_dcp (); + for (list<pair<int, libdcp::Channel> >::iterator i = map.begin(); i != map.end(); ++i) { + dcp_mapped->accumulate (data, i->first, i->second); + } + + Audio (dcp_mapped, time); _next_audio = time + film->audio_frames_to_time (data->frames()); } |
