From d38bc531cc7ce9c90b74145e2be2e24cb48e501a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 9 Dec 2014 17:46:35 +0100 Subject: vo: include normal render-ahead time in flip_queue_offset A small refactor; shouldn't change any behavior. Do this so immediate display can be achieved. --- video/out/vo.c | 5 +++-- video/out/vo.h | 2 ++ video/out/vo_vdpau.c | 15 ++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/video/out/vo.c b/video/out/vo.c index 7e2bcfb83e..518841007f 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -228,6 +228,7 @@ static struct vo *vo_create(struct mpv_global *global, talloc_steal(vo, log); *vo->in = (struct vo_internal) { .dispatch = mp_dispatch_create(vo), + .flip_queue_offset = VO_DEFAULT_FLIP_QUEUE_OFFSET, }; mp_make_wakeup_pipe(vo->in->wakeup_pipe); mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo); @@ -481,8 +482,8 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts) if (r) { // Don't show the frame too early - it would basically freeze the // display by disallowing OSD redrawing or VO interaction. - // Actually render the frame at earliest 50ms before target time. - next_pts -= 0.050 * 1e6; + // Actually render the frame at earliest 50ms before target time + // (flip_queue_offset is usually VO_DEFAULT_FLIP_QUEUE_OFFSET, 50ms). next_pts -= in->flip_queue_offset; int64_t now = mp_time_us(); if (next_pts > now) diff --git a/video/out/vo.h b/video/out/vo.h index a083437397..f54e2c1a55 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -158,6 +158,8 @@ struct voctrl_screenshot_args { // VO does framedrop itself (vo_vdpau). Untimed/encoding VOs never drop. #define VO_CAP_FRAMEDROP 2 +#define VO_DEFAULT_FLIP_QUEUE_OFFSET ((uint64_t)(0.050 * 1e6)) + struct vo; struct osd_state; struct mp_image; diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index aa2cd910a0..c1b63345f1 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -99,7 +99,7 @@ struct vdpctx { int chroma_deint; int flip_offset_window; int flip_offset_fs; - int flip_offset_ms; + int64_t flip_offset_us; bool flip; VdpRect src_rect_vid; @@ -258,11 +258,12 @@ static void resize(struct vo *vo) vc->src_rect_vid.y0 = vc->flip ? src_rect.y1 : src_rect.y0; vc->src_rect_vid.y1 = vc->flip ? src_rect.y0 : src_rect.y1; - vc->flip_offset_ms = vo->opts->fullscreen ? - vc->flip_offset_fs : - vc->flip_offset_window; + vc->flip_offset_us = vo->opts->fullscreen ? + 1000LL * vc->flip_offset_fs : + 1000LL * vc->flip_offset_window; + vc->flip_offset_us += VO_DEFAULT_FLIP_QUEUE_OFFSET; - vo_set_flip_queue_offset(vo, vc->flip_offset_ms * 1000); + vo_set_flip_queue_offset(vo, vc->flip_offset_us); if (vc->output_surface_width < vo->dwidth || vc->output_surface_height < vo->dheight) { @@ -752,11 +753,11 @@ static int flip_page_timed(struct vo *vo, int64_t pts_us, int duration) /* This should normally never happen. * - The last queued frame can't have a PTS that goes more than 50ms in the * future. This is guaranteed by vo.c, which currently actually queues - * ahead by roughly 50ms, plus the flip queue offset. Just to be sure + * ahead by roughly the flip queue offset. Just to be sure * give some additional room by doubling the time. * - The last vsync can never be in the future. */ - int64_t max_pts_ahead = (vc->flip_offset_ms + 50) * 1000 * 1000 * 2; + int64_t max_pts_ahead = vc->flip_offset_us * 1000 * 2; if (vc->last_queue_time > now + max_pts_ahead || vc->recent_vsync_time > now) { -- cgit v1.2.3