Add check for mismatch between sound asset and MainSoundConfiguration. v1.8.66
authorCarl Hetherington <cth@carlh.net>
Tue, 4 Apr 2023 21:09:29 +0000 (23:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 4 Apr 2023 21:37:44 +0000 (23:37 +0200)
src/verify.cc
src/verify.h
test/verify_test.cc

index 1cab0423bfda14d9614107e301224179e31fa38d..8b2b11d36eda159dcf5555e0404d3176087805d3 100644 (file)
@@ -1571,6 +1571,16 @@ verify_cpl(
        verify_text_details(cpl->reels(), notes);
 
        if (dcp->standard() == Standard::SMPTE) {
+               if (auto msc = cpl->main_sound_configuration()) {
+                       if (state.audio_channels && msc->channels() != *state.audio_channels) {
+                               notes.push_back({
+                                               VerificationNote::Type::ERROR,
+                                               VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION,
+                                               String::compose("MainSoundConfiguration has %1 channels but sound assets have %2", msc->channels(), *state.audio_channels),
+                                               cpl->file().get()
+                                       });
+                       }
+               }
 
                if (have_main_subtitle && have_no_main_subtitle) {
                        notes.push_back({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_MAIN_SUBTITLE_FROM_SOME_REELS});
@@ -1996,6 +2006,8 @@ dcp::note_to_string (VerificationNote note)
                return String::compose("<IssueDate> has an invalid value: %1", note.note().get());
        case VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS:
                return String::compose("The sound assets do not all have the same channel count; the first to differ is %1", note.file()->filename());
+       case VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION:
+               return String::compose("<MainSoundConfiguration> has an invalid value: %1", note.note().get());
        }
 
        return "";
index d05c92ebc8b713596c7cd895b6509ef05205907e..7696ea851151ab2bf5e32b6c53a07335e9b4e1e8 100644 (file)
@@ -425,7 +425,13 @@ public:
                /** The sound assets in the CPL do not have the same audio channel count.
                 *  file contains the filename of the first asset to differ
                 */
-               MISMATCHED_SOUND_CHANNEL_COUNTS
+               MISMATCHED_SOUND_CHANNEL_COUNTS,
+               /** The CPL contains a MainSoundConfiguration tag which does not describe the number of
+                *  channels in the audio assets.
+                *  note contains details of what is wrong
+                *  file contains the CPL filename
+                */
+               INVALID_MAIN_SOUND_CONFIGURATION,
        };
 
        VerificationNote (Type type, Code code)
index a0786d9c9377f5a2001e5c49d82b570b442727a0..4c1d1b7d09bc18945c47931e288dc51b52ddd1e7 100644 (file)
@@ -3516,3 +3516,54 @@ BOOST_AUTO_TEST_CASE(verify_mismatched_sound_channel_counts)
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS, canonical(find_file(path, "audio2")) },
                });
 }
+
+
+BOOST_AUTO_TEST_CASE(verify_invalid_main_sound_configuration)
+{
+       boost::filesystem::path const path = "build/test/verify_invalid_main_sound_configuration";
+
+       dcp::MXFMetadata mxf_meta;
+       mxf_meta.company_name = "OpenDCP";
+       mxf_meta.product_name = "OpenDCP";
+       mxf_meta.product_version = "0.0.25";
+
+       auto constexpr sample_rate = 48000;
+       auto constexpr frames = 240;
+
+       boost::filesystem::remove_all(path);
+       boost::filesystem::create_directories(path);
+       auto dcp = make_shared<dcp::DCP>(path);
+       auto cpl = make_shared<dcp::CPL>("hello", dcp::ContentKind::TRAILER, dcp::Standard::SMPTE);
+       cpl->set_annotation_text("hello");
+       cpl->set_main_sound_configuration(dcp::MainSoundConfiguration("51/L,R,C,LFE,Ls,Rs"));
+       cpl->set_main_sound_sample_rate(sample_rate);
+       cpl->set_main_picture_stored_area(dcp::Size(1998, 1080));
+       cpl->set_main_picture_active_area(dcp::Size(1998, 1080));
+       cpl->set_version_number(1);
+
+       auto mp = simple_picture(path, "1", frames, {});
+       auto ms = simple_sound(path, "1", mxf_meta, "en-US", frames, sample_rate, {}, 2);
+
+       auto reel = make_shared<dcp::Reel>(
+               std::make_shared<dcp::ReelMonoPictureAsset>(mp, 0),
+               std::make_shared<dcp::ReelSoundAsset>(ms, 0)
+               );
+
+       auto markers = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), frames);
+       markers->set(dcp::Marker::FFOC, dcp::Time(0, 0, 0, 1, 24));
+       markers->set(dcp::Marker::LFOC, dcp::Time(0, 0, 9, 23, 24));
+       reel->add(markers);
+
+       cpl->add(reel);
+
+       dcp->add(cpl);
+       dcp->set_annotation_text("hello");
+       dcp->write_xml();
+
+       check_verify_result(
+               { path },
+               {
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION, std::string{"MainSoundConfiguration has 6 channels but sound assets have 2"}, canonical(find_cpl(path)) },
+               });
+}
+