Skip to content

Commit

Permalink
vo: delay vsync samples by at least 10 refreshes
Browse files Browse the repository at this point in the history
This filters out vastly inaccurate values from presentation feedback
that can happen shortly after restarting playback or seeking.

Makes estimated vsync converge almost instantly instead of waiting
until those outliers are dropped from the past samples.
  • Loading branch information
kasper93 authored and Dudemanguy committed Nov 14, 2023
1 parent 4420dfe commit 39cab76
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion video/out/vo.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ static double vsync_stddef(struct vo *vo, double ref_vsync)
}

#define MAX_VSYNC_SAMPLES 1000
#define DELAY_VSYNC_SAMPLES 10

// Check if we should switch to measured average display FPS if it seems
// "better" then the system-reported one. (Note that small differences are
Expand Down Expand Up @@ -507,7 +508,7 @@ static void update_vsync_timing_after_swap(struct vo *vo,
}

in->num_successive_vsyncs++;
if (in->num_successive_vsyncs <= vo->opts->swapchain_depth)
if (in->num_successive_vsyncs <= DELAY_VSYNC_SAMPLES)
return;

if (vsync_time <= 0 || vsync_time <= prev_vsync) {
Expand Down

0 comments on commit 39cab76

Please sign in to comment.