diff options
author | wm4 <wm4@nowhere> | 2016-01-21 23:49:25 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-01-22 00:25:44 +0100 |
commit | 50c701574dc6b52a695e417586875aa0066592e8 (patch) | |
tree | 607bf56f1cd4d91c8f69754f66ceeece41febdaa /player | |
parent | 04ec417d41a7792e08d4bd6c6ee24671c17425b4 (diff) |
sub: change when/how subtitles are read completely
Most text subtitles are read completely on loading (libavformat works
this way, and there are good reasons to do it on the higher levels too).
This leads to some messy problems. For example, the subtitle path is the
only one which might read packets during decoder initialization. This is
not neccessary; get rid of it.
This fixes a potential problem of seeking to position 0 for image
subtitles on init, and if the start position is not at the beginning of
the timeline.
Diffstat (limited to 'player')
-rw-r--r-- | player/sub.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/player/sub.c b/player/sub.c index 6e707b3d95..ab9f714352 100644 --- a/player/sub.c +++ b/player/sub.c @@ -100,6 +100,14 @@ 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) + { + // Assume fully_read implies no interleaved audio/video streams. + // (Reading packets will change the demuxer position.) + demux_seek(track->demuxer, 0, SEEK_ABSOLUTE); + track->preloaded = sub_read_all_packets(track->d_sub); + } + if (!track->preloaded) { if (!sub_read_packets(dec_sub, video_pts)) return false; @@ -124,8 +132,6 @@ bool update_subtitles(struct MPContext *mpctx, double video_pts) static bool init_subdec(struct MPContext *mpctx, struct track *track) { - struct MPOpts *opts = mpctx->opts; - assert(!track->d_sub); if (!track->demuxer || !track->stream) @@ -141,16 +147,6 @@ static bool init_subdec(struct MPContext *mpctx, struct track *track) double fps = v_c ? v_c->fps : 25; sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps); - // Don't do this if the file has video/audio streams. Don't do it even - // if it has only sub streams, because reading packets will change the - // demuxer position. - if (track->is_external && !opts->sub_clear_on_seek) { - demux_seek(track->demuxer, 0, SEEK_ABSOLUTE); - track->preloaded = sub_read_all_packets(track->d_sub); - if (track->preloaded) - demux_stop_thread(track->demuxer); - } - return true; } |