diff options
author | wm4 <wm4@nowhere> | 2013-07-11 19:22:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-11 19:22:24 +0200 |
commit | e5544e2da38522674edb1eb5d4cfdf179c4328db (patch) | |
tree | 3868c73a022520365a9bd9ef45810d7685b8e5a4 /core | |
parent | 83eb28fff7d3a588610c617d255ae2420b792c44 (diff) | |
download | mpv-e5544e2da38522674edb1eb5d4cfdf179c4328db.tar.bz2 mpv-e5544e2da38522674edb1eb5d4cfdf179c4328db.tar.xz |
demux: improve DVD sub auto-selection hack
The code touched by this commit makes sure that DVD subtitle tracks
known by libdvdread but not known by demux_lavf can be selected and
displayed properly. These subtitle tracks have the first packet
some time late in the packet stream, so that libavformat won't
immediately recognize them, and will add the track as soon as the
first packet is seen during normal demuxing.
demux_mpg used to handle this elegantly: you just set the MPEG ID of
the stream you wanted. demux_lavf couldn't do this, so it was emulated
with a DEMUXER_CTRL. This commit changes it so that new streams are
selected by default (if autoselect is enabled), and the playloop
simply can take appropriate action before the lower layer throws away
the first packet.
This also changes the demux_lavf behavior that subtitle packets are
always demuxed, even if not needed. (They were immediately thrown away,
so there was no advantage to this.)
Further, this adds the ability to demux.c to deal with demuxing more
than one stream of a kind at once. (Though currently it's not useful.)
Diffstat (limited to 'core')
-rw-r--r-- | core/mplayer.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index 275795defb..2cc4659eef 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -913,12 +913,6 @@ static int map_id_from_demuxer(struct demuxer *d, enum stream_type type, int id) id = id & 0x1F; return id; } -static int map_id_to_demuxer(struct demuxer *d, enum stream_type type, int id) -{ - if (d->stream->uncached_type == STREAMTYPE_DVD && type == STREAM_SUB) - id = id | 0x20; - return id; -} static struct track *add_stream_track(struct MPContext *mpctx, struct sh_stream *stream, @@ -937,7 +931,9 @@ static struct track *add_stream_track(struct MPContext *mpctx, track->stream = stream; track->demuxer_id = stream->demuxer_id; // Initialize lazily selected track - if (track == mpctx->current_track[STREAM_SUB]) + bool selected = track == mpctx->current_track[STREAM_SUB]; + demuxer_select_track(track->demuxer, stream, selected); + if (selected) reinit_subs(mpctx); return track; } @@ -973,6 +969,8 @@ static struct track *add_stream_track(struct MPContext *mpctx, track->lang = talloc_strdup(track, req.name); } + demuxer_select_track(track->demuxer, stream, false); + return track; } @@ -1004,6 +1002,7 @@ static void add_dvd_tracks(struct MPContext *mpctx) track->lang = talloc_strdup(track, req.name); } } + demuxer_enable_autoselect(demuxer); #endif } @@ -1885,18 +1884,9 @@ static void reinit_subs(struct MPContext *mpctx) mpctx->sh_sub->dec_sub = sub_create(opts); assert(track->demuxer); - if (!track->stream) { - // Lazily added DVD track - we must not miss the first subtitle packet, - // which makes the demuxer create the sh_stream, and contains the first - // subtitle event. - - // demux_lavf - IDs are essentially random, have to use MPEG IDs - int id = map_id_to_demuxer(track->demuxer, track->type, - track->demuxer_id); - demux_control(track->demuxer, DEMUXER_CTRL_AUTOSELECT_SUBTITLE, &id); - + // Lazily added DVD track - will be created on first sub packet + if (!track->stream) return; - } mpctx->initialized_flags |= INITIALIZED_SUB; |