summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-15 21:09:15 +0100
committerwm4 <wm4@nowhere>2012-11-16 21:21:16 +0100
commitf7163c80658651804437f9a7f5bed6fb34a32830 (patch)
treec9ddd879009278cb2204cc598621039ea971b932 /core
parent589bda26cec162e1e27a8e40b333ca198a621b3f (diff)
downloadmpv-f7163c80658651804437f9a7f5bed6fb34a32830.tar.bz2
mpv-f7163c80658651804437f9a7f5bed6fb34a32830.tar.xz
subtitles: improve support for libavformat demuxed subtitles
Make demux_lavf not error out if no video or audio track is present. This allows opening subtitle files with the demuxer. Improve the test whether subtitles read from demuxers must do explicit packet reads. (I'm not sure whether always doing these reads could have bad effects, such as reading too many audio and video packets at once, so be conservative.)
Diffstat (limited to 'core')
-rw-r--r--core/mplayer.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index c16a38a3c0..a48bd4b37c 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1675,6 +1675,23 @@ double playing_audio_pts(struct MPContext *mpctx)
return pts - mpctx->opts.playback_speed *ao_get_delay(mpctx->ao);
}
+// When reading subtitles from a demuxer, and we don't read video or audio
+// from the demuxer, we must explicitly read subtitle packets. (Normally,
+// subs are interleaved with video and audio, so we get them automatically.)
+static bool is_non_interleaved(struct MPContext *mpctx, struct track *track)
+{
+ if (track->is_external || !track->demuxer)
+ return true;
+
+ struct demuxer *demuxer = track->demuxer;
+ for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
+ struct track *other = mpctx->current_track[type];
+ if (other != track && other->demuxer && other->demuxer == demuxer)
+ return false;
+ }
+ return true;
+}
+
static void reset_subtitles(struct MPContext *mpctx)
{
if (mpctx->sh_sub)
@@ -1765,7 +1782,7 @@ static void update_subtitles(struct MPContext *mpctx, double refpts_tl)
spudec_assemble(vo_spudec, packet, len, timestamp);
}
} else if (d_sub && (is_text_sub(type) || (sh_sub && sh_sub->active))) {
- bool non_interleaved = track->is_external; // if demuxing subs only
+ bool non_interleaved = is_non_interleaved(mpctx, track);
if (non_interleaved)
ds_get_next_pts(d_sub);