From b9ba9a898a9354b52c2154e25a0b5afcb359c5b1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Aug 2016 21:39:32 +0200 Subject: 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. --- demux/demux_mkv.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'demux/demux_mkv.c') 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) -- cgit v1.2.3