Only fill video gaps if they are at least half a frame in length.
authorCarl Hetherington <cth@carlh.net>
Thu, 10 Jan 2019 22:06:29 +0000 (22:06 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 10 Jan 2019 22:06:29 +0000 (22:06 +0000)
Fixes lack of image (sometimes) when trimming drop-frame content.

src/lib/dcpomatic_time.h
src/lib/player.cc

index c687569ecb0dac578809d0ae9294ccaf607960ad..a09dd93e9c179f515b08bfd093f8aaada36f2937 100644 (file)
@@ -113,6 +113,10 @@ public:
                return *this;
        }
 
+       Time<S, O> operator/ (int o) const {
+               return Time<S, O> (_t / o);
+       }
+
        /** Round up to the nearest sampling interval
         *  at some sampling rate.
         *  @param r Sampling rate.
index f80adcbf4581731ae0f675e57b7dbd10dad97b7d..7156e31228eb17fb369356f41d070e1656ae18e5 100644 (file)
@@ -756,40 +756,44 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
 
        if (_last_video_time) {
                DCPTime fill_from = max (*_last_video_time, piece->content->position());
-               LastVideoMap::const_iterator last = _last_video.find (wp);
-               if (_film->three_d()) {
-                       Eyes fill_to_eyes = video.eyes;
-                       if (fill_to_eyes == EYES_BOTH) {
-                               fill_to_eyes = EYES_LEFT;
-                       }
-                       if (fill_to == piece->content->end(_film)) {
-                               /* Don't fill after the end of the content */
-                               fill_to_eyes = EYES_LEFT;
-                       }
-                       DCPTime j = fill_from;
-                       Eyes eyes = _last_video_eyes.get_value_or(EYES_LEFT);
-                       if (eyes == EYES_BOTH) {
-                               eyes = EYES_LEFT;
-                       }
-                       while (j < fill_to || eyes != fill_to_eyes) {
-                               if (last != _last_video.end()) {
-                                       shared_ptr<PlayerVideo> copy = last->second->shallow_copy();
-                                       copy->set_eyes (eyes);
-                                       emit_video (copy, j);
-                               } else {
-                                       emit_video (black_player_video_frame(eyes), j);
+
+               /* Fill if we have more than half a frame to do */
+               if ((fill_to - fill_from) > one_video_frame() / 2) {
+                       LastVideoMap::const_iterator last = _last_video.find (wp);
+                       if (_film->three_d()) {
+                               Eyes fill_to_eyes = video.eyes;
+                               if (fill_to_eyes == EYES_BOTH) {
+                                       fill_to_eyes = EYES_LEFT;
                                }
-                               if (eyes == EYES_RIGHT) {
-                                       j += one_video_frame();
+                               if (fill_to == piece->content->end(_film)) {
+                                       /* Don't fill after the end of the content */
+                                       fill_to_eyes = EYES_LEFT;
                                }
-                               eyes = increment_eyes (eyes);
-                       }
-               } else {
-                       for (DCPTime j = fill_from; j < fill_to; j += one_video_frame()) {
-                               if (last != _last_video.end()) {
-                                       emit_video (last->second, j);
-                               } else {
-                                       emit_video (black_player_video_frame(EYES_BOTH), j);
+                               DCPTime j = fill_from;
+                               Eyes eyes = _last_video_eyes.get_value_or(EYES_LEFT);
+                               if (eyes == EYES_BOTH) {
+                                       eyes = EYES_LEFT;
+                               }
+                               while (j < fill_to || eyes != fill_to_eyes) {
+                                       if (last != _last_video.end()) {
+                                               shared_ptr<PlayerVideo> copy = last->second->shallow_copy();
+                                               copy->set_eyes (eyes);
+                                               emit_video (copy, j);
+                                       } else {
+                                               emit_video (black_player_video_frame(eyes), j);
+                                       }
+                                       if (eyes == EYES_RIGHT) {
+                                               j += one_video_frame();
+                                       }
+                                       eyes = increment_eyes (eyes);
+                               }
+                       } else {
+                               for (DCPTime j = fill_from; j < fill_to; j += one_video_frame()) {
+                                       if (last != _last_video.end()) {
+                                               emit_video (last->second, j);
+                                       } else {
+                                               emit_video (black_player_video_frame(EYES_BOTH), j);
+                                       }
                                }
                        }
                }