diff options
author | wm4 <wm4@nowhere> | 2016-08-12 21:39:32 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-08-12 21:39:32 +0200 |
commit | b9ba9a898a9354b52c2154e25a0b5afcb359c5b1 (patch) | |
tree | 17c2ff9e075b26165de788e469fe40b44b2bfaba /demux/demux_mkv.c | |
parent | e2a54bb1ca319652b8c742877a313e378b24e407 (diff) | |
download | mpv-b9ba9a898a9354b52c2154e25a0b5afcb359c5b1.tar.bz2 mpv-b9ba9a898a9354b52c2154e25a0b5afcb359c5b1.tar.xz |
demux: add per-track metadata
...and ignore it. The main purpose is for retrieving per-track
replaygain tags. Other than that per-track tags are not used or accessed
by the playback core yet.
The demuxer infrastructure is still not really good with that whole
synchronization thing (at least in part due to being inherited from
mplayer's single-threaded architecture). A convoluted mechanism is
needed to transport the tags from demuxer thread to user thread. Two
factors contribute to the complexity: tags can change during playback,
and tracks (i.e. struct sh_stream) are not duplicated per thread.
In particular, we update the way replaygain tags are retrieved. We first
try to use per-track tags (common in Matroska) and global tags
(effectively formats like mp3). This part fixes #3405.
Diffstat (limited to 'demux/demux_mkv.c')
-rw-r--r-- | demux/demux_mkv.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 6f45b5a5f2..da15c0fc0f 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -93,6 +93,7 @@ typedef struct mkv_content_encoding { typedef struct mkv_track { int tnum; + uint64_t uid; char *name; struct sh_stream *stream; @@ -595,6 +596,7 @@ static void parse_trackentry(struct demuxer *demuxer, } else { MP_ERR(demuxer, "Missing track number!\n"); } + track->uid = entry->track_uid; if (entry->name) { track->name = talloc_strdup(track, entry->name); @@ -986,9 +988,6 @@ static void process_tags(demuxer_t *demuxer) for (int i = 0; i < tags->n_tag; i++) { struct ebml_tag tag = tags->tag[i]; - if (tag.targets.target_track_uid || tag.targets.target_attachment_uid) - continue; - struct mp_tags *dst = NULL; if (tag.targets.target_chapter_uid) { @@ -1009,6 +1008,19 @@ static void process_tags(demuxer_t *demuxer) break; } } + } else if (tag.targets.target_track_uid) { + for (int n = 0; n < mkv_d->num_tracks; n++) { + if (mkv_d->tracks[n]->uid == + tag.targets.target_track_uid) + { + struct sh_stream *sh = mkv_d->tracks[n]->stream; + if (sh) + dst = sh->tags; + break; + } + } + } else if (tag.targets.target_attachment_uid) { + /* ignore */ } else { dst = demuxer->metadata; } @@ -1924,9 +1936,9 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check) MP_VERBOSE(demuxer, "All headers are parsed!\n"); - process_tags(demuxer); display_create_tracks(demuxer); add_coverart(demuxer); + process_tags(demuxer); probe_first_timestamp(demuxer); if (opts->demux_mkv->probe_duration) |