From c8a036eb727ceddc64a0304d781c916eb952c001 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 8 Jun 2022 09:58:16 +0200 Subject: Set up TextDecoder position based on the time that the next thing will be emitted, instead of the time that the last thing was (#2268). This is to avoid problems with the example shown in the test, where just because a subtitle in source A comes before a subtitle in source B, source A is pass()ed next and may then emit a subtitle which should be after the next one in B. --- src/lib/text_decoder.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/lib/text_decoder.cc') diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index e3b7d9958..b1b6cbcc4 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -41,12 +41,10 @@ using namespace dcpomatic; TextDecoder::TextDecoder ( Decoder* parent, - shared_ptr content, - ContentTime first + shared_ptr content ) : DecoderPart (parent) , _content (content) - , _position (first) { } @@ -63,7 +61,7 @@ void TextDecoder::emit_bitmap_start (ContentBitmapText const& bitmap) { BitmapStart (bitmap); - _position = bitmap.from(); + maybe_set_position(bitmap.from()); } @@ -116,7 +114,7 @@ TextDecoder::emit_plain_start (ContentTime from, vector sub } PlainStart(ContentStringText(from, string_texts)); - _position = from; + maybe_set_position(from); } @@ -274,7 +272,7 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & sub_subti } PlainStart(ContentStringText(from, string_texts)); - _position = from; + maybe_set_position(from); } @@ -318,3 +316,13 @@ TextDecoder::seek () { _position = ContentTime (); } + + +void +TextDecoder::maybe_set_position (dcpomatic::ContentTime position) +{ + if (!_position || position > *_position) { + _position = position; + } +} + -- cgit v1.2.3