From 4a1657da01da373332f484d26441835975bb4e4b Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 20 Jul 2015 21:12:46 +0200 Subject: vo: minor simplification for queue size handling Instead of calling it "future frames" and adding or subtracting 1 from it, always call it "requested frames". This simplifies it a bit. MPContext.next_frames had 2 added to it; this was mainly to ensure a minimum size of 2. Drop it and assume VO_MAX_REQ_FRAMES is at least 2; together with the other changes, this can be the exact size of the array. --- video/out/gl_video.c | 6 +++--- video/out/vo.c | 13 ++++++------- video/out/vo.h | 8 ++++---- video/out/vo_vdpau.c | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) (limited to 'video/out') diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 8f46daa8d6..00c5038362 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -2832,7 +2832,7 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts) void gl_video_configure_queue(struct gl_video *p, struct vo *vo) { - int queue_size = 0; + int queue_size = 1; // Figure out an adequate size for the interpolation queue. The larger // the radius, the earlier we need to queue frames. @@ -2842,10 +2842,10 @@ void gl_video_configure_queue(struct gl_video *p, struct vo *vo) if (kernel) { double radius = kernel->f.radius; radius = radius > 0 ? radius : p->opts.scaler[3].radius; - queue_size = 1 + ceil(radius); + queue_size += 1 + ceil(radius); } else { // Oversample case - queue_size = 2; + queue_size += 2; } } diff --git a/video/out/vo.c b/video/out/vo.c index 1db8fa3490..e538860452 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -959,25 +959,24 @@ 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_future_frames set the requested number of future frames in -// struct frame_timing. -// (For vo_opengl smoothmotion.) +// 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_future_frames) + 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 = 1 + MPMIN(num_future_frames, VO_MAX_FUTURE_FRAMES); + in->req_frames = MPCLAMP(num_req_frames, 1, VO_MAX_REQ_FRAMES); pthread_mutex_unlock(&in->lock); } -int vo_get_num_future_frames(struct vo *vo) +int vo_get_num_req_frames(struct vo *vo) { struct vo_internal *in = vo->in; pthread_mutex_lock(&in->lock); - int res = in->req_frames - 1; + int res = in->req_frames; pthread_mutex_unlock(&in->lock); return res; } diff --git a/video/out/vo.h b/video/out/vo.h index f264694c08..06a923bf41 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -140,7 +140,7 @@ struct voctrl_get_equalizer_args { // VO does framedrop itself (vo_vdpau). Untimed/encoding VOs never drop. #define VO_CAP_FRAMEDROP 2 -#define VO_MAX_FUTURE_FRAMES 10 +#define VO_MAX_REQ_FRAMES 10 struct vo; struct osd_state; @@ -185,7 +185,7 @@ struct vo_frame { // Note that some future frames may never be sent as current frame to the // VO if frames are dropped. int num_frames; - struct mp_image *frames[VO_MAX_FUTURE_FRAMES + 1]; + struct mp_image *frames[VO_MAX_REQ_FRAMES]; }; struct vo_driver { @@ -338,8 +338,8 @@ 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_future_frames); -int vo_get_num_future_frames(struct vo *vo); + 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_display_fps(struct vo *vo); diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index a75557db0c..7e7771f209 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -301,7 +301,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, 0); + vo_set_queue_params(vo, vc->flip_offset_us, false, 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