Re-add missing audio mapping in butler for preview.
authorCarl Hetherington <cth@carlh.net>
Thu, 1 Jun 2017 13:23:56 +0000 (14:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 1 Jun 2017 13:23:56 +0000 (14:23 +0100)
src/lib/butler.cc
src/lib/player.cc
src/lib/util.cc
src/lib/util.h

index bf9fedceba75cf66820c39cbb3aca2a2ebf71005..fde8e459b5372777cccc72f3330f155d11cddc55 100644 (file)
@@ -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
index de221fef357c17ed849725f9d57376f07786b8b0..2e47da5bfc9306c16077410be99dc7b5d00d7415 100644 (file)
@@ -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 */
 
index 0ce538cdff2429fbd4f571a57e14e292faddef8e..4ffe3bd12bb8ed4f76092286f8aad08ce4fe0691 100644 (file)
@@ -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;
+}
index db6c37fe11fa5a423e0cb47eb61c0cd6aa47b3f0..b152b67b514cfb3ba2a9db90d094e8774d7bb190 100644 (file)
@@ -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