summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/butler.cc3
-rw-r--r--src/lib/player.cc19
-rw-r--r--src/lib/util.cc23
-rw-r--r--src/lib/util.h3
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 <boost/weak_ptr.hpp>
#include <boost/shared_ptr.hpp>
@@ -183,7 +184,7 @@ Butler::audio (shared_ptr<AudioBuffers> 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<AudioContent> content, AudioStreamPtr stream
/* Remap */
- shared_ptr<AudioBuffers> 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<dcp::Channel> (j)) > 0) {
- dcp_mapped->accumulate_channel (
- content_audio.audio.get(),
- i,
- static_cast<dcp::Channel> (j),
- map.get (i, static_cast<dcp::Channel> (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 <dcp/locale_convert.h>
#include <dcp/util.h>
#include <dcp/raw_convert.h>
@@ -735,3 +736,25 @@ audio_channel_types (list<int> mapped, int channels)
return make_pair (non_lfe, lfe);
}
+
+shared_ptr<AudioBuffers>
+remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map)
+{
+ shared_ptr<AudioBuffers> 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<dcp::Channel> (j)) > 0) {
+ mapped->accumulate_channel (
+ input.get(),
+ i,
+ static_cast<dcp::Channel> (j),
+ map.get (i, static_cast<dcp::Channel> (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 <dcp/util.h>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
@@ -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<dcp::SoundAsset> asse
extern float relaxed_string_to_float (std::string);
extern std::string careful_string_filter (std::string);
extern std::pair<int, int> audio_channel_types (std::list<int> mapped, int channels);
+extern boost::shared_ptr<AudioBuffers> remap (boost::shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map);
#endif