summaryrefslogtreecommitdiffstats
path: root/video/decode/vd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-14 19:28:07 +0100
committerJan Ekström <jeebjp@gmail.com>2017-12-15 12:32:25 +0200
commit9824a30eb164300e1c626bf897f0e9658d23b9cc (patch)
tree5c2648ac76a1e16d5344fffe8b5090c3b7bb382e /video/decode/vd_lavc.c
parentd7d670fcbf3974894429e5693e76536f0d2fe847 (diff)
downloadmpv-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.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r--video/decode/vd_lavc.c33
1 files changed, 8 insertions, 25 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