mirror of
https://github.com/mpv-player/mpv
synced 2025-01-09 01:36:25 +01:00
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.
This commit is contained in:
parent
e42a771413
commit
74e3ac8bf8
12
configure
vendored
12
configure
vendored
@ -2684,6 +2684,17 @@ else
|
||||
fi
|
||||
|
||||
|
||||
echocheck "libavcodec AV_CODEC_PROP_TEXT_SUB API"
|
||||
_avcodec_has_text_flag_api=no
|
||||
statement_check libavcodec/avcodec.h 'int x = AV_CODEC_PROP_TEXT_SUB' && _avcodec_has_text_flag_api=yes
|
||||
if test "$_avcodec_has_text_flag_api" = yes ; then
|
||||
def_avcodec_has_text_flag_api='#define HAVE_AV_CODEC_PROP_TEXT_SUB 1'
|
||||
else
|
||||
def_avcodec_has_text_flag_api='#define HAVE_AV_CODEC_PROP_TEXT_SUB 0'
|
||||
fi
|
||||
echores "$_avcodec_has_text_flag_api"
|
||||
|
||||
|
||||
echocheck "libavutil QP API"
|
||||
_avutil_has_qp_api=no
|
||||
statement_check libavutil/frame.h 'av_frame_get_qp_table(NULL, NULL, NULL)' && _avutil_has_qp_api=yes
|
||||
@ -3268,6 +3279,7 @@ $def_zlib
|
||||
|
||||
$def_avutil_has_refcounting
|
||||
$def_avutil_has_qp_api
|
||||
$def_avcodec_has_text_flag_api
|
||||
$def_libpostproc
|
||||
$def_libavdevice
|
||||
$def_libavfilter
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user