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 /demux | |
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 'demux')
-rw-r--r-- | demux/packet.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/demux/packet.h b/demux/packet.h index cd1183d417..8e8d20c402 100644 --- a/demux/packet.h +++ b/demux/packet.h @@ -58,6 +58,9 @@ typedef struct demux_packet { struct mp_codec_params *codec; // set to non-NULL iff segmented is set double start, end; // set to non-NOPTS iff segmented is set + // subtitles only + double sub_duration; + // private struct demux_packet *next; struct AVPacket *avpacket; // keep the buffer allocation and sidedata |