diff options
Diffstat (limited to 'timeline')
-rw-r--r-- | timeline/tl_cue.c | 20 | ||||
-rw-r--r-- | timeline/tl_edl.c | 12 | ||||
-rw-r--r-- | timeline/tl_matroska.c | 26 |
3 files changed, 23 insertions, 35 deletions
diff --git a/timeline/tl_cue.c b/timeline/tl_cue.c index 14d1127819..cfc67bdd84 100644 --- a/timeline/tl_cue.c +++ b/timeline/tl_cue.c @@ -173,16 +173,9 @@ bool mp_probe_cue(struct bstr data) return valid; } -static void add_source(struct MPContext *mpctx, struct stream *s, - struct demuxer *d) +static void add_source(struct MPContext *mpctx, struct demuxer *d) { - mpctx->num_sources++; - mpctx->sources = talloc_realloc(NULL, mpctx->sources, struct content_source, - mpctx->num_sources); - mpctx->sources[mpctx->num_sources - 1] = (struct content_source) { - .stream = s, - .demuxer = d, - }; + MP_TARRAY_APPEND(NULL, mpctx->sources, mpctx->num_sources, d); } static bool try_open(struct MPContext *mpctx, char *filename) @@ -219,7 +212,7 @@ static bool try_open(struct MPContext *mpctx, char *filename) filename); } if (d) { - add_source(mpctx, s, d); + add_source(mpctx, d); return true; } mp_msg(MSGT_CPLAYER, MSGL_ERR, "Could not open source '%s'!\n", filename); @@ -281,9 +274,8 @@ out: } // return length of the source in seconds, or -1 if unknown -static double source_get_length(struct content_source *source) +static double source_get_length(struct demuxer *demuxer) { - struct demuxer *demuxer = source->demuxer; double get_time_ans; // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW if (demuxer && demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH, @@ -373,7 +365,7 @@ void build_cue_timeline(struct MPContext *mpctx) } } - add_source(mpctx, mpctx->stream, mpctx->demuxer); + add_source(mpctx, mpctx->demuxer); for (size_t i = 0; i < file_count; i++) { if (!open_source(mpctx, files[i])) @@ -386,7 +378,7 @@ void build_cue_timeline(struct MPContext *mpctx) track_count); double starttime = 0; for (int i = 0; i < track_count; i++) { - struct content_source *source = mpctx->sources + 1 + tracks[i].source; + struct demuxer *source = mpctx->sources[1 + tracks[i].source]; double duration; if (i + 1 < track_count && tracks[i].source == tracks[i + 1].source) { duration = tracks[i + 1].start - tracks[i].start; diff --git a/timeline/tl_edl.c b/timeline/tl_edl.c index 6763c9fa63..3c8cd21781 100644 --- a/timeline/tl_edl.c +++ b/timeline/tl_edl.c @@ -346,11 +346,10 @@ void build_edl_timeline(struct MPContext *mpctx) // Open source files - struct content_source *sources = talloc_array_ptrtype(NULL, sources, - num_sources + 1); + struct demuxer **sources = talloc_array_ptrtype(NULL, sources, + num_sources + 1); mpctx->sources = sources; - sources[0].stream = mpctx->stream; - sources[0].demuxer = mpctx->demuxer; + sources[0] = mpctx->demuxer; mpctx->num_sources = 1; for (int i = 0; i < num_sources; i++) { @@ -371,8 +370,7 @@ void build_edl_timeline(struct MPContext *mpctx) "file on line %d!\n", edl_ids[i].lineno); goto out; } - sources[mpctx->num_sources].stream = s; - sources[mpctx->num_sources].demuxer = d; + sources[mpctx->num_sources] = d; mpctx->num_sources++; } @@ -385,7 +383,7 @@ void build_edl_timeline(struct MPContext *mpctx) timeline[i].start = starttime / 1e9; starttime += parts[i].duration; timeline[i].source_start = parts[i].src.start / 1e9; - timeline[i].source = sources + parts[i].id + 1; + timeline[i].source = sources[parts[i].id + 1]; } if (parts[num_parts - 1].id != -1) { timeline[num_parts].start = starttime / 1e9; diff --git a/timeline/tl_matroska.c b/timeline/tl_matroska.c index 15067644a5..46c6d80ae4 100644 --- a/timeline/tl_matroska.c +++ b/timeline/tl_matroska.c @@ -96,7 +96,7 @@ static char **find_files(const char *original_file, const char *suffix) continue; off_t size = statbuf.st_size; - entries = talloc_realloc(entries, entries, struct find_entry, + entries = talloc_realloc(tmpmem, entries, struct find_entry, num_results + 1); entries[num_results] = (struct find_entry) { name, matchlen, size }; num_results++; @@ -113,7 +113,7 @@ static char **find_files(const char *original_file, const char *suffix) } static int find_ordered_chapter_sources(struct MPContext *mpctx, - struct content_source *sources, + struct demuxer **sources, int num_sources, unsigned char uid_map[][16]) { @@ -122,7 +122,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx, if (num_sources > 1) { mp_msg(MSGT_CPLAYER, MSGL_INFO, "This file references data from " "other sources.\n"); - if (mpctx->stream->type != STREAMTYPE_FILE) { + if (mpctx->demuxer->stream->type != STREAMTYPE_FILE) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "Playback source is not a " "normal disk file. Will not search for related files.\n"); } else { @@ -152,13 +152,12 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx, } if (d->file_format == DEMUXER_TYPE_MATROSKA) { for (int i = 1; i < num_sources; i++) { - if (sources[i].demuxer) + if (sources[i]) continue; if (!memcmp(uid_map[i], d->matroska_data.segment_uid, 16)) { mp_msg(MSGT_CPLAYER, MSGL_INFO,"Match for source %d: %s\n", i, d->filename); - sources[i].stream = s; - sources[i].demuxer = d; + sources[i] = d; num_left--; goto match; } @@ -175,7 +174,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx, mp_msg(MSGT_CPLAYER, MSGL_ERR, "Failed to find ordered chapter part!\n" "There will be parts MISSING from the video!\n"); for (int i = 1, j = 1; i < num_sources; i++) - if (sources[i].demuxer) { + if (sources[i]) { sources[j] = sources[i]; memcpy(uid_map[j], uid_map[i], 16); j++; @@ -202,10 +201,9 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) // +1 because sources/uid_map[0] is original file even if all chapters // actually use other sources and need separate entries - struct content_source *sources = talloc_array_ptrtype(NULL, sources, - m->num_ordered_chapters+1); - sources[0].stream = mpctx->stream; - sources[0].demuxer = mpctx->demuxer; + struct demuxer **sources = talloc_array_ptrtype(NULL, sources, + m->num_ordered_chapters+1); + sources[0] = mpctx->demuxer; unsigned char (*uid_map)[16] = talloc_array_ptrtype(NULL, uid_map, m->num_ordered_chapters + 1); int num_sources = 1; @@ -220,7 +218,7 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) if (!memcmp(c->segment_uid, uid_map[j], 16)) goto found1; memcpy(uid_map[num_sources], c->segment_uid, 16); - sources[num_sources] = (struct content_source){}; + sources[num_sources] = NULL; num_sources++; found1: ; @@ -262,8 +260,8 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) int64_t join_diff = c->start - starttime - prev_part_offset; if (part_count == 0 || FFABS(join_diff) > opts->chapter_merge_threshold * 1000000 - || sources + j != timeline[part_count - 1].source) { - timeline[part_count].source = sources + j; + || sources[j] != timeline[part_count - 1].source) { + timeline[part_count].source = sources[j]; timeline[part_count].start = starttime / 1e9; timeline[part_count].source_start = c->start / 1e9; prev_part_offset = c->start - starttime; |