From eabc5309457d8b3926c8d81c55f4de303a76b227 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 1 Sep 2015 23:48:14 +0200 Subject: 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. --- sub/sd_lavc_conv.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'sub') 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; -- cgit v1.2.3