diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-03-16 14:24:48 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-03-16 14:37:42 +0100 |
| commit | 3b78e9223c9be784531475acacb88b59b2459f48 (patch) | |
| tree | 7c97e11d3e4fd364f015c186594b41d13bcca495 /src/lib/writer.cc | |
| parent | 7a1563c37d6e4e8ab016e8d3b2bcf5e29a327053 (diff) | |
Split subtitles at reel boundaries (#1918).
Diffstat (limited to 'src/lib/writer.cc')
| -rw-r--r-- | src/lib/writer.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc index ad588f0a6..4386b8e26 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -545,6 +545,7 @@ Writer::finish (boost::filesystem::path output_dcp) LOG_GENERAL_NC ("Finishing ReelWriters"); for (auto& i: _reels) { + write_hanging_text (i); i.finish (output_dcp); } @@ -798,6 +799,23 @@ Writer::write (PlayerText text, TextType type, optional<DCPTextTrack> track, DCP while ((*reel)->period().to <= period.from) { ++(*reel); DCPOMATIC_ASSERT (*reel != _reels.end()); + write_hanging_text (**reel); + } + + 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. + */ + 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}); + } + } + /* 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()); } (*reel)->write (text, type, track, period); @@ -907,3 +925,17 @@ Writer::calculate_referenced_digests (boost::function<void (float)> set_progress } } + +void +Writer::write_hanging_text (ReelWriter& reel) +{ + vector<HangingText> new_hanging_texts; + for (auto i: _hanging_texts) { + if (i.period.from == reel.period().from) { + reel.write (i.text, i.type, i.track, i.period); + } else { + new_hanging_texts.push_back (i); + } + } + _hanging_texts = new_hanging_texts; +} |
