summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv_timeline.c
diff options
context:
space:
mode:
Diffstat (limited to 'demux/demux_mkv_timeline.c')
-rw-r--r--demux/demux_mkv_timeline.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index 1408ddf8f5..0c23e27d25 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -172,6 +172,7 @@ static bool check_file_seg(struct tl_ctx *ctx, char *filename, int segment)
.matroska_wanted_segment = segment,
.matroska_was_valid = &was_valid,
.disable_timeline = true,
+ .stream_flags = ctx->tl->stream_origin,
};
struct mp_cancel *cancel = ctx->tl->cancel;
if (mp_cancel_test(cancel))
@@ -257,8 +258,10 @@ static void find_ordered_chapter_sources(struct tl_ctx *ctx)
playlist_parse_file(opts->ordered_chapters_files,
ctx->tl->cancel, ctx->global);
talloc_steal(tmp, pl);
- for (struct playlist_entry *e = pl ? pl->first : NULL; e; e = e->next)
- MP_TARRAY_APPEND(tmp, filenames, num_filenames, e->filename);
+ for (int n = 0; n < pl->num_entries; n++) {
+ MP_TARRAY_APPEND(tmp, filenames, num_filenames,
+ pl->entries[n]->filename);
+ }
} else if (!ctx->demuxer->stream->is_local_file) {
MP_WARN(ctx, "Playback source is not a "
"normal disk file. Will not search for related files.\n");
@@ -455,12 +458,10 @@ static void build_timeline_loop(struct tl_ctx *ctx,
ctx->missing_time += info->limit - local_starttime;
}
-static void check_track_compatibility(struct timeline *tl)
+static void check_track_compatibility(struct tl_ctx *tl, struct demuxer *mainsrc)
{
- struct demuxer *mainsrc = tl->track_layout;
-
for (int n = 0; n < tl->num_parts; n++) {
- struct timeline_part *p = &tl->parts[n];
+ struct timeline_part *p = &tl->timeline[n];
if (p->source == mainsrc)
continue;
@@ -493,6 +494,11 @@ static void check_track_compatibility(struct timeline *tl)
// match (though mpv's implementation doesn't care).
if (strcmp(s->codec->codec, m->codec->codec) != 0)
MP_WARN(tl, "Timeline segments have mismatching codec.\n");
+ if (s->codec->extradata_size != m->codec->extradata_size ||
+ (s->codec->extradata_size &&
+ memcmp(s->codec->extradata, m->codec->extradata,
+ s->codec->extradata_size) != 0))
+ MP_WARN(tl, "Timeline segments have mismatching codec info.\n");
} else {
MP_WARN(tl, "Source %s lacks %s stream with TID=%d, which "
"is present in the ordered chapters main "
@@ -517,7 +523,7 @@ void build_ordered_chapter_timeline(struct timeline *tl)
.global = tl->global,
.tl = tl,
.demuxer = demuxer,
- .opts = mp_get_config_group(ctx, tl->global, GLOBAL_CONFIG),
+ .opts = mp_get_config_group(ctx, tl->global, &mp_opt_root),
};
if (!ctx->opts->ordered_chapters || !demuxer->access_references) {
@@ -593,10 +599,11 @@ void build_ordered_chapter_timeline(struct timeline *tl)
MP_TARRAY_APPEND(NULL, ctx->timeline, ctx->num_parts, new);
}
- struct timeline_part new = {
- .start = ctx->start_time / 1e9,
+ for (int n = 0; n < ctx->num_parts; n++) {
+ ctx->timeline[n].end = n == ctx->num_parts - 1
+ ? ctx->start_time / 1e9
+ : ctx->timeline[n + 1].start;
};
- MP_TARRAY_APPEND(NULL, ctx->timeline, ctx->num_parts, new);
/* Ignore anything less than a millisecond when reporting missing time. If
* users really notice less than a millisecond missing, maybe this can be
@@ -606,22 +613,30 @@ void build_ordered_chapter_timeline(struct timeline *tl)
ctx->missing_time / 1e9);
}
- tl->sources = ctx->sources;
- tl->num_sources = ctx->num_sources;
- tl->parts = ctx->timeline;
- tl->num_parts = ctx->num_parts - 1; // minus termination
- tl->chapters = chapters;
- tl->num_chapters = m->num_ordered_chapters;
-
// With Matroska, the "master" file usually dictates track layout etc.,
// except maybe with playlist-like files.
- tl->track_layout = tl->parts[0].source;
- for (int n = 0; n < tl->num_parts; n++) {
- if (tl->parts[n].source == ctx->demuxer) {
- tl->track_layout = ctx->demuxer;
+ struct demuxer *track_layout = ctx->timeline[0].source;
+ for (int n = 0; n < ctx->num_parts; n++) {
+ if (ctx->timeline[n].source == ctx->demuxer) {
+ track_layout = ctx->demuxer;
break;
}
}
- check_track_compatibility(tl);
+ check_track_compatibility(ctx, track_layout);
+
+ tl->sources = ctx->sources;
+ tl->num_sources = ctx->num_sources;
+
+ struct timeline_par *par = talloc_ptrtype(tl, par);
+ *par = (struct timeline_par){
+ .parts = ctx->timeline,
+ .num_parts = ctx->num_parts,
+ .track_layout = track_layout,
+ };
+ MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par);
+ tl->chapters = chapters;
+ tl->num_chapters = m->num_ordered_chapters;
+ tl->meta = track_layout;
+ tl->format = "mkv_oc";
}