summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-29 22:34:36 +0200
committerwm4 <wm4@nowhere>2013-04-29 22:59:15 +0200
commit1c96f51e36593d43843e8bd41cee49a2bee5e4dc (patch)
tree599eaf317b1aa29af5c0a5c1b6fc916ac7ab0769 /demux
parent2d8783075f788b9486a13e929871077850faa230 (diff)
downloadmpv-1c96f51e36593d43843e8bd41cee49a2bee5e4dc.tar.bz2
mpv-1c96f51e36593d43843e8bd41cee49a2bee5e4dc.tar.xz
demux: simplify stream ID business, fix issue with cover art
The stream ID handling as it was changed in commit 654c34f was still a little bit insane, and caused a regression with the cover art hack (the stream set in demux->video->sh was incorrect for demux_lavf). Simplify by always using stream_index for demux_stream->id, and getting rid of that tid thing. It turns out that the id for subtitles isn't special either (maybe demux_ts.c was the only thing left that required this).
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c19
-rw-r--r--demux/demux_ts.c2
-rw-r--r--demux/stheader.h5
3 files changed, 9 insertions, 17 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 9347f9a02c..e1bb960e78 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -244,9 +244,9 @@ demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer,
enum stream_type type,
int stream_index,
- int tid)
+ int demuxer_id)
{
- if (demuxer->num_streams > MAX_SH_STREAMS) {
+ if (demuxer->num_streams > MAX_SH_STREAMS || stream_index > MAX_SH_STREAMS) {
mp_msg(MSGT_DEMUXER, MSGL_WARN, "Too many streams.");
return NULL;
}
@@ -255,8 +255,7 @@ static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer,
.type = type,
.demuxer = demuxer,
.index = demuxer->num_streams,
- .demuxer_id = tid, // may be overwritten by demuxer
- .tid = tid,
+ .demuxer_id = demuxer_id, // may be overwritten by demuxer
.stream_index = stream_index,
.opts = demuxer->opts,
});
@@ -1203,7 +1202,7 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
int old_id = demuxer->ds[type]->id;
// legacy
- int index = stream ? stream->tid : -2;
+ int index = stream ? stream->stream_index : -2;
if (type == STREAM_AUDIO) {
if (demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index)
== DEMUXER_CTRL_NOTIMPL)
@@ -1213,8 +1212,7 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
== DEMUXER_CTRL_NOTIMPL)
demuxer->video->id = index;
} else if (type == STREAM_SUB) {
- int index2 = stream ? stream->stream_index : -2;
- demuxer->ds[type]->id = index2;
+ demuxer->ds[type]->id = index;
} else {
abort();
}
@@ -1238,12 +1236,7 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
bool demuxer_stream_is_selected(struct demuxer *d, struct sh_stream *stream)
{
- if (!stream)
- return false;
- int st_id = stream->tid;
- if (stream->type == STREAM_SUB) // major braindeath
- st_id = stream->stream_index;
- return d->ds[stream->type]->id == st_id;
+ return stream && d->ds[stream->type]->id == stream->stream_index;
}
int demuxer_add_attachment(demuxer_t *demuxer, struct bstr name,
diff --git a/demux/demux_ts.c b/demux/demux_ts.c
index 6d41dfd939..40675fa6f5 100644
--- a/demux/demux_ts.c
+++ b/demux/demux_ts.c
@@ -2986,7 +2986,7 @@ static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet,
{
sh_sub_t *sh_sub = demuxer->sub->sh;
- if(sh_sub && sh_sub->gsh->tid == tss->pid)
+ if(sh_sub && sh_sub->gsh->demuxer_id == tss->pid)
{
ds = demuxer->sub;
diff --git a/demux/stheader.h b/demux/stheader.h
index af4ceaff16..2bbb74160e 100644
--- a/demux/stheader.h
+++ b/demux/stheader.h
@@ -42,11 +42,10 @@ struct sh_stream {
struct demuxer *demuxer;
// Index into demuxer->streams.
int index;
- // The (possibly) type specific id, e.g. aid or sid.
- int tid;
// Index into stream array (currently one array per type, e.g. a_streams).
int stream_index;
- // Demuxer specific ID (always set, defaults to tid).
+ // Demuxer/format specific ID. Corresponds to the stream IDs as encoded in
+ // some file formats (e.g. MPEG), or an index chosen by demux.c.
int demuxer_id;
// One of these is non-NULL, the others are NULL, depending on the stream
// type.