Merge master.
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index f97e324bb4bb5d521467c0fcdd8a837e73299f7b..e14d1bd6bf784454639d1e73408c5bf5a7208a68 100644 (file)
@@ -110,7 +110,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, vector<boost::shared_ptr
 
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
-               if (fc->subtitle_use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
+               if (fc->use_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
 
@@ -172,17 +172,12 @@ FFmpegContent::examine (shared_ptr<Job> job)
        shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ()));
        take_from_video_examiner (examiner);
 
-       ContentTime video_length = examiner->video_length ();
-
        shared_ptr<const Film> film = _film.lock ();
        assert (film);
-       LOG_GENERAL ("Video length obtained from header as %1 frames", video_length.frames (video_frame_rate ()));
 
        {
                boost::mutex::scoped_lock lm (_mutex);
 
-               _video_length = video_length;
-
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
                        _subtitle_stream = _subtitle_streams.front ();
@@ -196,7 +191,6 @@ FFmpegContent::examine (shared_ptr<Job> job)
                _first_video = examiner->first_video ();
        }
 
-       signal_changed (ContentProperty::LENGTH);
        signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
        signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
        signal_changed (FFmpegContentProperty::AUDIO_STREAMS);
@@ -397,7 +391,7 @@ FFmpegContent::audio_analysis_path () const
 }
 
 list<ContentTimePeriod>
-FFmpegContent::subtitles_during (ContentTimePeriod period) const
+FFmpegContent::subtitles_during (ContentTimePeriod period, bool starting) const
 {
        list<ContentTimePeriod> d;
        
@@ -408,10 +402,16 @@ FFmpegContent::subtitles_during (ContentTimePeriod period) const
 
        /* XXX: inefficient */
        for (vector<ContentTimePeriod>::const_iterator i = stream->periods.begin(); i != stream->periods.end(); ++i) {
-               if (period.overlaps (*i)) {
+               if ((starting && period.contains (i->from)) || (!starting && period.overlaps (*i))) {
                        d.push_back (*i);
                }
        }
 
        return d;
 }
+
+bool
+FFmpegContent::has_subtitles () const
+{
+       return !subtitle_streams().empty ();
+}