diff options
author | wm4 <wm4@nowhere> | 2016-03-03 18:48:56 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-03-03 18:48:56 +0100 |
commit | 3f60548df472d01387784601526e378d8ffb4659 (patch) | |
tree | 6bcec60b8c057111607e5b4f6f9f4d822a0e3982 /player | |
parent | a6f8a6977ec59d314b617780c60e374b585ebaca (diff) | |
download | mpv-3f60548df472d01387784601526e378d8ffb4659.tar.bz2 mpv-3f60548df472d01387784601526e378d8ffb4659.tar.xz |
sub: pass all attachments to the subtitle decoder
Commit 8d4a179c made subtitle decoders pick up fonts strictly from the
same source file (i.e. the same demuxer).
It breaks some fucked up use-case, and 2 people on this earth complained
about the change because of this. Add it back.
This copies all attached fonts on each subtitle init. I considered
converting attachments to use refcounting, but it'd probably be much
more complex.
Since it's slightly harder to get a list of active demuxers with
duplicate removed, the prev_demuxer variable serves as a hack to achieve
almost the same thing, except in weird corner cases. (In which fonts
could be added twice.)
Diffstat (limited to 'player')
-rw-r--r-- | player/sub.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/player/sub.c b/player/sub.c index 6892ac935b..426e31bc7a 100644 --- a/player/sub.c +++ b/player/sub.c @@ -129,6 +129,29 @@ bool update_subtitles(struct MPContext *mpctx, double video_pts) return ok; } +static struct attachment_list *get_all_attachments(struct MPContext *mpctx) +{ + struct attachment_list *list = talloc_zero(NULL, struct attachment_list); + struct demuxer *prev_demuxer = NULL; + for (int n = 0; n < mpctx->num_tracks; n++) { + struct track *t = mpctx->tracks[n]; + if (!t->demuxer || prev_demuxer == t->demuxer) + continue; + prev_demuxer = t->demuxer; + for (int i = 0; i < t->demuxer->num_attachments; i++) { + struct demux_attachment *att = &t->demuxer->attachments[i]; + struct demux_attachment copy = { + .name = talloc_strdup(list, att->name), + .type = talloc_strdup(list, att->type), + .data = talloc_memdup(list, att->data, att->data_size), + .data_size = att->data_size, + }; + MP_TARRAY_APPEND(list, list->entries, list->num_entries, copy); + } + } + return list; +} + static bool init_subdec(struct MPContext *mpctx, struct track *track) { assert(!track->d_sub); @@ -136,7 +159,8 @@ static bool init_subdec(struct MPContext *mpctx, struct track *track) if (!track->demuxer || !track->stream) return false; - track->d_sub = sub_create(mpctx->global, track->demuxer, track->stream); + track->d_sub = sub_create(mpctx->global, track->stream, + get_all_attachments(mpctx)); if (!track->d_sub) return false; |