From a09396ee609af71f49f70521320e87989577b577 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 11 Jan 2019 13:52:29 +0100 Subject: demux_edl, cue, mkv: clean up timeline stuff slightly Remove the singly linked list hack, replace it with a slightly more proper data structure. This probably gets rid of a few minor bugs along the way, caused by the awkward nonsensical sharing/duplication of some fields. Another change (because I'm touching everything related to timeline anyway) is that I'm removing the special semantics for parts[num_parts]. This is now strictly out of bounds, and instead of using the start time of the next/beyond-last part, there is an end time field now. Unfortunately, this also requires touching the code for cue and mkv ordered chapters. From some superficial testing, they still seem to mostly work. One observable change is that the "no_chapters" header is per-stream now, which is arguably more correct, and getting the old behavior would require adding code to handle it as special-case, so just adjust ytdl_hook.lua to the new behavior. --- demux/demux_cue.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'demux/demux_cue.c') diff --git a/demux/demux_cue.c b/demux/demux_cue.c index f54c3f3e4a..8518d928d1 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -210,6 +210,7 @@ static void build_timeline(struct timeline *tl) } timeline[i] = (struct timeline_part) { .start = starttime, + .end = starttime + duration, .source_start = tracks[i].start, .source = source, }; @@ -217,23 +218,20 @@ static void build_timeline(struct timeline *tl) .pts = timeline[i].start, .metadata = mp_tags_dup(tl, tracks[i].tags), }; - starttime += duration; + starttime = timeline[i].end; } - // apparently we need this to give the last part a non-zero length - timeline[track_count] = (struct timeline_part) { - .start = starttime, - // perhaps unused by the timeline code - .source_start = 0, - .source = timeline[0].source, + struct timeline_par *par = talloc_ptrtype(tl, par); + *par = (struct timeline_par){ + .parts = timeline, + .num_parts = track_count, + .track_layout = timeline[0].source, }; - tl->parts = timeline; - // the last part is not included it in the count - tl->num_parts = track_count + 1 - 1; tl->chapters = chapters; tl->num_chapters = track_count; - tl->track_layout = tl->parts[0].source; + MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par); + tl->meta = par->track_layout; out: talloc_free(ctx); -- cgit v1.2.3