summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-17 01:57:42 +0100
committerwm4 <wm4@nowhere>2019-12-17 01:57:42 +0100
commit0bf0efd6d37d02b2ec7f5fecd5b662d60fc64acf (patch)
tree74a692024a8286b7a8b2cb8b5f5c1cac2837bf07
parent65e9139764ec5192b4d7d31758a07e4e16933d0c (diff)
downloadmpv-0bf0efd6d37d02b2ec7f5fecd5b662d60fc64acf.tar.bz2
mpv-0bf0efd6d37d02b2ec7f5fecd5b662d60fc64acf.tar.xz
demux_edl: fix reusing segment source files
EDL files can have multiple segments taken from the same source file. In this case, the source file is supposed to be opened only once. This stopped working, and it created a new demuxer instance for every single segment entry. This made it slow and made it use much more memory than needed. This was because it tried to iterate over the array of source files, but the array count (num_parts) was only set to a non-0 value later. Fix this by maintaining the count correctly. In addition, the actual code for checking whether a source can be reused (in open_source()) regressed and stopped working correctly. d->stream could be NULL. Use demuxer.filename instead; I'm not entirely sure whether this is always correct, but fortunately we have a distributed almost-AI driven test suite (called "users") which will probably find and report such cases. Probably broke with commit a09396ee60 or something close, but didn't check closer. Fixes: #7267
-rw-r--r--demux/demux_edl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/demux/demux_edl.c b/demux/demux_edl.c
index aa650a383f..1ac912888f 100644
--- a/demux/demux_edl.c
+++ b/demux/demux_edl.c
@@ -198,7 +198,7 @@ static struct demuxer *open_source(struct timeline *root,
{
for (int n = 0; n < tl->num_parts; n++) {
struct demuxer *d = tl->parts[n].source;
- if (d && strcmp(d->stream->url, filename) == 0)
+ if (d && d->filename && strcmp(d->filename, filename) == 0)
return d;
}
struct demuxer_params params = {
@@ -366,6 +366,8 @@ static struct timeline_par *build_timeline(struct timeline *root,
if (source && !tl->track_layout && part->is_layout)
tl->track_layout = source;
+
+ tl->num_parts++;
}
if (!tl->track_layout) {
@@ -385,7 +387,7 @@ static struct timeline_par *build_timeline(struct timeline *root,
if (!root->meta)
root->meta = tl->track_layout;
- tl->num_parts = parts->num_parts;
+ assert(tl->num_parts == parts->num_parts);
return tl;
error: