From 2c20c6f8923d1295e2ba919f5d31ec1da4f252c8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 26 Dec 2014 19:42:03 +0100 Subject: player: ordered chapters: filter missing chapters Ever since someone (not me) added some Matroska features which nobody ever uses (ordered edition or some bullshit), I haven't had a fucking clue what the fuck is going on in this fucking file. (Still agreed to it, so it's my fault.) mplayer2 handled missing chapters correctly (and I suppose in a somewhat clean/simple manner), but the changed code doesn't. Since I can't even follow this code because it's so arcanely complicated, just add a hack that has the same effect. --- player/timeline/tl_matroska.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/player/timeline/tl_matroska.c b/player/timeline/tl_matroska.c index e97a8ce594..0242623037 100644 --- a/player/timeline/tl_matroska.c +++ b/player/timeline/tl_matroska.c @@ -562,6 +562,9 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline, 0); struct demux_chapter *chapters = talloc_zero_array(NULL, struct demux_chapter, m->num_ordered_chapters); + // Stupid hack, because fuck everything. + for (int n = 0; n < m->num_ordered_chapters; n++) + chapters[n].pts = -1; uint64_t starttime = 0; uint64_t missing_time = 0; uint64_t last_end_time = 0; @@ -570,6 +573,12 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) &missing_time, &last_end_time, &timeline, chapters, &part_count, 0, 0); + // Fuck everything (2): filter out all "unset" chapters. + for (int n = m->num_ordered_chapters - 1; n >= 0; n--) { + if (chapters[n].pts == -1) + MP_TARRAY_REMOVE_AT(chapters, m->num_ordered_chapters, n); + } + if (!part_count) { // None of the parts come from the file itself??? talloc_free(sources); -- cgit v1.2.3