Don't disable forensic marking by default.
[dcpomatic.git] / src / lib / player.cc
index 9ee8ab72c986c34370b0822aaea6a2501282f220..0f20dc7ecbd81cf44aa056239de999caca719c83 100644 (file)
@@ -129,19 +129,19 @@ Player::setup_pieces ()
                }
 
                if (decoder->video && _ignore_video) {
-                       decoder->video->set_ignore ();
+                       decoder->video->set_ignore (true);
                }
 
                if (decoder->subtitle && _ignore_subtitle) {
-                       decoder->subtitle->set_ignore ();
+                       decoder->subtitle->set_ignore (true);
                }
 
                shared_ptr<DCPDecoder> dcp = dynamic_pointer_cast<DCPDecoder> (decoder);
-               if (dcp && _play_referenced) {
+               if (dcp) {
+                       dcp->set_decode_referenced (_play_referenced);
                        if (_play_referenced) {
-                               dcp->set_decode_referenced ();
+                               dcp->set_forced_reduction (_dcp_decode_reduction);
                        }
-                       dcp->set_forced_reduction (_dcp_decode_reduction);
                }
 
                shared_ptr<Piece> piece (new Piece (i, decoder, frc));
@@ -658,7 +658,9 @@ Player::subtitles_for_frame (DCPTime time) const
 {
        list<PositionImage> subtitles;
 
-       BOOST_FOREACH (PlayerSubtitles i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, _film->video_frame_rate())),  _always_burn_subtitles)) {
+       int const vfr = _film->video_frame_rate();
+
+       BOOST_FOREACH (PlayerSubtitles i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
 
                /* Image subtitles */
                list<PositionImage> c = transform_image_subtitles (i.image);
@@ -666,7 +668,7 @@ Player::subtitles_for_frame (DCPTime time) const
 
                /* Text subtitles (rendered to an image) */
                if (!i.text.empty ()) {
-                       list<PositionImage> s = render_subtitles (i.text, i.fonts, _video_container_size, time);
+                       list<PositionImage> s = render_subtitles (i.text, i.fonts, _video_container_size, time, vfr);
                        copy (s.begin(), s.end(), back_inserter (subtitles));
                }
        }
@@ -694,15 +696,18 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
        /* Time of the first frame we will emit */
        DCPTime const time = content_video_to_dcp (piece, video.frame);
 
-       /* Discard if it's outside the content's period or if it's before the last accurate seek */
-       if (
-               time < piece->content->position() ||
-               time >= piece->content->end() ||
-               (_last_video_time && time < *_last_video_time)) {
+       /* Discard if it's before the content's period or the last accurate seek.  We can't discard
+          if it's after the content's period here as in that case we still need to fill any gap between
+          `now' and the end of the content's period.
+       */
+       if (time < piece->content->position() || (_last_video_time && time < *_last_video_time)) {
                return;
        }
 
-       /* Fill gaps that we discover now that we have some video which needs to be emitted */
+       /* Fill gaps that we discover now that we have some video which needs to be emitted.
+          This is where we need to fill to.
+       */
+       DCPTime fill_to = min (time, piece->content->end());
 
        if (_last_video_time) {
                DCPTime fill_from = max (*_last_video_time, piece->content->position());
@@ -713,7 +718,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                        if (eyes == EYES_BOTH) {
                                eyes = EYES_LEFT;
                        }
-                       while (j < time || eyes != video.eyes) {
+                       while (j < fill_to || eyes != video.eyes) {
                                if (last != _last_video.end()) {
                                        shared_ptr<PlayerVideo> copy = last->second->shallow_copy();
                                        copy->set_eyes (eyes);
@@ -727,7 +732,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                                eyes = increment_eyes (eyes);
                        }
                } else {
-                       for (DCPTime j = fill_from; j < time; j += one_video_frame()) {
+                       for (DCPTime j = fill_from; j < fill_to; j += one_video_frame()) {
                                if (last != _last_video.end()) {
                                        emit_video (last->second, j);
                                } else {
@@ -754,7 +759,9 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
 
        DCPTime t = time;
        for (int i = 0; i < frc.repeat; ++i) {
-               emit_video (_last_video[wp], t);
+               if (t < piece->content->end()) {
+                       emit_video (_last_video[wp], t);
+               }
                t += one_video_frame ();
        }
 }