mirror of
https://github.com/mpv-player/mpv
synced 2024-12-11 09:25:56 +00:00
Fix ordered chapter pruning of redundant timeline parts
Code that was supposed to merge two timeline parts if the second one started exactly where the first one stopped didn't work because it mixed timestamps in different units (I had changed the units of some variables after originally writing that code but forgotten to update it). As a result of the bug there were unnecessary part switches, but it was unlikely to cause any serious problems.
This commit is contained in:
parent
59ffaa41f0
commit
f48840f820
13
mplayer.c
13
mplayer.c
@ -2782,6 +2782,7 @@ static void build_ordered_chapter_timeline(struct MPContext *mpctx)
|
||||
uint64_t missing_time = 0;
|
||||
int part_count = 0;
|
||||
int num_chapters = 0;
|
||||
uint64_t prev_part_offset;
|
||||
for (int i = 0; i < m->num_ordered_chapters; i++) {
|
||||
struct matroska_chapter *c = m->ordered_chapters + i;
|
||||
|
||||
@ -2795,15 +2796,17 @@ static void build_ordered_chapter_timeline(struct MPContext *mpctx)
|
||||
found2:;
|
||||
chapters[num_chapters].start = starttime / 1000.;
|
||||
chapters[num_chapters].name = talloc_strdup(chapters, c->name);
|
||||
// Only add a separate part if the time or file actually changes
|
||||
uint64_t prev_end = !part_count ? 0 : starttime
|
||||
- timeline[part_count - 1].start
|
||||
+ timeline[part_count - 1].source_start;
|
||||
if (part_count == 0 || c->start != prev_end
|
||||
/* Only add a separate part if the time or file actually changes.
|
||||
* Matroska files have chapter divisions that are redundant from
|
||||
* timeline point of view because the same chapter structure is used
|
||||
* both to specify the timeline and for normal chapter information.
|
||||
* Removing a missing inserted external chapter can also cause this. */
|
||||
if (part_count == 0 || c->start != starttime + prev_part_offset
|
||||
|| sources + j != timeline[part_count - 1].source) {
|
||||
timeline[part_count].source = sources + j;
|
||||
timeline[part_count].start = chapters[num_chapters].start;
|
||||
timeline[part_count].source_start = c->start / 1000.;
|
||||
prev_part_offset = c->start - starttime;
|
||||
part_count++;
|
||||
}
|
||||
starttime += c->end - c->start;
|
||||
|
Loading…
Reference in New Issue
Block a user