From f0957fd41d1915b8046dc0c2aeb662e1e8c288c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 10 Jan 2019 22:06:29 +0000 Subject: [PATCH] Only fill video gaps if they are at least half a frame in length. Fixes lack of image (sometimes) when trimming drop-frame content. --- src/lib/dcpomatic_time.h | 4 +++ src/lib/player.cc | 68 +++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index c687569ec..a09dd93e9 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -113,6 +113,10 @@ public: return *this; } + Time operator/ (int o) const { + return Time (_t / o); + } + /** Round up to the nearest sampling interval * at some sampling rate. * @param r Sampling rate. diff --git a/src/lib/player.cc b/src/lib/player.cc index f80adcbf4..7156e3122 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -756,40 +756,44 @@ Player::video (weak_ptr 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 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 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); + } } } } -- 2.30.2