diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 00c7663e91..e7398e50ba 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -1859,8 +1859,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, // Blend the frames together if (oversample) { - double vsync_dist = (t->next_vsync - t->prev_vsync)/1e6 - / (pts_nxt - pts_now), + double vsync_dist = t->vsync_interval / 1e6 / (pts_nxt - pts_now), threshold = tscale->conf.kernel.params[0]; threshold = isnan(threshold) ? 0.0 : threshold; mix = (1 - mix) / vsync_dist; @@ -1884,7 +1883,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, MP_STATS(p, "frame-mix"); MP_DBG(p, "inter frame pts: %lld, vsync: %lld, mix: %f\n", - (long long)t->pts, (long long)t->next_vsync, mix); + (long long)t->pts, (long long)t->vsync_interval, mix); p->is_interpolated = true; } pass_draw_to_screen(p, fbo); diff --git a/video/out/vo.c b/video/out/vo.c index 46958e7f62..35c583b35f 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -640,8 +640,7 @@ static bool render_frame(struct vo *vo) int64_t prev_vsync = prev_sync(vo, mp_time_us()); int64_t next_vsync = prev_vsync + in->vsync_interval; - frame->next_vsync = next_vsync; - frame->prev_vsync = prev_vsync; + frame->vsync_interval = in->vsync_interval; // Time at which we should flip_page on the VO. int64_t target = frame->display_synced ? 0 : pts - in->flip_queue_offset; diff --git a/video/out/vo.h b/video/out/vo.h index cc280987a5..213b287ab2 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -157,9 +157,8 @@ struct vo_frame { int64_t pts; // Approximate frame duration, in us. int duration; - // Realtime of estimated previous and next vsync events. - int64_t next_vsync; - int64_t prev_vsync; + // Realtime of estimated distance between 2 vsync events. + int64_t vsync_interval; // "ideal" display time within the vsync int64_t vsync_offset; // how often the frame will be repeated (does not include OSD redraws) diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 2be18bb7d7..179fbce684 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -81,7 +81,6 @@ struct mpv_opengl_cb_context { bool eq_changed; struct mp_csp_equalizer eq; int64_t recent_flip; - int64_t approx_vsync; bool frozen; // libmpv user is not redrawing frames struct vo *active; int hwdec_api; @@ -284,16 +283,6 @@ int mpv_opengl_cb_uninit_gl(struct mpv_opengl_cb_context *ctx) return 0; } -// needs lock -static int64_t prev_sync(mpv_opengl_cb_context *ctx, int64_t ts) -{ - int64_t diff = (int64_t)(ts - ctx->recent_flip); - int64_t offset = diff % ctx->approx_vsync; - if (offset < 0) - offset += ctx->approx_vsync; - return ts - offset; -} - int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h) { assert(ctx->renderer); @@ -370,11 +359,6 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h) if (!frame) frame = &dummy; - if (ctx->approx_vsync > 0) { - frame->prev_vsync = prev_sync(ctx, mp_time_us()); - frame->next_vsync = frame->prev_vsync + ctx->approx_vsync; - } - pthread_mutex_unlock(&ctx->lock); gl_video_render_frame(ctx->renderer, frame, fbo); @@ -396,10 +380,7 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h) int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time) { pthread_mutex_lock(&ctx->lock); - int64_t next = time > 0 ? time : mp_time_us(); - if (ctx->recent_flip) - ctx->approx_vsync = next - ctx->recent_flip; - ctx->recent_flip = next; + ctx->recent_flip = time > 0 ? time : mp_time_us(); pthread_mutex_unlock(&ctx->lock); return 0;