Fix failure to fill FFmpeg gaps at the start of films.
authorCarl Hetherington <cth@carlh.net>
Tue, 16 May 2017 10:25:45 +0000 (11:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 May 2017 10:25:45 +0000 (11:25 +0100)
src/lib/player.cc
test/ffmpeg_decoder_sequential_test.cc

index 2fc062bb513baf1d8c7ea2a0ae7a2145c079ee0c..ad21bb9f151ad9a5e39055a3e2a1e16fb795bc0f 100644 (file)
@@ -670,9 +670,16 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
           as in the problematic case we are about to emit a frame which is not contiguous with the previous.
        */
 
+       optional<DCPTime> fill_to;
        if (_last_video_time) {
+               fill_to = _last_video_time;
+       } else if (_last_seek_time && _last_seek_accurate) {
+               fill_to = _last_seek_time;
+       }
+
+       if (fill_to) {
                /* XXX: this may not work for 3D */
-               BOOST_FOREACH (DCPTimePeriod i, subtract(DCPTimePeriod (*_last_video_time, time), _no_video)) {
+               BOOST_FOREACH (DCPTimePeriod i, subtract(DCPTimePeriod (*fill_to, time), _no_video)) {
                        for (DCPTime j = i.from; j < i.to; j += one_video_frame()) {
                                if (_last_video) {
                                        emit_video (shared_ptr<PlayerVideo> (new PlayerVideo (*_last_video)), j);
index 6bda8f2601084bdcecb987a098e2d9c5ba80f954..67a82541894923e5010ff44e78ec0b441ce14fb7 100644 (file)
@@ -50,7 +50,7 @@ static DCPTime frame;
 static void
 check (shared_ptr<PlayerVideo>, DCPTime time)
 {
-       BOOST_CHECK (time == next);
+       BOOST_REQUIRE (time == next);
        next += frame;
 }
 
@@ -76,12 +76,12 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int
        next = DCPTime ();
        frame = DCPTime::from_frames (1, film->video_frame_rate ());
        while (!player->pass()) {}
-       BOOST_CHECK (next == DCPTime::from_frames (video_length, film->video_frame_rate()));
+       BOOST_REQUIRE (next == DCPTime::from_frames (video_length, film->video_frame_rate()));
 }
 
 BOOST_AUTO_TEST_CASE (ffmpeg_decoder_sequential_test)
 {
-       ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6911);
+       ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6912);
        ffmpeg_decoder_sequential_test_one ("Sintel_Trailer1.480p.DivX_Plus_HD.mkv", 24, 1253);
        ffmpeg_decoder_sequential_test_one ("prophet_clip.mkv", 23.976, 2879);
 }