summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demux/demux.c5
-rw-r--r--demux/demux.h1
-rw-r--r--demux/demux_cue.c5
-rw-r--r--demux/demux_edl.c5
-rw-r--r--demux/demux_mkv_timeline.c10
-rw-r--r--player/command.c6
-rw-r--r--player/playloop.c3
7 files changed, 13 insertions, 22 deletions
diff --git a/demux/demux.c b/demux/demux.c
index fedc533926..4c4a399c9f 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1271,7 +1271,6 @@ int demuxer_add_chapter(demuxer_t *demuxer, char *name,
struct demux_chapter new = {
.original_index = demuxer->num_chapters,
.pts = pts,
- .name = talloc_strdup(demuxer, name),
.metadata = talloc_zero(demuxer, struct mp_tags),
.demuxer_id = demuxer_id,
};
@@ -1511,9 +1510,7 @@ 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);
- if (new[n].metadata)
- new[n].metadata = mp_tags_dup(new, new[n].metadata);
+ new[n].metadata = mp_tags_dup(new, new[n].metadata);
}
return new;
}
diff --git a/demux/demux.h b/demux/demux.h
index 710073d26c..7e4dcea5d0 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -113,7 +113,6 @@ typedef struct demux_chapter
{
int original_index;
double pts;
- char *name;
struct mp_tags *metadata;
uint64_t demuxer_id; // for mapping to internal demuxer data structures
} demux_chapter_t;
diff --git a/demux/demux_cue.c b/demux/demux_cue.c
index cbe06ca5cf..ed3d3d83f3 100644
--- a/demux/demux_cue.c
+++ b/demux/demux_cue.c
@@ -224,9 +224,10 @@ static void build_timeline(struct timeline *tl)
};
chapters[i] = (struct demux_chapter) {
.pts = timeline[i].start,
- // might want to include other metadata here
- .name = talloc_strdup(chapters, tracks[i].title),
+ .metadata = talloc_zero(tl, struct mp_tags),
};
+ // might want to include other metadata here
+ mp_tags_set_str(chapters[i].metadata, "title", tracks[i].title);
starttime += duration;
}
diff --git a/demux/demux_edl.c b/demux/demux_edl.c
index d46f96e025..9ba0307487 100644
--- a/demux/demux_edl.c
+++ b/demux/demux_edl.c
@@ -167,7 +167,7 @@ static void copy_chapters(struct demux_chapter **chapters, int *num_chapters,
if (time >= start && time <= start + len) {
struct demux_chapter ch = {
.pts = dest_offset + time - start,
- .name = talloc_strdup(*chapters, src->chapters[n].name),
+ .metadata = mp_tags_dup(*chapters, src->chapters[n].metadata),
};
MP_TARRAY_APPEND(NULL, *chapters, *num_chapters, ch);
}
@@ -238,8 +238,9 @@ static void build_timeline(struct timeline *tl, struct tl_parts *parts)
// Add a chapter between each file.
struct demux_chapter ch = {
.pts = starttime,
- .name = talloc_strdup(tl, part->filename),
+ .metadata = talloc_zero(tl, struct mp_tags),
};
+ mp_tags_set_str(ch.metadata, "title", part->filename);
MP_TARRAY_APPEND(tl, tl->chapters, tl->num_chapters, ch);
// Also copy the source file's chapters for the relevant parts
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index e1491b631d..a874f9c6a7 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -372,7 +372,8 @@ static void build_timeline_loop(struct tl_ctx *ctx,
break; // malformed files can cause this to happen.
chapters[i].pts = ctx->start_time / 1e9;
- chapters[i].name = talloc_strdup(chapters, c->name);
+ chapters[i].metadata = talloc_zero(chapters, struct mp_tags);
+ mp_tags_set_str(chapters[i].metadata, "title", c->name);
}
/* If we're the source or it's a non-ordered edition reference,
@@ -556,9 +557,6 @@ void build_ordered_chapter_timeline(struct timeline *tl)
struct demux_chapter *chapters =
talloc_zero_array(tl, struct demux_chapter, m->num_ordered_chapters);
- // Stupid hack, because fuck everything.
- for (int n = 0; n < m->num_ordered_chapters; n++)
- chapters[n].pts = -1;
ctx->timeline = talloc_array_ptrtype(tl, ctx->timeline, 0);
ctx->num_chapters = m->num_ordered_chapters;
@@ -569,9 +567,9 @@ void build_ordered_chapter_timeline(struct timeline *tl)
};
build_timeline_loop(ctx, chapters, &info, 0);
- // Fuck everything (2): filter out all "unset" chapters.
+ // Fuck everything: filter out all "unset" chapters.
for (int n = m->num_ordered_chapters - 1; n >= 0; n--) {
- if (chapters[n].pts == -1)
+ if (!chapters[n].metadata)
MP_TARRAY_REMOVE_AT(chapters, m->num_ordered_chapters, n);
}
diff --git a/player/command.c b/player/command.c
index c64427f930..a74cde2b23 100644
--- a/player/command.c
+++ b/player/command.c
@@ -805,7 +805,6 @@ static int get_chapter_entry(int item, int action, void *arg, void *ctx)
};
int r = m_property_read_sub(props, action, arg);
- talloc_free(name);
return r;
}
@@ -1178,11 +1177,8 @@ static int mp_property_chapter_metadata(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
int chapter = get_current_chapter(mpctx);
- if (chapter < 0 || chapter >= mpctx->num_chapters)
+ if (chapter < 0)
return M_PROPERTY_UNAVAILABLE;
- if (!mpctx->chapters[chapter].metadata)
- return M_PROPERTY_UNAVAILABLE;
-
return tag_property(action, arg, mpctx->chapters[chapter].metadata);
}
diff --git a/player/playloop.c b/player/playloop.c
index 31652e3636..b361f7c11c 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -474,7 +474,6 @@ char *chapter_display_name(struct MPContext *mpctx, int chapter)
dname = talloc_asprintf(NULL, "(%d) of %d", chapter + 1,
chapter_count);
}
- talloc_free(name);
return dname;
}
@@ -483,7 +482,7 @@ char *chapter_name(struct MPContext *mpctx, int chapter)
{
if (chapter < 0 || chapter >= mpctx->num_chapters)
return NULL;
- return talloc_strdup(NULL, mpctx->chapters[chapter].name);
+ return mp_tags_get_str(mpctx->chapters[chapter].metadata, "title");
}
// returns the start of the chapter in seconds (NOPTS if unavailable)