summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-02 17:20:04 +0100
committerwm4 <wm4@nowhere>2014-11-02 17:29:41 +0100
commit969757baa0af99d905a9b8c99f0c92efa4e0fb33 (patch)
tree2db51b2e3bc89dce550fc1c9fbf31c7471a41fce /demux/demux.c
parent1cebd16350229d2ab1441f5061079ce9240fb22f (diff)
downloadmpv-969757baa0af99d905a9b8c99f0c92efa4e0fb33.tar.bz2
mpv-969757baa0af99d905a9b8c99f0c92efa4e0fb33.tar.xz
player: always use demux_chapter
Instead of defining a separate data structure in the core. For some odd reason, demux_chapter exported the chapter time in nano-seconds. Change that to the usual timestamps (rename the field to make any code relying on this to fail compilation), and also remove the unused chapter end time.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 48b1babe35..d4206228d5 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1076,9 +1076,9 @@ static int chapter_compare(const void *p1, const void *p2)
struct demux_chapter *c1 = (void *)p1;
struct demux_chapter *c2 = (void *)p2;
- if (c1->start > c2->start)
+ if (c1->pts > c2->pts)
return 1;
- else if (c1->start < c2->start)
+ else if (c1->pts < c2->pts)
return -1;
return c1->original_index > c2->original_index ? 1 :-1; // never equal
}
@@ -1090,12 +1090,11 @@ static void demuxer_sort_chapters(demuxer_t *demuxer)
}
int demuxer_add_chapter(demuxer_t *demuxer, struct bstr name,
- uint64_t start, uint64_t end, uint64_t demuxer_id)
+ double pts, uint64_t demuxer_id)
{
struct demux_chapter new = {
.original_index = demuxer->num_chapters,
- .start = start,
- .end = end,
+ .pts = pts,
.name = name.len ? bstrdup0(demuxer, name) : NULL,
.metadata = talloc_zero(demuxer, struct mp_tags),
.demuxer_id = demuxer_id,
@@ -1309,3 +1308,14 @@ void demux_unpause(demuxer_t *demuxer)
pthread_cond_signal(&in->wakeup);
pthread_mutex_unlock(&in->lock);
}
+
+struct demux_chapter *demux_copy_chapter_data(struct demux_chapter *c, int num)
+{
+ struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num);
+ for (int n = 0; n < num; n++) {
+ new[n] = c[n];
+ new[n].name = talloc_strdup(new, new[n].name);
+ new[n].metadata = mp_tags_dup(new, new[n].metadata);
+ }
+ return new;
+}