summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-11 19:22:24 +0200
committerwm4 <wm4@nowhere>2013-07-11 19:22:24 +0200
commite5544e2da38522674edb1eb5d4cfdf179c4328db (patch)
tree3868c73a022520365a9bd9ef45810d7685b8e5a4 /demux/demux_lavf.c
parent83eb28fff7d3a588610c617d255ae2420b792c44 (diff)
downloadmpv-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 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index ce7c274e4b..f7ef5dda1a 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -73,7 +73,6 @@ typedef struct lavf_priv {
AVFormatContext *avfc;
AVIOContext *pb;
uint8_t buffer[BIO_BUFFER_SIZE];
- int autoselect_sub;
int64_t last_pts;
struct sh_stream **streams; // NULL for unknown streams
int num_streams;
@@ -196,7 +195,6 @@ static int lavf_check_file(demuxer_t *demuxer)
assert(!demuxer->priv);
demuxer->priv = talloc_zero(NULL, lavf_priv_t);
priv = demuxer->priv;
- priv->autoselect_sub = -1;
priv->filename = s->url;
if (!priv->filename) {
@@ -427,7 +425,6 @@ static void handle_stream(demuxer_t *demuxer, int i)
memcpy(sh_sub->extradata, codec->extradata, codec->extradata_size);
sh_sub->extradata_len = codec->extradata_size;
}
- st->discard = AVDISCARD_DEFAULT;
break;
}
case AVMEDIA_TYPE_ATTACHMENT: {
@@ -463,6 +460,9 @@ static void handle_stream(demuxer_t *demuxer, int i)
if (lang && lang->value)
sh->lang = talloc_strdup(sh, lang->value);
}
+
+ bool selected = demuxer_stream_is_selected(demuxer, sh);
+ st->discard = selected ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
}
// Add any new streams that might have been added
@@ -657,13 +657,6 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
AVStream *st = priv->avfc->streams[pkt->stream_index];
struct sh_stream *stream = priv->streams[pkt->stream_index];
- if (stream && stream->type == STREAM_SUB &&
- stream->demuxer_id == priv->autoselect_sub)
- {
- priv->autoselect_sub = -1;
- demuxer_switch_track(demux, STREAM_SUB, stream);
- }
-
if (!demuxer_stream_is_selected(demux, stream)) {
talloc_free(pkt);
return 1;
@@ -799,18 +792,13 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
for (int n = 0; n < priv->num_streams; n++) {
struct sh_stream *stream = priv->streams[n];
AVStream *st = priv->avfc->streams[n];
- if (stream && stream->type != STREAM_SUB) {
+ if (stream) {
bool selected = demuxer_stream_is_selected(demuxer, stream);
st->discard = selected ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
}
}
return DEMUXER_CTRL_OK;
}
- case DEMUXER_CTRL_AUTOSELECT_SUBTITLE:
- {
- priv->autoselect_sub = *((int *)arg);
- return DEMUXER_CTRL_OK;
- }
case DEMUXER_CTRL_IDENTIFY_PROGRAM:
{
demux_program_t *prog = arg;