mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 01:52:19 +00:00
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
This commit is contained in:
parent
65e9139764
commit
0bf0efd6d3
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user