summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-05-22 02:22:18 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-05-22 18:25:54 +0300
commitf48840f8204d754026350c046b5b0ab03a9c8b80 (patch)
treef6f8a7df2c1c3432412db8a8f2ff7406a4d54b09
parent59ffaa41f0390914584f44293d5aed0a34e85b87 (diff)
downloadmpv-f48840f8204d754026350c046b5b0ab03a9c8b80.tar.bz2
mpv-f48840f8204d754026350c046b5b0ab03a9c8b80.tar.xz
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.
-rw-r--r--mplayer.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mplayer.c b/mplayer.c
index 259407d027..a09333f662 100644
--- a/mplayer.c
+++ b/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;