diff options
author | wm4 <wm4@nowhere> | 2013-06-02 19:38:57 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-03 22:40:06 +0200 |
commit | 74e3ac8bf885dad5b6d33fc8d2c714dd91c18b47 (patch) | |
tree | bc5048232edef3ba2cb26b5cf39634dc35bf6b29 /sub/sd_lavc_conv.c | |
parent | e42a7714133bc0dd0b786af45749ea894f32e6a7 (diff) | |
download | mpv-74e3ac8bf885dad5b6d33fc8d2c714dd91c18b47.tar.bz2 mpv-74e3ac8bf885dad5b6d33fc8d2c714dd91c18b47.tar.xz |
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.
Diffstat (limited to 'sub/sd_lavc_conv.c')
-rw-r--r-- | sub/sd_lavc_conv.c | 18 |
1 files changed, 17 insertions, 1 deletions
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 <libavutil/intreadwrite.h> #include <libavutil/common.h> +#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) |