vd_lavc: use libavcodec metadata for hardware decoder wrappers

This removes the need to keep an explicit list and to attempt to parse
codec names. Needs latest FFmpeg git.
This commit is contained in:
wm4 2017-12-14 19:28:07 +01:00 committed by Jan Ekström
parent d7d670fcbf
commit 9824a30eb1
2 changed files with 9 additions and 26 deletions

View File

@ -207,16 +207,6 @@ static const char *const hwdec_autoprobe_order[] = {
0
};
static const char *const hwdec_wrappers[] = {
"mmal",
"mediacodec",
"crystalhd",
"v4l2m2m",
"cuvid",
"rkmpp",
NULL
};
static int hwdec_compare(const void *p1, const void *p2)
{
struct hwdec_info *h1 = (void *)p1;
@ -238,12 +228,6 @@ static int hwdec_compare(const void *p1, const void *p2)
return h1->rank > h2->rank ? 1 :-1;
}
static bool test_decoder_suffix(const char *name, const char *suffix)
{
bstr bname = bstr0(name);
return bstr_eatend0(&bname, suffix) && bstr_eatend0(&bname, "_");
}
// (This takes care of some bookkeeping too, like setting info.name)
static void add_hwdec_item(struct hwdec_info **infos, int *num_infos,
struct hwdec_info info)
@ -273,6 +257,8 @@ static void add_all_hwdec_methods(struct hwdec_info **infos, int *num_infos)
codec = av_codec_next(codec);
if (!codec)
break;
if (codec->type != AVMEDIA_TYPE_VIDEO || !av_codec_is_decoder(codec))
continue;
struct hwdec_info info_template = {
.pix_fmt = AV_PIX_FMT_NONE,
@ -280,15 +266,12 @@ static void add_all_hwdec_methods(struct hwdec_info **infos, int *num_infos)
};
const char *wrapper = NULL;
for (int n = 0; hwdec_wrappers[n]; n++) {
if (test_decoder_suffix(codec->name, hwdec_wrappers[n])) {
wrapper = hwdec_wrappers[n];
// Different lavc/mpv names.
if (strcmp(wrapper, "mmal") == 0)
wrapper = "rpi";
break;
}
}
if (codec->capabilities & (AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_HYBRID))
wrapper = codec->wrapper_name;
// Different lavc/mpv names.
if (wrapper && strcmp(wrapper, "mmal") == 0)
wrapper = "rpi";
// A decoder can provide multiple methods. In particular, hwaccels
// provide various methods (e.g. native h264 with vaapi & d3d11), but

View File

@ -413,7 +413,7 @@ iconv support use --disable-iconv.",
ffmpeg_pkg_config_checks = [
'libavutil', '>= 56.0.100',
'libavcodec', '>= 58.6.102',
'libavcodec', '>= 58.7.100',
'libavformat', '>= 58.0.102',
'libswscale', '>= 5.0.101',
'libavfilter', '>= 7.0.101',