/* 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))
);
}
}
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)
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;