matroska: warn against mismatching segments

Matroska ordered chapters require all segment files to have the same
layout. If a referenced file has more tracks than the main file or
misses some tracks, the file is invalid.

Also see issue #1553.
This commit is contained in:
wm4 2015-02-04 23:02:27 +01:00
parent 59dc351772
commit 868d0f1e83
1 changed files with 49 additions and 0 deletions

View File

@ -471,6 +471,53 @@ static void build_timeline_loop(struct MPContext *mpctx,
*missing_time += limit - local_starttime;
}
static void check_track_compatibility(struct MPContext *mpctx)
{
struct demuxer *mainsrc = mpctx->track_layout;
for (int n = 0; n < mpctx->num_timeline_parts; n++) {
struct timeline_part *p = &mpctx->timeline[n];
if (p->source == mainsrc)
continue;
for (int i = 0; i < p->source->num_streams; i++) {
struct sh_stream *s = p->source->streams[i];
if (s->attached_picture)
continue;
if (!demuxer_stream_by_demuxer_id(mainsrc, s->type, s->demuxer_id)) {
MP_WARN(mpctx, "Source %s has %s stream with TID=%d, which "
"is not present in the ordered chapters main "
"file. This is a broken file. "
"The additional stream is ignored.\n",
p->source->filename, stream_type_name(s->type),
s->demuxer_id);
}
}
for (int i = 0; i < mainsrc->num_streams; i++) {
struct sh_stream *m = mainsrc->streams[i];
if (m->attached_picture)
continue;
struct sh_stream *s =
demuxer_stream_by_demuxer_id(p->source, m->type, m->demuxer_id);
if (s) {
// There are actually many more things that in theory have to
// match (though mpv's implementation doesn't care).
if (s->codec && m->codec && strcmp(s->codec, m->codec) != 0)
MP_WARN(mpctx, "Timeline segments have mismatching codec.\n");
} else {
MP_WARN(mpctx, "Source %s lacks %s stream with TID=%d, which "
"is present in the ordered chapters main "
"file. This is a broken file.\n",
p->source->filename, stream_type_name(m->type),
m->demuxer_id);
}
}
}
}
void build_ordered_chapter_timeline(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
@ -579,4 +626,6 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
break;
}
}
check_track_compatibility(mpctx);
}