From 9824a30eb164300e1c626bf897f0e9658d23b9cc Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 14 Dec 2017 19:28:07 +0100 Subject: 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. --- video/decode/vd_lavc.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'video/decode/vd_lavc.c') 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 -- cgit v1.2.3