mirror of https://github.com/mpv-player/mpv
demux: do not make up demuxer_id
The demuxer_id (exported in as "src-id" property) is supposed to be the native stream ID, as it exists in the file, or -1 if that does not exist (actually any negative value), or if it is unknown. Until now, an ID was made up if it was missing. That seems like strange non-sense, and I can't find the reason why it was done. But it was probably for convenience by the EDL stuff or so. Stop doing this. Fortunately, the src-id property was documented as being unavailable if the ID is not known. Even the code for this was present, it was just inactive until now. Extend input.rst with some explanations. Also fixing 3 other places where negative demuxer_id was ignored or avoided.
This commit is contained in:
parent
b6f605285c
commit
370ed5777c
|
@ -2145,7 +2145,11 @@ Property list
|
|||
String describing the media type. One of ``audio``, ``video``, ``sub``.
|
||||
|
||||
``track-list/N/src-id``
|
||||
Track ID as used in the source file. Not always available.
|
||||
Track ID as used in the source file. Not always available. (It is
|
||||
missing if the format has no native ID, if the track is a pseudo-track
|
||||
that does not exist in this way in the actual file, or if the format
|
||||
is handled by libavformat, and the format was not whitelisted as having
|
||||
track IDs.)
|
||||
|
||||
``track-list/N/title``
|
||||
Track title as it is stored in the file. Not always available.
|
||||
|
|
|
@ -980,13 +980,6 @@ static void demux_add_sh_stream_locked(struct demux_internal *in,
|
|||
|
||||
if (sh->ff_index < 0)
|
||||
sh->ff_index = sh->index;
|
||||
if (sh->demuxer_id < 0) {
|
||||
sh->demuxer_id = 0;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
if (in->streams[n]->type == sh->type)
|
||||
sh->demuxer_id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
|
||||
assert(in->streams[sh->index] == sh);
|
||||
|
@ -3762,6 +3755,8 @@ static bool queue_seek(struct demux_internal *in, double seek_pts, int flags,
|
|||
struct sh_stream *demuxer_stream_by_demuxer_id(struct demuxer *d,
|
||||
enum stream_type t, int id)
|
||||
{
|
||||
if (id < 0)
|
||||
return NULL;
|
||||
int num = demux_get_num_stream(d);
|
||||
for (int n = 0; n < num; n++) {
|
||||
struct sh_stream *s = demux_get_stream(d, n);
|
||||
|
|
|
@ -1286,7 +1286,6 @@ static void add_coverart(struct demuxer *demuxer)
|
|||
if (!codec)
|
||||
continue;
|
||||
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
|
||||
sh->demuxer_id = -1 - sh->index; // don't clash with mkv IDs
|
||||
sh->codec->codec = codec;
|
||||
sh->attached_picture = new_demux_packet_from(att->data, att->data_size);
|
||||
if (sh->attached_picture) {
|
||||
|
|
|
@ -133,7 +133,7 @@ static void associate_streams(struct demuxer *demuxer,
|
|||
|
||||
// Matching by demuxer ID is supposedly useful and preferable for
|
||||
// ordered chapters.
|
||||
if (sh->demuxer_id == vs->sh->demuxer_id)
|
||||
if (sh->demuxer_id >= 0 && sh->demuxer_id == vs->sh->demuxer_id)
|
||||
other = vs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue