mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
62378b394a
commit
eabc530945
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue