From c75484af73d38b00a4f27143f8e434b6f25bf355 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 Oct 2018 16:02:39 +0100 Subject: [PATCH] Collect subtitles at the same time before emitting them from DCPDecoder. Prevents overlaid text in, for example, lines with partial italic. --- src/lib/dcp_decoder.cc | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 72db5369c..71a7e42d0 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -228,18 +228,24 @@ DCPDecoder::pass_texts (ContentTime next, shared_ptr asset, true ); + list strings; + BOOST_FOREACH (shared_ptr i, subs) { shared_ptr is = dynamic_pointer_cast (i); if (is) { - list s; - s.push_back (*is); - decoder->emit_plain ( - 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 ()) - ), - s - ); + if (!strings.empty() && (strings.back().in() != is->in() || strings.back().out() != is->out())) { + dcp::SubtitleString b = strings.back(); + decoder->emit_plain ( + 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 (*is); } shared_ptr ii = dynamic_pointer_cast (i); @@ -284,6 +290,18 @@ DCPDecoder::pass_texts (ContentTime next, shared_ptr asset, ); } } + + if (!strings.empty()) { + dcp::SubtitleString b = strings.back(); + decoder->emit_plain ( + 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 (); + } } } -- 2.30.2