diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-12-13 22:04:49 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-12-13 22:04:49 +0000 |
| commit | 6a68937320fa76ce213c648845abc73983fc1849 (patch) | |
| tree | 542a0426b4a0790f28cce34aef43e52b41e896cf | |
| parent | 7b0af48a5861cb58314db46d29b05289979c2c25 (diff) | |
Setup SubtitleDecoder::_position correctly (in some cases).
| -rw-r--r-- | src/lib/dcp_decoder.cc | 3 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.cc | 8 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 3 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 4 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.h | 7 | ||||
| -rw-r--r-- | src/lib/text_subtitle_decoder.cc | 6 |
6 files changed, 20 insertions, 11 deletions
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 44053c5df..1a4896fe7 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -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; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 04b264192..965f9db61 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -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 diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 378b59901..0d6ac383f 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -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); diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 802c9ef84..5838d167b 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -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) { } diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index 9740b06e8..c1f171b1f 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -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 { diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc index 846c3016e..6188d524f 100644 --- a/src/lib/text_subtitle_decoder.cc +++ b/src/lib/text_subtitle_decoder.cc @@ -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 |
