Backport of c75484af73d38b00a4f27143f8e434b6f25bf355 from master; fix for overlaid...
authorCarl Hetherington <cth@carlh.net>
Sat, 1 Dec 2018 23:20:47 +0000 (23:20 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 3 Dec 2018 00:24:04 +0000 (00:24 +0000)
src/lib/dcp_decoder.cc
test/data

index 0250fa9fef31a7a73fd969c9c0a6afd59f236de1..ad5beeba822a7d3299617f23b40e3528d71b6b85 100644 (file)
@@ -194,16 +194,34 @@ DCPDecoder::pass_subtitles (ContentTime next)
                        true
                        );
 
+               list<dcp::SubtitleString> strings;
+
                BOOST_FOREACH (dcp::SubtitleString i, subs) {
-                       list<dcp::SubtitleString> 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 ();
                }
        }
 }
index e5472ceee4b68737cdf10157c6a5d2018c98e66d..8e5bb30bd87cc81d55da1653301c9b338a54622a 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit e5472ceee4b68737cdf10157c6a5d2018c98e66d
+Subproject commit 8e5bb30bd87cc81d55da1653301c9b338a54622a