From 9b81b7827ce4ce887c6f22332e31b058f68cf3ac Mon Sep 17 00:00:00 2001 From: Daniel Dawson Date: Tue, 1 Dec 2009 03:59:38 -0800 Subject: [PATCH] demux_mkv: Detect and warn about virtual timeline nesting Detect use of ChapterSegmentEditionUID element in a Matroska chapter definition, indicating inclusion of an external virtual timeline, which is not yet supported. Leave the chapter is the chapter list but set segment_uid to zero. This way timeline parsing will skip the chapter and avoid nonsensical output but will still print information about missing content. --- libmpdemux/demux_mkv.c | 16 ++++++++++++++++ libmpdemux/ebml.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index dcf2a71721..3874298172 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -1093,6 +1093,7 @@ static uint64_t read_one_chapter(struct demuxer *demuxer, stream_t *s) char *name = 0; int i; uint32_t id; + bool badchapter = false; len = ebml_read_length(s, &i); uint64_t bytes_read = len + i; @@ -1147,6 +1148,15 @@ static uint64_t read_one_chapter(struct demuxer *demuxer, stream_t *s) } break; + case MATROSKA_ID_CHAPTERSEGMENTEDITIONUID: + mp_tmsg(MSGT_DEMUX, MSGL_WARN, + "[mkv] Warning: unsupported edition recursion in chapter; " + "will skip on playback!\n"); + ebml_read_skip(s, &l); + len -= l; + badchapter = true; + break; + default: ebml_read_skip(s, &l); len -= l; @@ -1169,6 +1179,11 @@ static uint64_t read_one_chapter(struct demuxer *demuxer, stream_t *s) m->ordered_chapters[m->num_ordered_chapters] = chapter; m->num_ordered_chapters++; + if (badchapter) { + memset(&chapter.segment_uid, 0, sizeof(chapter.segment_uid)); + goto cleanup; + } + mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter %u from %02d:%02d:%02d." "%03d to %02d:%02d:%02d.%03d, %s\n", cid, @@ -1181,6 +1196,7 @@ static uint64_t read_one_chapter(struct demuxer *demuxer, stream_t *s) (int) ((end / 1000) % 60), (int) (end % 1000), name); +cleanup: free(name); return bytes_read; } diff --git a/libmpdemux/ebml.h b/libmpdemux/ebml.h index 4faf2495f1..a224bcd8e0 100644 --- a/libmpdemux/ebml.h +++ b/libmpdemux/ebml.h @@ -152,6 +152,8 @@ #define MATROSKA_ID_CHAPTERDISPLAY 0x80 #define MATROSKA_ID_CHAPSTRING 0x85 #define MATROSKA_ID_CHAPTERSEGMENTUID 0x6E67 +#define MATROSKA_ID_CHAPTERSEGMENTEDITIONUID\ + 0x6EBC /* IDs in the cluster master */ #define MATROSKA_ID_CLUSTERTIMECODE 0xE7 -- 2.11.4.GIT