diff options
author | wm4 <wm4@nowhere> | 2020-05-23 03:48:51 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-23 03:48:51 +0200 |
commit | 1826e69af215175ff602e01e76998db3759fc3ab (patch) | |
tree | 1fe40ec633e0f386031c739560990c9ee5bfce41 /player | |
parent | d62131d3aeda6f3b4c255ca06e70573433a8f16a (diff) | |
download | mpv-1826e69af215175ff602e01e76998db3759fc3ab.tar.bz2 mpv-1826e69af215175ff602e01e76998db3759fc3ab.tar.xz |
options: add option to control display-sync factor
Can be useful to force it to adapt to extreme speed changes, while a
higher limit would just use a fraction closer to the original video
speed.
Probably useful for testing only.
Diffstat (limited to 'player')
-rw-r--r-- | player/video.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/player/video.c b/player/video.c index 630cdeffe4..5102ddf656 100644 --- a/player/video.c +++ b/player/video.c @@ -659,12 +659,12 @@ double calc_average_frame_duration(struct MPContext *mpctx) // effective video FPS. If this is not possible, try to do it for multiples, // which still leads to an improved end result. // Both parameters are durations in seconds. -static double calc_best_speed(double vsync, double frame) +static double calc_best_speed(double vsync, double frame, int max_factor) { double ratio = frame / vsync; double best_scale = -1; double best_dev = INFINITY; - for (int factor = 1; factor <= 5; factor++) { + for (int factor = 1; factor <= max_factor; factor++) { double scale = ratio * factor / rint(ratio * factor); double dev = fabs(scale - 1); if (dev < best_dev) { @@ -683,7 +683,8 @@ static double find_best_speed(struct MPContext *mpctx, double vsync) double dur = mpctx->past_frames[n].approx_duration; if (dur <= 0) continue; - total += calc_best_speed(vsync, dur / mpctx->opts->playback_speed); + total += calc_best_speed(vsync, dur / mpctx->opts->playback_speed, + mpctx->opts->sync_max_factor); num++; } return num > 0 ? total / num : 1; |