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 /sub/dec_sub.h | |
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 'sub/dec_sub.h')
-rw-r--r-- | sub/dec_sub.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sub/dec_sub.h b/sub/dec_sub.h index 8c8d7d4de5..eb8406cb14 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -43,7 +43,8 @@ void sub_destroy(struct dec_sub *sub); bool sub_can_preload(struct dec_sub *sub); void sub_preload(struct dec_sub *sub); void sub_redecode_cached_packets(struct dec_sub *sub); -bool sub_read_packets(struct dec_sub *sub, double video_pts, bool force); +void sub_read_packets(struct dec_sub *sub, double video_pts, bool force, + bool *packets_read, bool *sub_updated); struct sub_bitmaps *sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim, int format, double pts); char *sub_get_text(struct dec_sub *sub, double pts, enum sd_text_type type); |