diff options
author | wm4 <wm4@nowhere> | 2019-01-11 13:52:29 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:04 +0200 |
commit | a09396ee609af71f49f70521320e87989577b577 (patch) | |
tree | f6daf16eb6eefb20e68b4e1458136a38fc9a6c13 /demux/timeline.h | |
parent | 6efcde06e31be4db0b2d9e3958bafffcdaa0a42e (diff) | |
download | mpv-a09396ee609af71f49f70521320e87989577b577.tar.bz2 mpv-a09396ee609af71f49f70521320e87989577b577.tar.xz |
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.
Diffstat (limited to 'demux/timeline.h')
-rw-r--r-- | demux/timeline.h | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/demux/timeline.h b/demux/timeline.h index 0940592aea..544220358a 100644 --- a/demux/timeline.h +++ b/demux/timeline.h @@ -1,44 +1,55 @@ #ifndef MP_TIMELINE_H_ #define MP_TIMELINE_H_ +// Single segment in a timeline. struct timeline_part { - double start; + // (end time must match with start time of the next part) + double start, end; double source_start; char *url; struct demuxer *source; }; +// Timeline formed by a single demuxer. Multiple pars are used to get tracks +// that require a separate opened demuxer, such as separate audio tracks. (For +// example, for ordered chapters there is only a single par, because all streams +// demux from the same file at a given time, while for DASH-style video+audio, +// each track would have its own timeline.) +// Note that demuxer instances must not be shared across timeline_pars. This +// would conflict in demux_timeline.c. +// "par" is short for parallel stream. +struct timeline_par { + bstr init_fragment; + bool dash, no_clip; + + // Segments to play, ordered by time. + struct timeline_part *parts; + int num_parts; + + // Which source defines the overall track list (over the full timeline). + struct demuxer *track_layout; +}; + struct timeline { struct mpv_global *global; struct mp_log *log; struct mp_cancel *cancel; - // main source + // main source, and all other sources (this usually only has special meaning + // for memory management; mostly compensates for the lack of refcounting) struct demuxer *demuxer; - - bstr init_fragment; - bool dash, no_clip; - - // All referenced files. struct demuxer **sources; int num_sources; - // Segments to play, ordered by time. parts[num_parts] must be valid; its - // start field sets the duration, and source must be NULL. - struct timeline_part *parts; - int num_parts; + // Description of timeline ranges, possibly multiple parallel ones. + struct timeline_par **pars; + int num_pars; struct demux_chapter *chapters; int num_chapters; - // Which source defines the overall track list (over the full timeline). - struct demuxer *track_layout; - - // For tracks which require a separate opened demuxer, such as separate - // audio tracks. (For example, for ordered chapters this would be NULL, - // because all streams demux from the same file at a given time, while - // for DASH-style video+audio, each track would have its own timeline.) - struct timeline *next; + // global tags, attachments, editions + struct demuxer *meta; }; struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log, |