From 0ece360eeaf95f2c33df2c0177cb98ffd5fc0338 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 4 Aug 2011 08:38:39 +0300 Subject: demux_mkv: skip files faster in ordered chapter file search Ordered chapter code tries opening files to find those matching the SegmentUID values specified in the timeline. Previously this scan did a full initialization of the Matroska demuxer for each file, then checked whether the UID value in the demuxer was a match. Make the scan code instead provide a list of searched-for UIDs to the demuxer open code, and make that do a comparison against the list as soon as it sees the UID in the file, aborting if there is no match. Also fix units used in "Merging timeline part" verbose message. --- timeline/tl_matroska.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'timeline') diff --git a/timeline/tl_matroska.c b/timeline/tl_matroska.c index 6912bac159..967ee556ae 100644 --- a/timeline/tl_matroska.c +++ b/timeline/tl_matroska.c @@ -112,10 +112,12 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx, struct stream *s = open_stream(filenames[i], &mpctx->opts, &format); if (!s) continue; - struct demuxer *d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_MATROSKA, - mpctx->opts.audio_id, - mpctx->opts.video_id, - mpctx->opts.sub_id, filenames[i]); + struct demuxer *d = demux_open_withparams(&mpctx->opts, s, + DEMUXER_TYPE_MATROSKA, mpctx->opts.audio_id, + mpctx->opts.video_id, mpctx->opts.sub_id, filenames[i], + &(struct demuxer_params){.matroska_wanted_uids = uid_map}); + + if (!d) { free_stream(s); continue; @@ -176,7 +178,8 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) m->num_ordered_chapters+1); sources[0].stream = mpctx->stream; sources[0].demuxer = mpctx->demuxer; - unsigned char uid_map[m->num_ordered_chapters+1][16]; + unsigned char (*uid_map)[16] = talloc_array_ptrtype(NULL, uid_map, + m->num_ordered_chapters + 1); int num_sources = 1; memcpy(uid_map[0], m->segment_uid, 16); @@ -241,7 +244,7 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) /* Chapter was merged at an inexact boundary; * adjust timestamps to match. */ mp_msg(MSGT_CPLAYER, MSGL_V, "Merging timeline part %d with " - "offset %d ms.\n", i, (int) join_diff); + "offset %g ms.\n", i, join_diff / 1e6); starttime += join_diff; } chapters[num_chapters].start = starttime / 1e9; @@ -250,6 +253,7 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) num_chapters++; } timeline[part_count].start = starttime / 1e9; + talloc_free(uid_map); if (!part_count) { // None of the parts come from the file itself??? -- cgit v1.2.3