From 4f03da3aa12525cb8389ddefee629f5d0b2ac0aa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 24 May 2013 22:00:53 +0100 Subject: Partial addition of DCP audio channel count to Film. --- src/lib/audio_decoder.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/lib/audio_decoder.cc') 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 data, Time time) { - /* XXX: map audio to 5.1 */ - /* Maybe resample */ if (_swr_context) { @@ -122,7 +120,7 @@ AudioDecoder::audio (shared_ptr data, Time time) (int64_t) data->frames() * _audio_content->output_audio_frame_rate() / _audio_content->content_audio_frame_rate() ) + 32; - shared_ptr resampled (new AudioBuffers (MAX_AUDIO_CHANNELS, max_resampled_frames)); + shared_ptr resampled (new AudioBuffers (data->channels(), max_resampled_frames)); /* Resample audio */ int const resampled_frames = swr_convert ( @@ -139,10 +137,18 @@ AudioDecoder::audio (shared_ptr data, Time time) data = resampled; } - Audio (data, time); - shared_ptr film = _film.lock (); assert (film); + + /* Remap channels */ + shared_ptr dcp_mapped (film->dcp_audio_channels(), data->frames()); + dcp_mapped->make_silent (); + list > map = _audio_content->audio_mapping().content_to_dcp (); + for (list >::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()); } -- cgit v1.2.3