From 74e3ac8bf885dad5b6d33fc8d2c714dd91c18b47 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 2 Jun 2013 19:38:57 +0200 Subject: sd_lavc_conv: add hack if AV_CODEC_PROP_TEXT_SUB is not available Otherwise this could happily open decoders for image subtitles or even audio/video decoders. AV_CODEC_PROP_TEXT_SUB is a preprocessor symbol, but it's still better to detect this properly instead of using #ifdef, because these flags might as well be changed into enums sooner or later. --- sub/sd_lavc_conv.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sub') diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c index e45e743499..744aa83440 100644 --- a/sub/sd_lavc_conv.c +++ b/sub/sd_lavc_conv.c @@ -22,6 +22,8 @@ #include #include +#include "config.h" + #include "talloc.h" #include "core/mp_msg.h" #include "core/av_common.h" @@ -35,8 +37,22 @@ static bool supports_format(const char *format) { enum AVCodecID cid = mp_codec_to_av_codec_id(format); const AVCodecDescriptor *desc = avcodec_descriptor_get(cid); + if (!desc) + return false; +#if HAVE_AV_CODEC_PROP_TEXT_SUB // These are documented to support AVSubtitleRect->ass. - return desc && (desc->props & AV_CODEC_PROP_TEXT_SUB); + return desc->props & AV_CODEC_PROP_TEXT_SUB; +#else + const char *whitelist[] = + {"text", "ass", "ssa", "mov_text", "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; +#endif } static int init(struct sd *sd) -- cgit v1.2.3