diff options
author | Dudemanguy <random342@airmail.cc> | 2024-01-21 17:14:39 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-02-15 16:43:11 +0000 |
commit | 8f043de961f5b57c60e61e49b1841ad20faa64fe (patch) | |
tree | 69c4510a26174548181db3226328a06b0ba65a3a /player/playloop.c | |
parent | 0a4b098c616bf1b6700bc88878b028bf1f446868 (diff) | |
download | mpv-8f043de961f5b57c60e61e49b1841ad20faa64fe.tar.bz2 mpv-8f043de961f5b57c60e61e49b1841ad20faa64fe.tar.xz |
player/sub: avoid wasteful subtitle redraws
This only affects two special cases: printing subtitles to the terminal
and printing subtitles on a still picture. Previously, mpv was very dumb
here and spammed this logic on every single loop. For terminal
subtitles, this isn't as big of a deal, but for the image case this is
pretty bad. The entire VO constantly redrew even when there was no need
to which can be very expensive depending on user settings.
Instead, let's rework sub_read_packets so that it also tells us whether
or not the subtitle packets update in some way in addition to telling us
whether or not to read more. Since we cache all packets thanks to the
previous commit, we can leverage this information to make a guess
whether or not the current subtitle packet is supposed to be visible on
the screen. Because the redraw now only happens when it is needed, the
mp_set_timeout_hack can be removed.
Diffstat (limited to 'player/playloop.c')
-rw-r--r-- | player/playloop.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/player/playloop.c b/player/playloop.c index 3a10f6faee..eccc432ffe 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -419,6 +419,7 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek) update_ab_loop_clip(mpctx); mpctx->current_seek = seek; + redraw_subs(mpctx); } // This combines consecutive seek requests. @@ -665,6 +666,9 @@ static void handle_osd_redraw(struct MPContext *mpctx) if (!want_redraw) return; vo_redraw(mpctx->video_out); + // Even though we just redrew, it may need to be done again for certain + // cases of subtitles on an image. + redraw_subs(mpctx); } static void clear_underruns(struct MPContext *mpctx) |