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.
This commit is contained in:
wm4 2014-12-09 17:46:35 +01:00
parent 349d19dda9
commit d38bc531cc
3 changed files with 13 additions and 9 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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)
{