summaryrefslogtreecommitdiffstats
path: root/player/core.h
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-01-21 17:14:39 -0600
committerDudemanguy <random342@airmail.cc>2024-02-15 16:43:11 +0000
commit8f043de961f5b57c60e61e49b1841ad20faa64fe (patch)
tree69c4510a26174548181db3226328a06b0ba65a3a /player/core.h
parent0a4b098c616bf1b6700bc88878b028bf1f446868 (diff)
downloadmpv-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/core.h')
-rw-r--r--player/core.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/player/core.h b/player/core.h
index 8a49585cdf..9d9c4e8307 100644
--- a/player/core.h
+++ b/player/core.h
@@ -402,6 +402,9 @@ typedef struct MPContext {
int last_chapter_seek;
bool last_chapter_flag;
+ /* Heuristic for potentially redrawing subs. */
+ bool redraw_subs;
+
bool paused; // internal pause state
bool playback_active; // not paused, restarting, loading, unloading
bool in_playloop;
@@ -621,6 +624,7 @@ void mp_load_builtin_scripts(struct MPContext *mpctx);
int64_t mp_load_user_script(struct MPContext *mpctx, const char *fname);
// sub.c
+void redraw_subs(struct MPContext *mpctx);
void reset_subtitle_state(struct MPContext *mpctx);
void reinit_sub(struct MPContext *mpctx, struct track *track);
void reinit_sub_all(struct MPContext *mpctx);