Setup SubtitleDecoder::_position correctly (in some cases).
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Dec 2017 22:04:49 +0000 (22:04 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 13 Dec 2017 22:04:49 +0000 (22:04 +0000)
src/lib/dcp_decoder.cc
src/lib/dcp_subtitle_decoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/subtitle_decoder.cc
src/lib/subtitle_decoder.h
src/lib/text_subtitle_decoder.cc

index 44053c5dff791b43747d7c2c0dabd6a66d82413b..1a4896fe700f3f09b0eb94f092dd4527def1e814 100644 (file)
@@ -59,7 +59,8 @@ DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, boo
                audio.reset (new AudioDecoder (this, c->audio, log, fast));
        }
        if (c->subtitle) {
-               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log));
+               /* XXX: this time here should be the time of the first subtitle, not 0 */
+               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
        }
 
        shared_ptr<dcp::CPL> cpl;
index 04b264192cd9d43c184449820b9c16213118ed28..965f9db61dc20d9719b16a2a0a2d8ecdc027fa0d 100644 (file)
@@ -30,11 +30,15 @@ using boost::bind;
 
 DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content, shared_ptr<Log> log)
 {
-       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log));
-
        shared_ptr<dcp::SubtitleAsset> c (load (content->path (0)));
        _subtitles = c->subtitles ();
        _next = _subtitles.begin ();
+
+       ContentTime first;
+       if (_next != _subtitles.end()) {
+               first = content_time_period(*_next).from;
+       }
+       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log, first));
 }
 
 void
index 378b59901163339f2a8dbb1175f1847e87b0fb1e..0d6ac383f903c389b3bf1b999590107722210036 100644 (file)
@@ -98,7 +98,8 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log>
        }
 
        if (c->subtitle) {
-               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log));
+               /* XXX: this time here should be the time of the first subtitle, not 0 */
+               subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
        }
 
        _next_time.resize (_format_context->nb_streams);
index 802c9ef84cfaa7578b84a58995819cd9da5cc73b..5838d167be7913c301d7b46369d23555de9b65d7 100644 (file)
@@ -40,10 +40,12 @@ using boost::function;
 SubtitleDecoder::SubtitleDecoder (
        Decoder* parent,
        shared_ptr<const SubtitleContent> c,
-       shared_ptr<Log> log
+       shared_ptr<Log> log,
+       ContentTime first
        )
        : DecoderPart (parent, log)
        , _content (c)
+       , _position (first)
 {
 
 }
index 9740b06e8644f8ed93872eb62884ed6cfa63b1ae..c1f171b1fbb799ebe0a128ff606b1932df5f0e68 100644 (file)
@@ -38,14 +38,11 @@ class Image;
 class SubtitleDecoder : public DecoderPart
 {
 public:
-       /** Second parameter to the _during functions is true if we
-        *  want only subtitles that start during the period,
-        *  otherwise we want subtitles that overlap the period.
-        */
        SubtitleDecoder (
                Decoder* parent,
                boost::shared_ptr<const SubtitleContent>,
-               boost::shared_ptr<Log> log
+               boost::shared_ptr<Log> log,
+               ContentTime first
                );
 
        ContentTime position () const {
index 846c3016ee1748f8c97aa08b27a1232ed3a8ec57..6188d524f97b101344138f83bacfaaa14dacc13b 100644 (file)
@@ -38,7 +38,11 @@ TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent>
        : TextSubtitle (content)
        , _next (0)
 {
-       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log));
+       ContentTime first;
+       if (!_subtitles.empty()) {
+               first = content_time_period(_subtitles[0]).from;
+       }
+       subtitle.reset (new SubtitleDecoder (this, content->subtitle, log, first));
 }
 
 void