Fix handling of subtitles at reel boundaries.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Mar 2021 09:36:56 +0000 (10:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Mar 2021 09:36:56 +0000 (10:36 +0100)
When a subtitle spans 3 reels were were backing off the end of the
subtitle at the end of reel #1 but not the one at the end of reel #2,
causing two subs to be too close together.

src/lib/writer.cc

index 4386b8e26264dea29a1e4cc41dce74212e915465..035fc2b1dbfa3328acd67f3f9ccc110e53c788a4 100644 (file)
@@ -802,6 +802,11 @@ Writer::write (PlayerText text, TextType type, optional<DCPTextTrack> track, DCP
                write_hanging_text (**reel);
        }
 
+       auto back_off = [this](DCPTimePeriod period) {
+               period.to -= DCPTime::from_frames(2, film()->video_frame_rate());
+               return period;
+       };
+
        if (period.to > (*reel)->period().to) {
                /* This text goes off the end of the reel.  Store parts of it that should go into
                 * other reels.
@@ -809,13 +814,14 @@ Writer::write (PlayerText text, TextType type, optional<DCPTextTrack> track, DCP
                for (auto i = std::next(*reel); i != _reels.end(); ++i) {
                        auto overlap = i->period().overlap(period);
                        if (overlap) {
-                               _hanging_texts.push_back (HangingText{text, type, track, *overlap});
+                               _hanging_texts.push_back (HangingText{text, type, track, back_off(*overlap)});
                        }
                }
                /* Back off from the reel boundary by a couple of frames to avoid tripping checks
                 * for subtitles being too close together.
                 */
-               period.to = (*reel)->period().to - DCPTime::from_frames(2, film()->video_frame_rate());
+               period.to = (*reel)->period().to;
+               period = back_off(period);
        }
 
        (*reel)->write (text, type, track, period);