From 3c86d70cf46ca11212ae2e2f4d711db0f478c2f5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 1 Jun 2017 14:23:56 +0100 Subject: [PATCH] Re-add missing audio mapping in butler for preview. --- src/lib/butler.cc | 3 ++- src/lib/player.cc | 19 +------------------ src/lib/util.cc | 23 +++++++++++++++++++++++ src/lib/util.h | 3 +++ 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/lib/butler.cc b/src/lib/butler.cc index bf9fedceb..fde8e459b 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -20,6 +20,7 @@ #include "butler.h" #include "player.h" +#include "util.h" #include #include @@ -183,7 +184,7 @@ Butler::audio (shared_ptr audio) } } - _audio.put (audio); + _audio.put (remap (audio, _audio_channels, _audio_mapping)); } void diff --git a/src/lib/player.cc b/src/lib/player.cc index de221fef3..2e47da5bf 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -718,24 +718,7 @@ Player::audio_transform (shared_ptr content, AudioStreamPtr stream /* Remap */ - shared_ptr dcp_mapped (new AudioBuffers (_film->audio_channels(), content_audio.audio->frames())); - dcp_mapped->make_silent (); - - AudioMapping map = stream->mapping (); - for (int i = 0; i < map.input_channels(); ++i) { - for (int j = 0; j < dcp_mapped->channels(); ++j) { - if (map.get (i, static_cast (j)) > 0) { - dcp_mapped->accumulate_channel ( - content_audio.audio.get(), - i, - static_cast (j), - map.get (i, static_cast (j)) - ); - } - } - } - - content_audio.audio = dcp_mapped; + content_audio.audio = remap (content_audio.audio, _film->audio_channels(), stream->mapping()); /* Process */ diff --git a/src/lib/util.cc b/src/lib/util.cc index 0ce538cdf..4ffe3bd12 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -36,6 +36,7 @@ #include "digester.h" #include "audio_processor.h" #include "compose.hpp" +#include "audio_buffers.h" #include #include #include @@ -735,3 +736,25 @@ audio_channel_types (list mapped, int channels) return make_pair (non_lfe, lfe); } + +shared_ptr +remap (shared_ptr input, int output_channels, AudioMapping map) +{ + shared_ptr mapped (new AudioBuffers (output_channels, input->frames())); + mapped->make_silent (); + + for (int i = 0; i < map.input_channels(); ++i) { + for (int j = 0; j < mapped->channels(); ++j) { + if (map.get (i, static_cast (j)) > 0) { + mapped->accumulate_channel ( + input.get(), + i, + static_cast (j), + map.get (i, static_cast (j)) + ); + } + } + } + + return mapped; +} diff --git a/src/lib/util.h b/src/lib/util.h index db6c37fe1..b152b67b5 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -27,6 +27,7 @@ #include "types.h" #include "dcpomatic_time.h" +#include "audio_mapping.h" #include #include #include @@ -56,6 +57,7 @@ namespace dcp { extern std::string program_name; struct AVSubtitle; +class AudioBuffers; extern std::string seconds_to_hms (int); extern std::string seconds_to_approximate_hms (int); @@ -84,5 +86,6 @@ extern std::string audio_asset_filename (boost::shared_ptr asse extern float relaxed_string_to_float (std::string); extern std::string careful_string_filter (std::string); extern std::pair audio_channel_types (std::list mapped, int channels); +extern boost::shared_ptr remap (boost::shared_ptr input, int output_channels, AudioMapping map); #endif -- 2.30.2