From 34bead485987b416685e73ca918610fff75d618d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 27 Jan 2016 21:07:17 +0100 Subject: 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. --- video/out/opengl/video.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'video/out/opengl/video.c') 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; -- cgit v1.2.3