From 1fe64c61be426513aff24ea69dfa970939caa8b1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 25 Nov 2015 22:10:55 +0100 Subject: vo_opengl: disable interpolation without display-sync Without display-sync mode, our guesses wrt. vsync phase etc. are much worse, and I see no reason to keep the complicated "vsync_timed" code. --- video/out/opengl/video.c | 6 ++++-- video/out/vo.c | 32 ++++---------------------------- video/out/vo.h | 3 +-- video/out/vo_vdpau.c | 2 +- 4 files changed, 10 insertions(+), 33 deletions(-) (limited to 'video') diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 75e9874724..4c62efe3be 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -2160,7 +2160,9 @@ 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); - if (p->opts.interpolation && (p->frames_drawn || !frame->still)) { + if (p->opts.interpolation && frame->display_synced && + (p->frames_drawn || !frame->still)) + { gl_video_interpolate_frame(p, frame, fbo); } else { bool is_new = !frame->redraw && !frame->repeat; @@ -2872,7 +2874,7 @@ void gl_video_configure_queue(struct gl_video *p, struct vo *vo) } } - vo_set_queue_params(vo, 0, p->opts.interpolation, queue_size); + vo_set_queue_params(vo, 0, queue_size); } struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p) diff --git a/video/out/vo.c b/video/out/vo.c index 883d0e9818..f86cccd3e1 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -135,8 +135,6 @@ struct vo_internal { bool want_redraw; // redraw request from VO to player bool send_reset; // send VOCTRL_RESET bool paused; - bool vsync_timed; // the VO redraws itself as fast as possible - // at every vsync int queued_events; // event mask for the user int internal_events; // event mask for us @@ -586,7 +584,7 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts) if (next_pts > now) r = false; if (!in->wakeup_pts || next_pts < in->wakeup_pts) { - in->wakeup_pts = in->vsync_timed ? 0 : next_pts; + in->wakeup_pts = next_pts; wakeup_locked(vo); } } @@ -605,7 +603,7 @@ void vo_queue_frame(struct vo *vo, struct vo_frame *frame) (!in->current_frame || in->current_frame->num_vsyncs < 1)); in->hasframe = true; in->frame_queued = frame; - in->wakeup_pts = (frame->display_synced || in->vsync_timed) + in->wakeup_pts = frame->display_synced ? 0 : frame->pts + MPMAX(frame->duration, 0); wakeup_locked(vo); pthread_mutex_unlock(&in->lock); @@ -669,7 +667,7 @@ static bool render_frame(struct vo *vo) in->frame_queued = NULL; } else if (in->paused || !in->current_frame || !in->hasframe || (in->current_frame->display_synced && in->current_frame->num_vsyncs < 1) || - (!in->vsync_timed && !in->current_frame->display_synced)) + !in->current_frame->display_synced) { goto done; } @@ -726,25 +724,6 @@ static bool render_frame(struct vo *vo) in->dropped_frame &= mp_time_us() - in->last_flip < 100 * 1000; in->dropped_frame &= in->hasframe_rendered; - if (in->vsync_timed && !frame->display_synced) { - // this is a heuristic that wakes the thread up some - // time before the next vsync - target = next_vsync - MPMIN(in->vsync_interval / 2, 8e3); - - // We are very late with the frame and using vsync timing: probably - // no new frames are coming in. This must be done whether or not - // framedrop is enabled. Also, if the frame is to be dropped, even - // though it's an interpolated frame (repeat set), exit early. - bool late = prev_vsync > pts + duration + in->vsync_interval_approx; - if (frame->repeat && ((in->hasframe_rendered && late) || in->dropped_frame)) - { - in->dropped_frame = false; - goto done; - } - - frame->vsync_offset = next_vsync - pts; - } - // Setup parameters for the next time this frame is drawn. ("frame" is the // frame currently drawn, while in->current_frame is the potentially next.) in->current_frame->repeat = true; @@ -1048,16 +1027,13 @@ const char *vo_get_window_title(struct vo *vo) // flip_page[_timed] will be called offset_us microseconds too early. // (For vo_vdpau, which does its own timing.) -// Setting vsync_timed to true redraws as fast as possible. // num_req_frames set the requested number of requested vo_frame.frames. // (For vo_opengl interpolation.) -void vo_set_queue_params(struct vo *vo, int64_t offset_us, bool vsync_timed, - int num_req_frames) +void vo_set_queue_params(struct vo *vo, int64_t offset_us, int num_req_frames) { struct vo_internal *in = vo->in; pthread_mutex_lock(&in->lock); in->flip_queue_offset = offset_us; - in->vsync_timed = vsync_timed; in->req_frames = MPCLAMP(num_req_frames, 1, VO_MAX_REQ_FRAMES); pthread_mutex_unlock(&in->lock); } diff --git a/video/out/vo.h b/video/out/vo.h index 0f934ebdc4..05c50bb3dd 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -344,8 +344,7 @@ void vo_query_formats(struct vo *vo, uint8_t *list); void vo_event(struct vo *vo, int event); int vo_query_and_reset_events(struct vo *vo, int events); struct mp_image *vo_get_current_frame(struct vo *vo); -void vo_set_queue_params(struct vo *vo, int64_t offset_us, bool vsync_timed, - int num_req_frames); +void vo_set_queue_params(struct vo *vo, int64_t offset_us, int num_req_frames); int vo_get_num_req_frames(struct vo *vo); int64_t vo_get_vsync_interval(struct vo *vo); double vo_get_estimated_vsync_interval(struct vo *vo); diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 72a08adac7..54f95c61e9 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -302,7 +302,7 @@ static void resize(struct vo *vo) vc->flip_offset_us = vo->opts->fullscreen ? 1000LL * vc->flip_offset_fs : 1000LL * vc->flip_offset_window; - vo_set_queue_params(vo, vc->flip_offset_us, false, 1); + vo_set_queue_params(vo, vc->flip_offset_us, 1); if (vc->output_surface_w < vo->dwidth || vc->output_surface_h < vo->dheight) { vc->output_surface_w = s_size(max_w, vc->output_surface_w, vo->dwidth); -- cgit v1.2.3