summaryrefslogtreecommitdiff
path: root/src/lib/text_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-08 09:58:16 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-12 15:40:33 +0200
commitc8a036eb727ceddc64a0304d781c916eb952c001 (patch)
tree86154aac21fd268af47bead23d0077c36d9e5f72 /src/lib/text_decoder.cc
parent922dc3605c29bd742a18b02fbe1faae5739b70df (diff)
Set up TextDecoder position based on the time that the next thing willv2.16.14
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.
Diffstat (limited to 'src/lib/text_decoder.cc')
-rw-r--r--src/lib/text_decoder.cc20
1 files changed, 14 insertions, 6 deletions
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<const TextContent> content,
- ContentTime first
+ shared_ptr<const TextContent> 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<dcp::SubtitleString> 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;
+ }
+}
+