summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-09-28 13:07:42 -0500
committerDudemanguy <random342@airmail.cc>2023-10-05 22:32:06 +0000
commit07995f5d5fa38f9060c6bbfd0e51bbfc39b3e236 (patch)
treec07087b2daa170fbe160a2a3c53120af42d8211b
parent61aecfabfd854df409f0129f4abbcd3934e92685 (diff)
downloadmpv-07995f5d5fa38f9060c6bbfd0e51bbfc39b3e236.tar.bz2
mpv-07995f5d5fa38f9060c6bbfd0e51bbfc39b3e236.tar.xz
vo_gpu_next: improve updating overlays
fbe154831a8addfc18a4f81e1c4b9284c31acace added a new VOCTRL to signal when the OSD changed for gpu-next's handling of subtitles, but this is both not necessary and actually incomplete. The VOCTRL would signal OSD changes, but not all subtitle changes (like selecting another non-external sub track for example). VOCTRL_OSD_CHANGED was used to increment p->osd_sync which would then redraw the blended subtitles if the player was paused. But there's already a VOCTRL_PAUSE and VOCTRL_RESUME. Plus, the sub_bitmap_list object will have items in it if it changed in any way, so we don't need the VOCTRL_OSD_CHANGED method at all. That can be removed. The check that fp->osd_sync < p->osd_sync stays in place since that's an optimization while the video is playing, but we also check the pause state as well since the VO can know this. If we're paused, then always do update_overlays since core must be signalling a redraw to us if we get a draw_frame call here. Additionally in update_overlays itself, the p->osd_sync counter is incremented if we have any items since the frame signature will need that. As for the actual bug that is fixed, changing subtitle tracks while paused with blended subtitles now correctly works. Previously, it was never updated so the old subtitle stayed there forever until you deselected it (since VOCTRL_OSD_CHANGED triggered there). Also include some cosmetic code fixes that were noticed.
-rw-r--r--player/command.c2
-rw-r--r--video/out/vo.c1
-rw-r--r--video/out/vo.h3
-rw-r--r--video/out/vo_gpu_next.c43
4 files changed, 22 insertions, 27 deletions
diff --git a/player/command.c b/player/command.c
index efb2436194..cf4971a4b3 100644
--- a/player/command.c
+++ b/player/command.c
@@ -6930,8 +6930,6 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
}
}
osd_changed(mpctx->osd);
- if (mpctx->video_out)
- vo_control_async(mpctx->video_out, VOCTRL_OSD_CHANGED, NULL);
if (flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD))
mp_force_video_refresh(mpctx);
mp_wakeup_core(mpctx);
diff --git a/video/out/vo.c b/video/out/vo.c
index 420b5b44c9..7b2e0976fe 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -683,7 +683,6 @@ void vo_control_async(struct vo *vo, int request, void *data)
break;
case VOCTRL_KILL_SCREENSAVER:
case VOCTRL_RESTORE_SCREENSAVER:
- case VOCTRL_OSD_CHANGED:
break;
default:
abort(); // requires explicit support
diff --git a/video/out/vo.h b/video/out/vo.h
index a6c6a3ce6e..e0b24d4cf7 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -72,9 +72,6 @@ enum mp_voctrl {
// you could install your own listener.
VOCTRL_VO_OPTS_CHANGED,
- // Triggered by any change to the OSD (e.g. OSD style changes)
- VOCTRL_OSD_CHANGED,
-
/* private to vo_gpu */
VOCTRL_LOAD_HWDEC_API,
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index 229a268b15..8014f7def1 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -158,6 +158,7 @@ struct priv {
bool is_interpolated;
bool want_reset;
bool frame_pending;
+ bool paused;
pl_options pars;
struct m_config_cache *opts_cache;
@@ -286,6 +287,9 @@ static void update_overlays(struct vo *vo, struct mp_osd_res res,
double pts = src ? src->pts : 0;
struct sub_bitmap_list *subs = osd_render(vo->osd, res, pts, flags, subfmt_all);
+ if (subs->num_items)
+ p->osd_sync++;
+
frame->overlays = state->overlays;
frame->num_overlays = 0;
@@ -1081,10 +1085,8 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
struct mp_image *mpi = image->user_data;
struct frame_priv *fp = mpi->priv;
apply_crop(image, p->src, vo->params->w, vo->params->h);
-
if (opts->blend_subs) {
- if (fp->osd_sync < p->osd_sync) {
- // Only update the overlays if the state has changed
+ if (p->paused || fp->osd_sync < p->osd_sync) {
float rx = pl_rect_w(p->dst) / pl_rect_w(image->crop);
float ry = pl_rect_h(p->dst) / pl_rect_h(image->crop);
struct mp_osd_res res = {
@@ -1403,21 +1405,20 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
const struct gl_video_opts *opts = p->opts_cache->opts;
struct frame_priv *fp = mpi->priv;
if (opts->blend_subs) {
- // Only update the overlays if the state has changed
- float rx = pl_rect_w(dst) / pl_rect_w(image.crop);
- float ry = pl_rect_h(dst) / pl_rect_h(image.crop);
- struct mp_osd_res res = {
- .w = pl_rect_w(dst),
- .h = pl_rect_h(dst),
- .ml = -image.crop.x0 * rx,
- .mr = (image.crop.x1 - vo->params->w) * rx,
- .mt = -image.crop.y0 * ry,
- .mb = (image.crop.y1 - vo->params->h) * ry,
- .display_par = 1.0,
- };
- update_overlays(vo, res, osd_flags,
- PL_OVERLAY_COORDS_DST_CROP,
- &fp->subs, &image, mpi);
+ float rx = pl_rect_w(dst) / pl_rect_w(image.crop);
+ float ry = pl_rect_h(dst) / pl_rect_h(image.crop);
+ struct mp_osd_res res = {
+ .w = pl_rect_w(dst),
+ .h = pl_rect_h(dst),
+ .ml = -image.crop.x0 * rx,
+ .mr = (image.crop.x1 - vo->params->w) * rx,
+ .mt = -image.crop.y0 * ry,
+ .mb = (image.crop.y1 - vo->params->h) * ry,
+ .display_par = 1.0,
+ };
+ update_overlays(vo, res, osd_flags,
+ PL_OVERLAY_COORDS_DST_CROP,
+ &fp->subs, &image, mpi);
} else {
// Disable overlays when blend_subs is disabled
update_overlays(vo, osd, osd_flags, PL_OVERLAY_COORDS_DST_FRAME,
@@ -1489,12 +1490,12 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_TRUE;
case VOCTRL_SET_EQUALIZER:
case VOCTRL_PAUSE:
+ p->paused = true;
if (p->is_interpolated)
vo->want_redraw = true;
return VO_TRUE;
-
- case VOCTRL_OSD_CHANGED:
- p->osd_sync++;
+ case VOCTRL_RESUME:
+ p->paused = false;
return VO_TRUE;
case VOCTRL_UPDATE_RENDER_OPTS: {