diff options
author | wm4 <wm4@nowhere> | 2017-12-14 19:28:07 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2017-12-15 12:32:25 +0200 |
commit | 9824a30eb164300e1c626bf897f0e9658d23b9cc (patch) | |
tree | 5c2648ac76a1e16d5344fffe8b5090c3b7bb382e | |
parent | d7d670fcbf3974894429e5693e76536f0d2fe847 (diff) | |
download | mpv-9824a30eb164300e1c626bf897f0e9658d23b9cc.tar.bz2 mpv-9824a30eb164300e1c626bf897f0e9658d23b9cc.tar.xz |
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.
-rw-r--r-- | video/decode/vd_lavc.c | 33 | ||||
-rw-r--r-- | wscript | 2 |
2 files changed, 9 insertions, 26 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 87964d6fdc..f67fab5284 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -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 @@ -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', |