From 3931544ef33196e1966c416cc0d60d4160cf27fb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 13 Feb 2015 15:22:53 +0100 Subject: vo_opengl: fix smoothmotion coefficient calculation Using prev_pts as the start of the scale was plain wrong. Change it to prev_vsync. --- video/out/gl_video.c | 10 +++------- video/out/vo.c | 1 + video/out/vo.h | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/video/out/gl_video.c b/video/out/gl_video.c index c23e6ac436..1c70d56674 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -1749,15 +1749,11 @@ static void gl_video_interpolate_frame(struct gl_video *p, gl->ActiveTexture(GL_TEXTURE0 + 1); gl->BindTexture(p->gl_target, p->surfaces[p->surface_idx].fbotex.texture); gl->ActiveTexture(GL_TEXTURE0); - MP_DBG(p, "frame ppts: %lld, pts: %lld, vsync: %lld, DIFF: %lld\n", - (long long)prev_pts, (long long)t->pts, - (long long)t->next_vsync, (long long)t->next_vsync - t->pts); if (prev_pts < t->next_vsync && t->pts > t->next_vsync) { - double N = t->next_vsync - prev_pts; - double P = t->pts - prev_pts; - double prev_pts_component = N / P; + double N = t->next_vsync - t->prev_vsync; + double P = t->pts - t->prev_vsync; float ts = p->opts.smoothmotion_threshold; - inter_coeff = 1 - prev_pts_component; + inter_coeff = 1 - (N / P); inter_coeff = inter_coeff < 0.0 + ts ? 0.0 : inter_coeff; inter_coeff = inter_coeff > 1.0 - ts ? 1.0 : inter_coeff; MP_DBG(p, "inter frame ppts: %lld, pts: %lld, " diff --git a/video/out/vo.c b/video/out/vo.c index 10105c35aa..b85b319c3e 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -617,6 +617,7 @@ static bool render_frame(struct vo *vo) struct frame_timing t = (struct frame_timing) { .pts = pts, .next_vsync = next_vsync, + .prev_vsync = prev_vsync, }; vo->driver->draw_image_timed(vo, img, &t); } else { diff --git a/video/out/vo.h b/video/out/vo.h index 9be92ac482..a531744c49 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -155,6 +155,7 @@ struct vo_extra { struct frame_timing { int64_t pts; int64_t next_vsync; + int64_t prev_vsync; }; struct vo_driver { -- cgit v1.2.3