summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-25 22:11:30 +0100
committerwm4 <wm4@nowhere>2015-11-25 22:11:30 +0100
commit44376d2d9bc36ca7d057e414243fb7de9d4a01cd (patch)
tree781a962d01a81086685b48d722993a0c63a97737 /video
parentb8bcf0f466ac40dbef8c1130e821d00cb0118af2 (diff)
downloadmpv-44376d2d9bc36ca7d057e414243fb7de9d4a01cd.tar.bz2
mpv-44376d2d9bc36ca7d057e414243fb7de9d4a01cd.tar.xz
vo: add new frame drop detection
For the vo-delayed-frame-count property. Slightly less dumb than the previous one (which was removed earlier), but still pretty dumb. But this also seems to be relatively robust, even with strong vsync jittering.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index fd488201ed..3d12e7f3b3 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -143,6 +143,7 @@ struct vo_internal {
int64_t *vsync_samples;
int num_vsync_samples;
int64_t prev_vsync;
+ int64_t base_vsync;
double estimated_vsync_interval;
double estimated_vsync_jitter;
bool expecting_vsync;
@@ -326,6 +327,7 @@ static void reset_vsync_timings(struct vo *vo)
in->prev_vsync = 0;
in->estimated_vsync_interval = 0;
in->estimated_vsync_jitter = -1;
+ in->base_vsync = 0;
in->expecting_vsync = false;
}
@@ -344,6 +346,8 @@ static void update_vsync_timing_after_swap(struct vo *vo)
in->num_vsync_samples -= 1;
MP_TARRAY_INSERT_AT(in, in->vsync_samples, in->num_vsync_samples, 0,
now - in->prev_vsync);
+ if (!in->base_vsync)
+ in->base_vsync = now;
in->prev_vsync = now;
double avg = 0, jitter = 0;
@@ -357,6 +361,17 @@ static void update_vsync_timing_after_swap(struct vo *vo)
in->estimated_vsync_jitter = sqrt(jitter / in->num_vsync_samples);
MP_STATS(vo, "value %f jitter", in->estimated_vsync_jitter);
+
+ if (llabs(in->base_vsync - now) > in->vsync_interval * 2 / 3) {
+ // Assume a drop. An underflow can technically speaking not be a drop
+ // (it's up to the driver what this is supposed to mean), but no reason
+ // to treat it differently.
+ in->base_vsync = now;
+ in->delayed_count += 1;
+ MP_STATS(vo, "vo-delayed");
+ }
+
+ in->base_vsync += in->vsync_interval;
}
// to be called from VO thread only