Bv2.1 7.2.1: Check total size of all timed text fonts is not larger than 10MB.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Dec 2020 22:49:48 +0000 (23:49 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:22 +0000 (20:13 +0100)
I'm not sure if this is what Bv2.1 means, but hopefully it's close
enough.

src/verify.cc
src/verify.h
test/verify_test.cc

index 3c36e8f660e812938a9c791a0bb21ea5696dc7aa..428c737fabaadfd0ab99152845928ccda7b726f8 100644 (file)
@@ -666,6 +666,21 @@ verify_subtitle_asset (
                                        )
                                );
                }
+               /* XXX: I'm not sure what Bv2.1_7.2.1 means when it says "the font resource shall not be larger than 10MB"
+                * but I'm hoping that checking for the total size of all fonts being <= 10MB will do.
+                */
+               map<string, ArrayData> fonts = asset->font_data ();
+               int total_size = 0;
+               for (map<string, ArrayData>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
+                       total_size += i->second.size();
+               }
+               if (total_size > 10 * 1024 * 1024) {
+                       notes.push_back (
+                               VerificationNote(
+                                       VerificationNote::VERIFY_BV21_ERROR, VerificationNote::TIMED_TEXT_FONTS_TOO_LARGE_IN_BYTES, *asset->file()
+                                       )
+                               );
+               }
        }
 }
 
@@ -866,6 +881,8 @@ dcp::note_to_string (dcp::VerificationNote note)
                return String::compose("The XML for the closed caption asset %1 is longer than the 256KB maximum required by Bv2.1", note.file()->filename());
        case dcp::VerificationNote::TIMED_TEXT_ASSET_TOO_LARGE_IN_BYTES:
                return String::compose("The total size of the timed text asset %1 is larger than the 115MB maximum required by Bv2.1", note.file()->filename());
+       case dcp::VerificationNote::TIMED_TEXT_FONTS_TOO_LARGE_IN_BYTES:
+               return String::compose("The total size of the fonts in timed text asset %1 is larger than the 10MB maximum required by Bv2.1", note.file()->filename());
        }
 
        return "";
index 3b5dafac37e76cc3a552692e07f076badbf7ce42..c30718ebba9a34570f61c4e82abed1b1b6ef8add 100644 (file)
@@ -106,6 +106,8 @@ public:
                CLOSED_CAPTION_XML_TOO_LARGE_IN_BYTES,
                /** Any timed text asset's total files is larger than 115MB [Bv2.1_7.2.1] */
                TIMED_TEXT_ASSET_TOO_LARGE_IN_BYTES,
+               /** The total size of all a timed text asset's fonts is larger than 10MB [Bv2.1_7.2.1] */
+               TIMED_TEXT_FONTS_TOO_LARGE_IN_BYTES,
        };
 
        VerificationNote (Type type, Code code)
index 74fd81e86be54fbde7bba45e4ec7e6894f6d30d2..e468f28631527676df308621bc3644e2dd354d25 100644 (file)
@@ -1271,9 +1271,13 @@ verify_timed_text_asset_too_large (string name)
        vector<boost::filesystem::path> dirs;
        dirs.push_back (dir);
        list<dcp::VerificationNote> notes = dcp::verify (dirs, &stage, &progress, xsd_test);
-       BOOST_REQUIRE_EQUAL (notes.size(), 1U);
-       BOOST_CHECK_EQUAL (notes.front().type(), dcp::VerificationNote::VERIFY_BV21_ERROR);
-       BOOST_CHECK_EQUAL (notes.front().code(), dcp::VerificationNote::TIMED_TEXT_ASSET_TOO_LARGE_IN_BYTES);
+       BOOST_REQUIRE_EQUAL (notes.size(), 2U);
+       list<dcp::VerificationNote>::const_iterator i = notes.begin();
+       BOOST_CHECK_EQUAL (i->type(), dcp::VerificationNote::VERIFY_BV21_ERROR);
+       BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::TIMED_TEXT_ASSET_TOO_LARGE_IN_BYTES);
+       ++i;
+       BOOST_CHECK_EQUAL (i->type(), dcp::VerificationNote::VERIFY_BV21_ERROR);
+       BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::TIMED_TEXT_FONTS_TOO_LARGE_IN_BYTES);
 }