Skip to content

Commit ef666af

Browse files
committed
vo: don't update zoom and pan while changing file
When the current playlist entry changes, or when quitting, and file-local options values are reset, the VO re-renders the current file with the new option values before rendering the next file, if any, causing flicker. Fix this by not making VO drivers resize while changing file until the next frame arrives. Manually sending VOCTRL_SET_PANSCAN for the new file is only necessary when navigating between images with the same dimensions, else VOs resize automatically on reconfig. The VO can still re-render while changing file to print new OSD messages, only resizing and panning the image is delayed. Fixes #7293 Fixes #7675 Fixes Dudemanguy/mpv-manga-reader#12
1 parent a11e486 commit ef666af

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

player/loadfile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,8 +1991,11 @@ static void play_current_file(struct MPContext *mpctx)
19911991
current && current->reloading;
19921992
if (current)
19931993
current->reloading = false;
1994-
if (!reloading)
1994+
if (!reloading) {
1995+
if (mpctx->video_out)
1996+
vo_set_changing_file(mpctx->video_out);
19951997
m_config_restore_backups(mpctx->mconfig);
1998+
}
19961999

19972000
TA_FREEP(&mpctx->filter_root);
19982001
talloc_free(mpctx->filtered_tags);

video/out/vo.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct vo_internal {
139139
bool paused;
140140
bool visible;
141141
bool wakeup_on_done;
142+
bool changing_file;
142143
int queued_events; // event mask for the user
143144
int internal_events; // event mask for us
144145

@@ -237,12 +238,25 @@ static void read_opts(struct vo *vo)
237238
static void update_opts(void *p)
238239
{
239240
struct vo *vo = p;
241+
struct vo_internal *in = vo->in;
240242

241243
if (m_config_cache_update(vo->opts_cache)) {
242244
read_opts(vo);
243245
vo->driver->control(vo, VOCTRL_VO_OPTS_CHANGED, NULL);
244-
// "Legacy" update of video position related options.
245-
// Unlike VOCTRL_VO_OPTS_CHANGED, often not propagated to backends.
246+
if (!in->changing_file) {
247+
// "Legacy" update of video position related options.
248+
// Unlike VOCTRL_VO_OPTS_CHANGED, often not propagated to backends.
249+
vo->driver->control(vo, VOCTRL_SET_PANSCAN, NULL);
250+
}
251+
}
252+
}
253+
254+
static void handle_file_change(struct vo *vo)
255+
{
256+
struct vo_internal *in = vo->in;
257+
258+
if (in->changing_file) {
259+
in->changing_file = false;
246260
vo->driver->control(vo, VOCTRL_SET_PANSCAN, NULL);
247261
}
248262
}
@@ -1012,6 +1026,8 @@ static bool render_frame(struct vo *vo)
10121026

10131027
stats_time_start(in->stats, "video-flip");
10141028

1029+
handle_file_change(vo);
1030+
10151031
vo->driver->flip_page(vo);
10161032

10171033
struct vo_vsync_info vsync = {
@@ -1236,6 +1252,17 @@ void vo_set_paused(struct vo *vo, bool paused)
12361252
mp_mutex_unlock(&in->lock);
12371253
}
12381254

1255+
static void run_set_changing_file(void *p)
1256+
{
1257+
struct vo *vo = p;
1258+
vo->in->changing_file = true;
1259+
}
1260+
1261+
void vo_set_changing_file(struct vo *vo)
1262+
{
1263+
mp_dispatch_run(vo->in->dispatch, run_set_changing_file, vo);
1264+
}
1265+
12391266
int64_t vo_get_drop_count(struct vo *vo)
12401267
{
12411268
mp_mutex_lock(&vo->in->lock);

video/out/vo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ bool vo_want_redraw(struct vo *vo);
542542
void vo_seek_reset(struct vo *vo);
543543
void vo_destroy(struct vo *vo);
544544
void vo_set_paused(struct vo *vo, bool paused);
545+
void vo_set_changing_file(struct vo *vo);
545546
int64_t vo_get_drop_count(struct vo *vo);
546547
void vo_increment_drop_count(struct vo *vo, int64_t n);
547548
int64_t vo_get_delayed_count(struct vo *vo);

0 commit comments

Comments
 (0)