Always make 16-channel MXFs.
authorCarl Hetherington <cth@carlh.net>
Thu, 16 Mar 2023 22:03:08 +0000 (23:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Mar 2023 15:43:07 +0000 (17:43 +0200)
cscript
run/tests
src/lib/reel_writer.cc
src/lib/writer.cc
test/data
test/ffmpeg_audio_test.cc
test/silence_padding_test.cc

diff --git a/cscript b/cscript
index ddb4cbf4d300b02cbe270e79effdefae0db09347..ef74488894fe123f941fffefea3cb6d40c3d12c3 100644 (file)
--- a/cscript
+++ b/cscript
@@ -477,7 +477,7 @@ def dependencies(target, options):
         # Use distro-provided FFmpeg on Arch
         deps = []
 
-    deps.append(('libdcp', 'v1.8.64'))
+    deps.append(('libdcp', 'v1.8.65'))
     deps.append(('libsub', 'v1.6.44'))
     deps.append(('leqm-nrt', '4560105773c66ac9216b62313a24093bb0a027ae'))
     deps.append(('rtaudio', 'f619b76'))
index b211e035a2f49fe9f2b6aff048afb16bfd0b6e36..fc13f4b1c167908e855990fd40f52ed7f63fca49 100755 (executable)
--- a/run/tests
+++ b/run/tests
@@ -3,7 +3,7 @@
 # e.g. --run_tests=foo
 set -e
 
-PRIVATE_GIT="fe0425b204ed2dcac9e6e134b72fba7f43d8c2eb"
+PRIVATE_GIT="49276da301a937fbf09bc9e7b5a537cdee72bc46"
 
 if [ "$1" == "--check" ]; then
        shift 1
index 31860e8816131da9973231612a19d415866001d9..9ffe1cdc53f1a2f9f45344cd86bbbaa778cbcd30 100644 (file)
@@ -22,6 +22,7 @@
 #include "audio_buffers.h"
 #include "compose.hpp"
 #include "config.h"
+#include "constants.h"
 #include "cross.h"
 #include "dcpomatic_log.h"
 #include "digester.h"
@@ -161,7 +162,7 @@ ReelWriter::ReelWriter (
                }
 
                _picture_asset->set_file (asset);
-               _picture_asset_writer = _picture_asset->start_write (asset, _first_nonexistent_frame > 0);
+               _picture_asset_writer = _picture_asset->start_write(asset, _first_nonexistent_frame > 0 ? dcp::PictureAsset::Behaviour::OVERWRITE_EXISTING : dcp::PictureAsset::Behaviour::MAKE_NEW);
        } else if (!text_only) {
                /* We already have a complete picture asset that we can just re-use */
                /* XXX: what about if the encryption key changes? */
@@ -177,7 +178,8 @@ ReelWriter::ReelWriter (
                _sound_asset = make_shared<dcp::SoundAsset> (
                        dcp::Fraction(film()->video_frame_rate(), 1),
                        film()->audio_frame_rate(),
-                       film()->audio_channels(),
+                       /* Always make 16-channel sound assets for SMPTE; libdcp will pad unused channels for us */
+                       standard == dcp::Standard::SMPTE ? MAX_DCP_AUDIO_CHANNELS : film()->audio_channels(),
                        lang ? *lang : dcp::LanguageTag("en-US"),
                        standard
                        );
@@ -195,8 +197,9 @@ ReelWriter::ReelWriter (
                */
                _sound_asset_writer = _sound_asset->start_write (
                        film()->directory().get() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
-                       film()->contains_atmos_content(),
-                       !film()->limit_to_smpte_bv20()
+                       film()->audio_channels(),
+                       film()->contains_atmos_content() ? dcp::SoundAsset::AtmosSync::ENABLED : dcp::SoundAsset::AtmosSync::DISABLED,
+                       film()->limit_to_smpte_bv20() ? dcp::SoundAsset::MCASubDescriptors::DISABLED : dcp::SoundAsset::MCASubDescriptors::ENABLED
                        );
        }
 
@@ -821,7 +824,7 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio)
        }
 
        DCPOMATIC_ASSERT (audio);
-       _sound_asset_writer->write (audio->data(), audio->frames());
+       _sound_asset_writer->write(audio->data(), audio->channels(), audio->frames());
 }
 
 
index 2a2925cf0e1224a0e7776d5884633517833228f1..b0bd4aaff4766c3ab27c7d859f97cd27c5988951 100644 (file)
@@ -645,9 +645,7 @@ Writer::finish (boost::filesystem::path output_dcp)
        }
 
        dcp::MCASoundField field;
-       if (film()->audio_channels() == 2) {
-               field = dcp::MCASoundField::STEREO;
-       } else if (film()->audio_channels() <= 6) {
+       if (film()->audio_channels() <= 6) {
                field = dcp::MCASoundField::FIVE_POINT_ONE;
        } else {
                field = dcp::MCASoundField::SEVEN_POINT_ONE;
index c79ab114fdd6ca5f2f20a9d13d9203826f7f6c6a..e9a0aaeeafed9ba73d09e0ee97f6fe2f6ba1b9d6 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit c79ab114fdd6ca5f2f20a9d13d9203826f7f6c6a
+Subproject commit e9a0aaeeafed9ba73d09e0ee97f6fe2f6ba1b9d6
index 054567d3b2e136444416ba8a644481e3b01d20ce..910fc942c488d4d28a90b53d218eb4bedfaf6dd4 100644 (file)
  */
 
 
-#include "lib/ffmpeg_content.h"
-#include "lib/film.h"
+#include "lib/constants.h"
+#include "lib/content_factory.h"
 #include "lib/dcp_content_type.h"
-#include "lib/video_content.h"
-#include "lib/ratio.h"
 #include "lib/ffmpeg_content.h"
-#include "lib/content_factory.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/film.h"
 #include "lib/player.h"
+#include "lib/ratio.h"
+#include "lib/video_content.h"
 #include "test.h"
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
@@ -70,7 +71,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test)
 
        auto sound_asset = check.cpls().front()->reels().front()->main_sound ();
        BOOST_CHECK (sound_asset);
-       BOOST_CHECK_EQUAL (sound_asset->asset()->channels (), 6);
+       BOOST_CHECK_EQUAL(sound_asset->asset()->channels (), 16);
 
        /* Sample index in the DCP */
        int n = 0;
@@ -80,46 +81,17 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test)
        while (n < sound_asset->asset()->intrinsic_duration()) {
                auto sound_frame = sound_asset->asset()->start_read()->get_frame (frame++);
                uint8_t const * d = sound_frame->data ();
-
-               for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) {
-
-                       if (sound_asset->asset()->channels() > 0) {
-                               /* L should be silent */
-                               int const sample = d[i + 0] | (d[i + 1] << 8);
-                               BOOST_CHECK_EQUAL (sample, 0);
+               for (int offset = 0; offset < sound_frame->size(); offset += (3 * sound_asset->asset()->channels())) {
+                       for (auto channel = 0; channel < MAX_DCP_AUDIO_CHANNELS; ++channel) {
+                               auto const sample = d[offset + channel * 3 + 1] | (d[offset + channel * 3 + 2] << 8);
+                               if (channel == 2) {
+                                       /* Input should be on centre */
+                                       BOOST_CHECK_EQUAL(sample, n);
+                               } else {
+                                       /* Everything else should be silent */
+                                       BOOST_CHECK_EQUAL(sample, 0);
+                               }
                        }
-
-                       if (sound_asset->asset()->channels() > 1) {
-                               /* R should be silent */
-                               int const sample = d[i + 2] | (d[i + 3] << 8);
-                               BOOST_CHECK_EQUAL (sample, 0);
-                       }
-
-                       if (sound_asset->asset()->channels() > 2) {
-                               /* Mono input so it will appear on centre */
-                               int const sample = d[i + 7] | (d[i + 8] << 8);
-                               BOOST_CHECK_EQUAL (sample, n);
-                       }
-
-                       if (sound_asset->asset()->channels() > 3) {
-                               /* Lfe should be silent */
-                               int const sample = d[i + 9] | (d[i + 10] << 8);
-                               BOOST_CHECK_EQUAL (sample, 0);
-                       }
-
-                       if (sound_asset->asset()->channels() > 4) {
-                               /* Ls should be silent */
-                               int const sample = d[i + 11] | (d[i + 12] << 8);
-                               BOOST_CHECK_EQUAL (sample, 0);
-                       }
-
-
-                       if (sound_asset->asset()->channels() > 5) {
-                               /* Rs should be silent */
-                               int const sample = d[i + 13] | (d[i + 14] << 8);
-                               BOOST_CHECK_EQUAL (sample, 0);
-                       }
-
                        ++n;
                }
        }
index 45908bba8cd2a90a264cd7a08d07f018b3f4c2ba..59614c6c0f0b39e7cc7e68d5eb19aa81a119df99 100644 (file)
@@ -47,7 +47,7 @@ using boost::lexical_cast;
 
 
 static void
-test_silence_padding (int channels)
+test_silence_padding(int channels, dcp::Standard standard)
 {
        string const film_name = "silence_padding_test_" + lexical_cast<string> (channels);
        auto film = new_test_film2 (
@@ -57,8 +57,16 @@ test_silence_padding (int channels)
                        make_shared<FFmpegContent>("test/data/staircase.wav")
                });
 
+       if (standard == dcp::Standard::INTEROP) {
+               film->set_interop(true);
+       }
        film->set_audio_channels (channels);
-       make_and_verify_dcp (film);
+
+       std::vector<dcp::VerificationNote::Code> codes;
+       if (standard == dcp::Standard::INTEROP) {
+               codes.push_back(dcp::VerificationNote::Code::INVALID_STANDARD);
+       }
+       make_and_verify_dcp(film, codes);
 
        boost::filesystem::path path = "build/test";
        path /= film_name;
@@ -75,6 +83,13 @@ test_silence_padding (int channels)
        /* DCP sound asset frame */
        int frame = 0;
 
+       auto const asset_channels = sound_asset->asset()->channels();
+       if (standard == dcp::Standard::SMPTE) {
+               DCP_ASSERT(asset_channels == MAX_DCP_AUDIO_CHANNELS)
+       } else {
+               DCP_ASSERT(asset_channels == channels);
+       }
+
        while (n < sound_asset->asset()->intrinsic_duration()) {
                auto sound_frame = sound_asset->asset()->start_read()->get_frame(frame++);
                uint8_t const * d = sound_frame->data ();
@@ -101,8 +116,10 @@ test_silence_padding (int channels)
 BOOST_AUTO_TEST_CASE (silence_padding_test)
 {
        for (int i = 1; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
-               test_silence_padding (i);
+               test_silence_padding(i, dcp::Standard::INTEROP);
        }
+
+       test_silence_padding(MAX_DCP_AUDIO_CHANNELS, dcp::Standard::SMPTE);
 }