From 8798cec7fa14bbeb35c7b711db3a41d336f78a69 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 6 Mar 2025 10:11:36 -0600 Subject: [PATCH] vo: replace driver->untimed with VO_CAP_UNTIMED There's a weird mix and match of ways to set special things about a VO so let's consolidate it all to use VO_CAP bits. More importantly this fixes do_redraw not being properly ignored/skipped in the untimed VO case. This was intended in 8657b8e1f3c247dcba441a4c61e3beef2acc2cd4 but later the code got reorganized/moved around to make it no longer a no-op but we just got lucky and there were not any known problems with the broken logic until 5338f4ba70903e7517bbfc7881e10ff13a912ffc. --- player/video.c | 7 ++++--- video/out/vo.c | 7 +++---- video/out/vo.h | 5 ++--- video/out/vo_image.c | 2 +- video/out/vo_lavc.c | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/player/video.c b/player/video.c index ff086db272..bec2d68dff 100644 --- a/player/video.c +++ b/player/video.c @@ -410,7 +410,7 @@ static bool use_video_lookahead(struct MPContext *mpctx) { return mpctx->video_out && !(mpctx->video_out->driver->caps & VO_CAP_NORETAIN) && - !(mpctx->opts->untimed || mpctx->video_out->driver->untimed) && + !(mpctx->opts->untimed || (mpctx->video_out->driver->caps & VO_CAP_UNTIMED)) && !mpctx->opts->video_latency_hacks; } @@ -627,7 +627,8 @@ static void update_avsync_before_frame(struct MPContext *mpctx) * If untimed is set always output frames immediately * without sleeping. */ - if (mpctx->time_frame < -0.2 || opts->untimed || vo->driver->untimed) + if (mpctx->time_frame < -0.2 || opts->untimed || + (vo->driver->caps & VO_CAP_UNTIMED)) mpctx->time_frame = 0; } } @@ -1247,7 +1248,7 @@ void write_video(struct MPContext *mpctx) struct vo_frame *frame = vo_frame_ref(&dummy); double diff = mpctx->past_frames[0].approx_duration; - if (opts->untimed || vo->driver->untimed) + if (opts->untimed || (vo->driver->caps & VO_CAP_UNTIMED)) diff = -1; // disable frame dropping and aspects of frame timing if (diff >= 0) { diff /= mpctx->video_speed; diff --git a/video/out/vo.c b/video/out/vo.c index 997e734065..2b1b06c84c 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -1076,15 +1076,14 @@ static void do_redraw(struct vo *vo) { struct vo_internal *in = vo->in; - if (!vo->config_ok || (vo->driver->caps & VO_CAP_NORETAIN)) + if (!vo->config_ok || (vo->driver->caps & VO_CAP_NORETAIN) || + (vo->driver->caps & VO_CAP_UNTIMED)) return; mp_mutex_lock(&in->lock); in->request_redraw = false; bool full_redraw = in->dropped_frame; - struct vo_frame *frame = NULL; - if (!vo->driver->untimed) - frame = vo_frame_ref(in->current_frame); + struct vo_frame *frame = vo_frame_ref(in->current_frame); if (frame) in->dropped_frame = false; struct vo_frame dummy = {0}; diff --git a/video/out/vo.h b/video/out/vo.h index 0e414459ad..e91a10e564 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -202,6 +202,8 @@ enum { VO_CAP_NORETAIN = 1 << 2, // VO supports applying film grain VO_CAP_FILM_GRAIN = 1 << 3, + // VO is drawn untimed and is never redrawn + VO_CAP_UNTIMED = 1 << 4, }; enum { @@ -324,9 +326,6 @@ struct vo_driver { // VO_CAP_* bits int caps; - // Disable video timing, push frames as quickly as possible, never redraw. - bool untimed; - // The VO is responsible for freeing frames. bool frame_owner; diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 88c966057f..f1fbb26c24 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -158,7 +158,7 @@ const struct vo_driver video_out_image = { .description = "Write video frames to image files", .name = "image", - .untimed = true, + .caps = VO_CAP_UNTIMED, .priv_size = sizeof(struct priv), .preinit = preinit, .query_format = query_format, diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index 839c9f7db4..d67ebfb9e3 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -259,8 +259,8 @@ const struct vo_driver video_out_lavc = { .encode = true, .description = "video encoding using libavcodec", .name = "lavc", + .caps = VO_CAP_UNTIMED, .initially_blocked = true, - .untimed = true, .priv_size = sizeof(struct priv), .preinit = preinit, .query_format = query_format,