diff options
author | wm4 <wm4@nowhere> | 2015-09-01 23:48:14 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-09-01 23:48:14 +0200 |
commit | eabc5309457d8b3926c8d81c55f4de303a76b227 (patch) | |
tree | dfaf1c4e17efc7f9194f0ddccde01fdce066427f /sub | |
parent | 62378b394a87ecc4e0115b2cf605deb3ad29f46a (diff) | |
download | mpv-eabc5309457d8b3926c8d81c55f4de303a76b227.tar.bz2 mpv-eabc5309457d8b3926c8d81c55f4de303a76b227.tar.xz |
sub: always try to use libavcodec text subtitle converter
Drop the whitelist. It's annoying to maintain. Instead, accept any
subtitle decoder. Since this code path will now also be taken by bitmap
subtitle decoders not whitelisted by sd_lavc.c, add a warning when
bitmap subtitles are decoded. (To reduce or increase potential user
confusion.)
To some degree, a whitelist is needed to distinguish text and bitmap
subtitles. FFmpeg has an API to distinguish them in a generic way to
some degree, but Libav doesn't. So we just stick with this for now.
Diffstat (limited to 'sub')
-rw-r--r-- | sub/sd_lavc_conv.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c index 09e960cde5..9da679905b 100644 --- a/sub/sd_lavc_conv.c +++ b/sub/sd_lavc_conv.c @@ -48,19 +48,9 @@ static bool supports_format(const char *format) { format = get_lavc_format(format); enum AVCodecID cid = mp_codec_to_av_codec_id(format); + AVCodec *codec = avcodec_find_decoder(cid); const AVCodecDescriptor *desc = avcodec_descriptor_get(cid); - if (!desc) - return false; - // These are known to support AVSubtitleRect->ass. - const char *whitelist[] = - {"text", "ass", "ssa", "srt", "subrip", "microdvd", "mpl2", - "jacosub", "pjs", "sami", "realtext", "subviewer", "subviewer1", - "vplayer", "webvtt", 0}; - for (int n = 0; whitelist[n]; n++) { - if (strcmp(format, whitelist[n]) == 0) - return true; - } - return false; + return codec && desc && desc->type == AVMEDIA_TYPE_SUBTITLE; } // Disable style definitions generated by the libavcodec converter. @@ -249,6 +239,8 @@ static void decode(struct sd *sd, struct demux_packet *packet) MP_ERR(sd, "Error decoding subtitle\n"); } else if (got_sub) { for (int i = 0; i < sub.num_rects; i++) { + if (sub.rects[i]->w > 0 && sub.rects[i]->h > 0) + MP_WARN(sd, "Ignoring bitmap subtitle.\n"); char *ass_line = sub.rects[i]->ass; if (!ass_line) break; |