diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2015-06-07 21:57:44 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-06-07 23:53:37 +0200 |
commit | b694f480fef25e9f795dff1ad614d6a163026ac6 (patch) | |
tree | e43b3998a547a45696cf74e245b995c32706643d | |
parent | 69abb4819414a8f0a4e20812537112d72d9c04fb (diff) | |
download | mpv-b694f480fef25e9f795dff1ad614d6a163026ac6.tar.bz2 mpv-b694f480fef25e9f795dff1ad614d6a163026ac6.tar.xz |
vo: restore frame-drop logic for high-fps clips
Commits 92b27be and f4ce99d removed high-fps logic to to a bug. That bug was
a missing parenthesis around everything after duration >= 0 && ... at the
removed code.
This patch restores the removed code, fixes the bug and then refactors the
code a bit.
-rw-r--r-- | video/out/vo.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 4babfd9c93..3a7f755f3a 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -626,7 +626,29 @@ static bool render_frame(struct vo *vo) if (!in->hasframe_rendered) duration = -1; // disable framedrop + bool prev_dropped_frame = in->dropped_frame; + + // "normal" strict drop threshold. in->dropped_frame = duration >= 0 && end_time < next_vsync; + + // Clip has similar (within ~5%) or lower fps than the display. + if (duration > 0.95 * in->vsync_interval) { + // If the clip and display have similar/identical fps, it's possible that + // due to the very tight timing, we'll drop frames frequently even if on + // average we can keep up - especially if we have timing jitter (inaccurate + // clip timestamps, inaccurate timers, vsync block jitter, etc). + // So we're allowing to be 1 vsync late to prevent these frequent drops. + // However, once we've dropped a frame - "catch up" by using the strict + // threshold - which will typically be dropping 2 frames in a row. + // On low clip fps, we don't drop anyway and this logic doesn't matter. + + // if we dropped previously - "catch up" by keeping the strict threshold. + in->dropped_frame &= prev_dropped_frame; + + // if we haven't dropped - allow 1 frame late (prev_vsync as threshold). + in->dropped_frame |= end_time < prev_vsync; + } + in->dropped_frame &= !(vo->driver->caps & VO_CAP_FRAMEDROP); in->dropped_frame &= (vo->global->opts->frame_dropping & 1); // Even if we're hopelessly behind, rather degrade to 10 FPS playback, |