summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-12 11:10:45 +0200
committerwm4 <wm4@nowhere>2015-08-12 11:11:23 +0200
commit828881816acbfae0451e038c45e63b6784681daa (patch)
tree204b590332a95f2e5778a3e184b676e0e719ac4c /demux
parentc7329e5118d4e26d02f74fed66747392916ceae7 (diff)
downloadmpv-828881816acbfae0451e038c45e63b6784681daa.tar.bz2
mpv-828881816acbfae0451e038c45e63b6784681daa.tar.xz
demux: remove redundant demux_chapter.name field
Instead, force everyone to use the metadata struct and set a "title" field. This is only a problem for the timeline producers, which set up chapters manually. (They do this because a timeline is a separate struct.) This fixes the behavior of the chapter-metadata property, which never returned a "title" property for e.g. ordered chapters.
Diffstat (limited to 'demux')
-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
5 files changed, 11 insertions, 15 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);
}