Don't write MainSoundConfiguration with 71 when we only have HI/VI (#2580).
authorCarl Hetherington <cth@carlh.net>
Fri, 30 Jun 2023 21:54:42 +0000 (23:54 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 30 Jun 2023 21:54:42 +0000 (23:54 +0200)
src/lib/writer.cc
test/cpl_metadata_test.cc [new file with mode: 0644]
test/wscript

index d42b23478f469e68e4c650f03b5606c918e2ec57..9e998a8307c1d9a4937343b88761a99bbd2320d8 100644 (file)
@@ -29,6 +29,7 @@
 #include "dcp_video.h"
 #include "dcpomatic_log.h"
 #include "film.h"
+#include "film_util.h"
 #include "job.h"
 #include "log.h"
 #include "ratio.h"
@@ -646,10 +647,10 @@ Writer::finish (boost::filesystem::path output_dcp)
        }
 
        dcp::MCASoundField field;
-       if (film()->audio_channels() <= 6) {
-               field = dcp::MCASoundField::FIVE_POINT_ONE;
-       } else {
+       if (channel_is_mapped(film(), dcp::Channel::BSL) || channel_is_mapped(film(), dcp::Channel::BSR)) {
                field = dcp::MCASoundField::SEVEN_POINT_ONE;
+       } else {
+               field = dcp::MCASoundField::FIVE_POINT_ONE;
        }
 
        dcp::MainSoundConfiguration msc(field, MAX_DCP_AUDIO_CHANNELS);
diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc
new file mode 100644 (file)
index 0000000..b9c274f
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/audio_content.h"
+#include "lib/content.h"
+#include "lib/content_factory.h"
+#include "lib/film.h"
+#include "test.h"
+#include <dcp/cpl.h>
+#include <dcp/dcp.h>
+#include <boost/test/unit_test.hpp>
+
+
+using std::shared_ptr;
+
+
+BOOST_AUTO_TEST_CASE(main_sound_configuration_test_51_vi)
+{
+       auto picture = content_factory("test/data/flat_red.png")[0];
+       auto L = content_factory("test/data/L.wav")[0];
+       auto R = content_factory("test/data/R.wav")[0];
+       auto C = content_factory("test/data/C.wav")[0];
+       auto Lfe = content_factory("test/data/Lfe.wav")[0];
+       auto Ls = content_factory("test/data/Ls.wav")[0];
+       auto Rs = content_factory("test/data/Rs.wav")[0];
+       auto VI = content_factory("test/data/sine_440.wav")[0];
+
+       auto film = new_test_film2("main_sound_configuration_test_51_vi", { picture, L, R, C, Lfe, Ls, Rs, VI });
+       film->set_audio_channels(8);
+
+       auto set_map = [](shared_ptr<Content> content, dcp::Channel channel) {
+               auto map = content->audio->mapping();
+               map.set(0, channel, 1.0f);
+               content->audio->set_mapping(map);
+       };
+
+       set_map(L, dcp::Channel::LEFT);
+       set_map(R, dcp::Channel::RIGHT);
+       set_map(C, dcp::Channel::CENTRE);
+       set_map(Lfe, dcp::Channel::LFE);
+       set_map(Ls, dcp::Channel::LS);
+       set_map(Rs, dcp::Channel::RS);
+       set_map(VI, dcp::Channel::VI);
+
+       make_and_verify_dcp(film);
+
+       dcp::DCP dcp(film->dir(film->dcp_name()));
+       dcp.read();
+       BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U);
+       auto cpl = dcp.cpls()[0];
+
+       auto msc = cpl->main_sound_configuration();
+       BOOST_REQUIRE(msc);
+
+       /* We think this should say 51 not 71 at the start (#2580) */
+       BOOST_CHECK_EQUAL(msc->to_string(), "51/L,R,C,LFE,Ls,Rs,-,VIN,-,-,-,-,-,-,-,-");
+}
+
index 3cfe22799c918443fc1ede0d87f3bc137d821e10..e1c12f89d8bd34d7d1fb6e84fb8672a33334e2d6 100644 (file)
@@ -67,6 +67,7 @@ def build(bld):
                  config_test.cc
                  content_test.cc
                  cpl_hash_test.cc
+                 cpl_metadata_test.cc
                  create_cli_test.cc
                  crypto_test.cc
                  dcpomatic_time_test.cc