Fix error when exporting stereo projects with "mixdown to stereo" v2.15.79
authorCarl Hetherington <cth@carlh.net>
Sun, 14 Jun 2020 20:12:51 +0000 (22:12 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 14 Jun 2020 20:12:51 +0000 (22:12 +0200)
set.

src/lib/ffmpeg_encoder.cc
test/ffmpeg_encoder_test.cc

index 61e489f071c112e6d092438430ba919e83654a2d..ee49a06461133e8d57dece989e5afb4572cdbc7a 100644 (file)
@@ -104,12 +104,24 @@ FFmpegEncoder::FFmpegEncoder (
                map = AudioMapping (ch, 2);
                float const overall_gain = 2 / (4 + sqrt(2));
                float const minus_3dB = 1 / sqrt(2);
-               map.set (dcp::LEFT,   0, overall_gain);
-               map.set (dcp::RIGHT,  1, overall_gain);
-               map.set (dcp::CENTRE, 0, overall_gain * minus_3dB);
-               map.set (dcp::CENTRE, 1, overall_gain * minus_3dB);
-               map.set (dcp::LS,     0, overall_gain);
-               map.set (dcp::RS,     1, overall_gain);
+               if (ch == 2) {
+                       map.set (dcp::LEFT, 0, 1);
+                       map.set (dcp::RIGHT, 1, 1);
+               } else if (ch == 4) {
+                       map.set (dcp::LEFT,   0, overall_gain);
+                       map.set (dcp::RIGHT,  1, overall_gain);
+                       map.set (dcp::CENTRE, 0, overall_gain * minus_3dB);
+                       map.set (dcp::CENTRE, 1, overall_gain * minus_3dB);
+                       map.set (dcp::LS,     0, overall_gain);
+               } else if (ch >= 6) {
+                       map.set (dcp::LEFT,   0, overall_gain);
+                       map.set (dcp::RIGHT,  1, overall_gain);
+                       map.set (dcp::CENTRE, 0, overall_gain * minus_3dB);
+                       map.set (dcp::CENTRE, 1, overall_gain * minus_3dB);
+                       map.set (dcp::LS,     0, overall_gain);
+                       map.set (dcp::RS,     1, overall_gain);
+               }
+               /* XXX: maybe we should do something better for >6 channel DCPs */
        } else {
                _output_audio_channels = ch;
                map = AudioMapping (ch, ch);
index 10186abcc92aa247dd423ed7619ab0f7cd47e909..d824ede30bebcca1c46fe768c1e705bcaa0e8e80 100644 (file)
@@ -376,3 +376,20 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test7)
        encoder.go ();
 }
 
+
+/** Stereo project with mixdown-to-stereo set */
+BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test8)
+{
+       shared_ptr<Film> film = new_test_film2("ffmpeg_encoder_h264_test4");
+       film->examine_and_add_content(shared_ptr<DCPContent>(new DCPContent("test/data/scope_dcp")));
+       BOOST_REQUIRE(!wait_for_jobs());
+       film->set_audio_channels (2);
+
+       shared_ptr<Job> job(new TranscodeJob(film));
+       FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test8.mp4", EXPORT_FORMAT_H264_AAC, true, false, 23
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+                              , optional<dcp::Key>(), optional<string>()
+#endif
+               );
+       encoder.go();
+}