path: root/player
diff options
authorwm4 <wm4@nowhere>2016-03-06 14:50:36 +0100
committerwm4 <wm4@nowhere>2016-03-06 15:17:59 +0100
commit05b2cd08dcaddb9ea6224f3ad3a32e1d967d0a98 (patch)
tree39ffaf15780da0cbde76c6e73ffec4a0ab7b404a /player
parent5c1fe2a4f3e559a0c6a010e48b0c225d01c1cd0a (diff)
sub: make preloading more robust
Subtitles can be preloaded, which means they're fully read and copied into ASS_Track. This in turn is mainly for the sake of being able to do subtitle seeking (when it comes down to it, subtitle seeking is the cause for most trouble here). Commit a714f8e92 broke preloaded subtitles which have events with unknown duration, such as some MicroDVD samples. The event list gets cleared on every seek, so the property of being preloaded obviously gets lost. Fix this by moving most of the preloading logic to dec_sub.c. If the subtitle list gets cleared, they are not considered preloaded anymore, and the logic for demuxed subtitles is used. As another minor thing, preloadeding subtitles did neither disable the demux stream, nor did it discard packets. Thus you could get queue overflows in theory (harmless, but annoying). Fix this by explicitly discarding packets in preloaded mode. In summary, now the only difference between preloaded and normal demuxing are: 1. a seek is issued, and all packets are read on start 2. during playback, discard the packets instead of feeding them to the subtitle decoder This is still petty annoying. It would be nice if maintaining the subtitle index (and maybe a subtitle packet cache for instant subtitle presentation when seeking back) could be maintained in the demuxer instead. Half of all file formats with interleaved subtitles have this anyway (mp4, mkv muxed with newer mkvmerge).
Diffstat (limited to 'player')
2 files changed, 4 insertions, 11 deletions
diff --git a/player/core.h b/player/core.h
index f26cacbb51..21129d6ea3 100644
--- a/player/core.h
+++ b/player/core.h
@@ -147,10 +147,6 @@ struct track {
struct vo_chain *vo_c;
struct ao_chain *ao_c;
struct lavfi_pad *sink;
- // For external subtitles, which are read fully on init. Do not attempt
- // to read packets from them.
- bool preloaded;
// Summarizes video filtering and output.
diff --git a/player/sub.c b/player/sub.c
index 426e31bc7a..69c1dbbd19 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -99,18 +99,15 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts,
video_pts -= opts->sub_delay;
- if (!track->preloaded && track->demuxer->fully_read && !opts->sub_clear_on_seek)
- {
+ if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
// Assume fully_read implies no interleaved audio/video streams.
// (Reading packets will change the demuxer position.)
demux_seek(track->demuxer, 0, 0);
- track->preloaded = sub_read_all_packets(track->d_sub);
+ sub_preload(dec_sub);
- if (!track->preloaded) {
- if (!sub_read_packets(dec_sub, video_pts))
- return false;
- }
+ if (!sub_read_packets(dec_sub, video_pts))
+ return false;
// Handle displaying subtitles on terminal; never done for secondary subs
if (mpctx->current_track[0][STREAM_SUB] == track && !mpctx->video_out)