diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-11-23 09:54:16 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-11-23 09:54:16 +0000 |
| commit | cd32ade6c276b9163a8aa889a9d81ead6ddb59d6 (patch) | |
| tree | 63af1edfaa43524129909e3eeaeec2aa2e1dec9d /src/lib | |
| parent | 827e9dac612368b0268f973ac59520b33c4f880f (diff) | |
Fix hanging subtitles after recent changes to subtitle examination.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_examiner.cc | 17 | ||||
| -rw-r--r-- | src/lib/ffmpeg_subtitle_stream.cc | 17 | ||||
| -rw-r--r-- | src/lib/ffmpeg_subtitle_stream.h | 1 |
3 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 271180d5d..eb02ba17b 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -160,21 +160,10 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo /* Finish off any hanging subtitles at the end */ for (LastSubtitleMap::const_iterator i = _last_subtitle_start.begin(); i != _last_subtitle_start.end(); ++i) { if (i->second) { - if (i->second->image) { - i->first->add_image_subtitle ( + if (i->first->unknown_to (i->second->id)) { + i->first->set_subtitle_to ( i->second->id, - ContentTimePeriod ( - i->second->time, - ContentTime::from_frames (video_length(), video_frame_rate().get_value_or (24)) - ) - ); - } else { - i->first->add_text_subtitle ( - i->second->id, - ContentTimePeriod ( - i->second->time, - ContentTime::from_frames (video_length(), video_frame_rate().get_value_or (24)) - ) + ContentTime::from_frames (video_length(), video_frame_rate().get_value_or (24)) ); } } diff --git a/src/lib/ffmpeg_subtitle_stream.cc b/src/lib/ffmpeg_subtitle_stream.cc index 57c54e1ea..d389714e9 100644 --- a/src/lib/ffmpeg_subtitle_stream.cc +++ b/src/lib/ffmpeg_subtitle_stream.cc @@ -181,6 +181,23 @@ FFmpegSubtitleStream::find_subtitle_to (string id) const return i->second.to; } +/** @param id Subtitle id. + * @return true if the `from' and `to' times for this id are equal, which indicates + * that the `to' time is unknown. + */ +bool +FFmpegSubtitleStream::unknown_to (string id) const +{ + PeriodMap::const_iterator i = _image_subtitles.find (id); + if (i != _image_subtitles.end ()) { + return i->second.from == i->second.to; + } + + i = _text_subtitles.find (id); + DCPOMATIC_ASSERT (i != _text_subtitles.end ()); + return i->second.from == i->second.to; +} + /** Add some offset to all the times in the stream */ void FFmpegSubtitleStream::add_offset (ContentTime offset) diff --git a/src/lib/ffmpeg_subtitle_stream.h b/src/lib/ffmpeg_subtitle_stream.h index 33247558f..7c4f8cd39 100644 --- a/src/lib/ffmpeg_subtitle_stream.h +++ b/src/lib/ffmpeg_subtitle_stream.h @@ -37,6 +37,7 @@ public: void add_image_subtitle (std::string id, ContentTimePeriod period); void add_text_subtitle (std::string id, ContentTimePeriod period); void set_subtitle_to (std::string id, ContentTime to); + bool unknown_to (std::string id) const; std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod period, bool starting) const; std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod period, bool starting) const; ContentTime find_subtitle_to (std::string id) const; |
