From 438aa086ba4c0be8f464ac903d23bcd0efff786b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 1 Dec 2018 23:20:47 +0000 Subject: [PATCH] Backport of c75484af73d38b00a4f27143f8e434b6f25bf355 from master; fix for overlaid in partially-marked-up subtitle lines. --- src/lib/dcp_decoder.cc | 28 +++++++++++++++++++++++----- test/data | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 0250fa9fe..ad5beeba8 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -194,16 +194,34 @@ DCPDecoder::pass_subtitles (ContentTime next) true ); + list strings; + BOOST_FOREACH (dcp::SubtitleString i, subs) { - list s; - s.push_back (i); + if (!strings.empty() && (strings.back().in() != i.in() || strings.back().out() != i.out())) { + dcp::SubtitleString b = strings.back(); + subtitle->emit_text ( + ContentTimePeriod ( + ContentTime::from_frames(_offset - entry_point, vfr) + ContentTime::from_seconds(b.in().as_seconds()), + ContentTime::from_frames(_offset - entry_point, vfr) + ContentTime::from_seconds(b.out().as_seconds()) + ), + strings + ); + strings.clear (); + } + + strings.push_back (i); + } + + if (!strings.empty()) { + dcp::SubtitleString b = strings.back(); subtitle->emit_text ( ContentTimePeriod ( - ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i.in().as_seconds ()), - ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i.out().as_seconds ()) + ContentTime::from_frames(_offset - entry_point, vfr) + ContentTime::from_seconds(b.in().as_seconds()), + ContentTime::from_frames(_offset - entry_point, vfr) + ContentTime::from_seconds(b.out().as_seconds()) ), - s + strings ); + strings.clear (); } } } diff --git a/test/data b/test/data index e5472ceee..8e5bb30bd 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit e5472ceee4b68737cdf10157c6a5d2018c98e66d +Subproject commit 8e5bb30bd87cc81d55da1653301c9b338a54622a -- 2.30.2