Bv2.1 7.3: audio sample rate must be 48kHz.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Jan 2021 01:16:37 +0000 (02:16 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:23 +0000 (20:13 +0100)
src/sound_asset.h
src/verify.cc
src/verify.h
test/test.cc
test/test.h
test/verify_test.cc

index 69f74c6aa766b3651ddb9e9abbaf0ab924720c51..cc8f2ce069d8bc9ed3093facc45343e7387a55d1 100644 (file)
@@ -51,7 +51,7 @@ namespace dcp {
 }
 
 extern std::shared_ptr<dcp::SoundAsset> simple_sound (
-       boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames
+       boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate
        );
 
 
@@ -106,7 +106,7 @@ public:
 private:
        friend class SoundAssetWriter;
        friend std::shared_ptr<dcp::SoundAsset> (::simple_sound) (
-               boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames
+               boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate
                );
 
        std::string pkl_type (Standard standard) const {
index d1b4988a44ca18440f73b4a1c7214dfb7dfa16b2..b6498891ac4d06a045b20568e41e72b4497ca745 100644 (file)
@@ -616,6 +616,13 @@ verify_main_sound_asset (
        stage ("Checking sound asset metadata", asset->file());
 
        verify_language_tag (asset->language(), notes);
+       if (asset->sampling_rate() != 48000) {
+               notes.push_back (
+                       VerificationNote(
+                               VerificationNote::VERIFY_BV21_ERROR, VerificationNote::INVALID_SOUND_FRAME_RATE, *asset->file()
+                               )
+                       );
+       }
 }
 
 
@@ -1210,6 +1217,8 @@ dcp::note_to_string (dcp::VerificationNote note)
                return "There are more than 3 closed caption lines in at least one place, which is disallowed by Bv2.1";
        case dcp::VerificationNote::CLOSED_CAPTION_LINE_TOO_LONG:
                return "There are more than 32 characters in at least one closed caption line, which is disallowed by Bv2.1";
+       case dcp::VerificationNote::INVALID_SOUND_FRAME_RATE:
+               return "A sound asset has a sampling rate other than 48kHz, which is disallowed by Bv2.1";
        }
 
        return "";
index 0398c909d365028b499ac50f5b69e6fb99d445bd..fa16dfa12373a072af5c028c11e04d50eaf5c5a4 100644 (file)
@@ -131,6 +131,8 @@ public:
                TOO_MANY_CLOSED_CAPTION_LINES,
                /** There are more than 32 characters in at least one closed caption line [Bv2.1_7.2.6] */
                CLOSED_CAPTION_LINE_TOO_LONG,
+               /** The audio sampling rate must be 48kHz [Bv2.1_7.3] */
+               INVALID_SOUND_FRAME_RATE,
        };
 
        VerificationNote (Type type, Code code)
index 88fdb3a9b136499dca1e516efb4491b5d3ddb106..f110c9cbf2413209523fffe010b47add5b99484b 100644 (file)
@@ -276,9 +276,8 @@ simple_picture (boost::filesystem::path path, string suffix, int frames)
 
 
 shared_ptr<dcp::SoundAsset>
-simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames)
+simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames, int sample_rate)
 {
-       int const sample_rate = 48000;
        int const channels = 1;
 
        /* Set a valid language, then overwrite it, so that the language parameter can be badly formed */
@@ -289,7 +288,7 @@ simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_
        active_channels.push_back (dcp::LEFT);
        shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix), active_channels);
 
-       int const samples_per_frame = 48000 / 24;
+       int const samples_per_frame = sample_rate / 24;
 
        float* silence[channels];
        for (auto i = 0; i < channels; ++i) {
index 6a6a57d2e4c8422c56b7f109cba4b96f4d000307..5ed424bc0ec5c0a000ba0cb530acd25ce7098003 100644 (file)
@@ -44,7 +44,7 @@ extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::vector<st
 extern void check_xml (std::string ref, std::string test, std::vector<std::string> ignore, bool ignore_whitespace = false);
 extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);
 extern std::shared_ptr<dcp::MonoPictureAsset> simple_picture (boost::filesystem::path path, std::string suffix, int frames = 24);
-extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames = 24);
+extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames = 24, int sample_rate = 48000);
 extern std::shared_ptr<dcp::Subtitle> simple_subtitle ();
 extern std::shared_ptr<dcp::DCP> make_simple (boost::filesystem::path path, int reels = 1, int frames = 24);
 extern std::shared_ptr<dcp::DCP> make_simple_with_interop_subs (boost::filesystem::path path);
index 1877e284a6a99e6a5394e11fe5e28cdb20ab3dff..1789aafede67c01d46509038e88dbd7a05beb197 100644 (file)
@@ -1607,3 +1607,24 @@ BOOST_AUTO_TEST_CASE (verify_closed_caption_lines_too_long1)
        check_verify_result ({dir}, {{ dcp::VerificationNote::VERIFY_BV21_ERROR, dcp::VerificationNote::CLOSED_CAPTION_LINE_TOO_LONG }});
 }
 
+
+BOOST_AUTO_TEST_CASE (verify_sound_sampling_rate_must_be_48k)
+{
+       boost::filesystem::path const dir("verify_sound_sampling_rate_must_be_48k");
+       prepare_directory (dir);
+
+       auto picture = simple_picture (dir, "foo");
+       auto reel_picture = make_shared<dcp::ReelMonoPictureAsset>(picture, 0);
+       auto reel = make_shared<dcp::Reel>();
+       reel->add (reel_picture);
+       auto sound = simple_sound (dir, "foo", dcp::MXFMetadata(), "de-DE", 24, 96000);
+       auto reel_sound = make_shared<dcp::ReelSoundAsset>(sound, 0);
+       reel->add (reel_sound);
+       auto cpl = make_shared<dcp::CPL>("hello", dcp::FEATURE);
+       cpl->add (reel);
+       auto dcp = make_shared<dcp::DCP>(dir);
+       dcp->add (cpl);
+       dcp->write_xml (dcp::SMPTE);
+
+       check_verify_result ({dir}, {{ dcp::VerificationNote::VERIFY_BV21_ERROR, dcp::VerificationNote::INVALID_SOUND_FRAME_RATE }});
+}