From: Carl Hetherington Date: Tue, 16 Oct 2018 15:02:39 +0000 (+0100) Subject: Collect subtitles at the same time before emitting them from X-Git-Tag: v2.13.62~5 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=c75484af73d38b00a4f27143f8e434b6f25bf355;p=dcpomatic.git Collect subtitles at the same time before emitting them from DCPDecoder. Prevents overlaid text in, for example, lines with partial italic. --- 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 (); + } } }