diff options
author | wm4 <wm4@nowhere> | 2016-01-27 21:07:17 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-01-27 21:07:17 +0100 |
commit | 34bead485987b416685e73ca918610fff75d618d (patch) | |
tree | a83b162051ee7c4cbd6cb8ea58ec2e4f3d6aa999 /video/out/opengl | |
parent | 7b6e3772ab7a39fc81e7524540e69eb30c4da7ac (diff) | |
download | mpv-34bead485987b416685e73ca918610fff75d618d.tar.bz2 mpv-34bead485987b416685e73ca918610fff75d618d.tar.xz |
vo_opengl: replace tscale-interpolates-only with interpolation-threshold
The previous approach was too naive, and can e.g. ruin playback if
scheduling switches e.g. between 1 and 2 vsync per frame.
Diffstat (limited to 'video/out/opengl')
-rw-r--r-- | video/out/opengl/video.c | 19 | ||||
-rw-r--r-- | video/out/opengl/video.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index bbf01f2cbb..6945c82f9a 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -354,8 +354,8 @@ const struct gl_video_opts gl_video_opts_def = { .clamp = 1, }, // tscale }, .scaler_resizes_only = 1, - .tscale_interpolates_only = 1, .scaler_lut_size = 6, + .interpolation_threshold = 0.0001, .alpha_mode = 3, .background = {0, 0, 0, 255}, .gamma = 1.0f, @@ -380,8 +380,8 @@ const struct gl_video_opts gl_video_opts_hq_def = { .clamp = 1, }, // tscale }, .scaler_resizes_only = 1, - .tscale_interpolates_only = 1, .scaler_lut_size = 6, + .interpolation_threshold = 0.0001, .alpha_mode = 3, .background = {0, 0, 0, 255}, .gamma = 1.0f, @@ -424,7 +424,6 @@ const struct m_sub_options gl_video_conf = { SCALER_OPTS("tscale", 3), OPT_INTRANGE("scaler-lut-size", scaler_lut_size, 0, 4, 10), OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0), - OPT_FLAG("tscale-interpolates-only", tscale_interpolates_only, 0), OPT_FLAG("linear-scaling", linear_scaling, 0), OPT_FLAG("correct-downscaling", correct_downscaling, 0), OPT_FLAG("sigmoid-upscaling", sigmoid_upscaling, 0), @@ -460,6 +459,7 @@ const struct m_sub_options gl_video_conf = { OPT_FLAG("rectangle-textures", use_rectangle, 0), OPT_COLOR("background", background, 0), OPT_FLAG("interpolation", interpolation, 0), + OPT_FLOAT("interpolation-threshold", interpolation_threshold, 0), OPT_CHOICE("blend-subtitles", blend_subs, 0, ({"no", 0}, {"yes", 1}, @@ -2260,12 +2260,15 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo) if (has_frame) { gl_sc_set_vao(p->sc, &p->vao); - bool same_rate = !(frame->repeat || frame->num_vsyncs > 1); + bool interpolate = p->opts.interpolation && frame->display_synced && + (p->frames_drawn || !frame->still); + if (interpolate) { + double ratio = frame->ideal_frame_duration / frame->vsync_interval; + if (fabs(ratio - 1.0) < p->opts.interpolation_threshold) + interpolate = false; + } - if (p->opts.interpolation && frame->display_synced && - (p->frames_drawn || !frame->still) && - (!same_rate || !p->opts.tscale_interpolates_only)) - { + if (interpolate) { gl_video_interpolate_frame(p, frame, fbo); } else { bool is_new = !frame->redraw && !frame->repeat; diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index ea6981705c..a1918bef39 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -83,7 +83,6 @@ struct gl_video_opts { float sigmoid_center; float sigmoid_slope; int scaler_resizes_only; - int tscale_interpolates_only; int pbo; int dither_depth; int dither_algo; @@ -95,6 +94,7 @@ struct gl_video_opts { int use_rectangle; struct m_color background; int interpolation; + float interpolation_threshold; int blend_subs; char *scale_shader; char **pre_shaders; |