Make subtitle checking robust to CPLs with no subs/ccaps in some reels.
authorCarl Hetherington <cth@carlh.net>
Thu, 14 Jan 2021 22:38:03 +0000 (23:38 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:23 +0000 (20:13 +0100)
src/verify.cc

index 44b3b657fc92ff32f9b140779b820244c290df8f..dc43570633ec1d0563ca4c7d26aa18900d67f344 100644 (file)
@@ -765,6 +765,7 @@ check_text_timing (
        vector<shared_ptr<dcp::Reel>> reels,
        optional<int> picture_frame_rate,
        vector<VerificationNote>& notes,
+       std::function<bool (shared_ptr<dcp::Reel>)> check,
        std::function<string (shared_ptr<dcp::Reel>)> xml,
        std::function<int64_t (shared_ptr<dcp::Reel>)> duration
        )
@@ -805,6 +806,10 @@ check_text_timing (
        };
 
        for (auto i = 0U; i < reels.size(); ++i) {
+               if (!check(reels[i])) {
+                       continue;
+               }
+
                /* We need to look at <Subtitle> instances in the XML being checked, so we can't use the subtitles
                 * read in by libdcp's parser.
                 */
@@ -956,6 +961,9 @@ check_text_timing (vector<shared_ptr<dcp::Reel>> reels, vector<VerificationNote>
 
        if (reels[0]->main_subtitle()) {
                check_text_timing (reels, picture_frame_rate, notes,
+                       [](shared_ptr<dcp::Reel> reel) {
+                               return static_cast<bool>(reel->main_subtitle());
+                       },
                        [](shared_ptr<dcp::Reel> reel) {
                                return reel->main_subtitle()->asset()->raw_xml();
                        },
@@ -967,6 +975,9 @@ check_text_timing (vector<shared_ptr<dcp::Reel>> reels, vector<VerificationNote>
 
        for (auto i = 0U; i < reels[0]->closed_captions().size(); ++i) {
                check_text_timing (reels, picture_frame_rate, notes,
+                       [i](shared_ptr<dcp::Reel> reel) {
+                               return i < reel->closed_captions().size();
+                       },
                        [i](shared_ptr<dcp::Reel> reel) {
                                return reel->closed_captions()[i]->asset()->raw_xml();
                        },