summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2022-03-06 13:06:21 +0200
committeravih <avih@users.noreply.github.com>2022-03-07 01:05:20 +0200
commit836e87e6d4c7c69d5ef458d93ddf8c7bc96d5142 (patch)
treeed30fa382a73900d233aa0012b0d67eabc3cce96
parent7f67a553f68a9df87997fdcb6484ffd243ca2162 (diff)
downloadmpv-836e87e6d4c7c69d5ef458d93ddf8c7bc96d5142.tar.bz2
mpv-836e87e6d4c7c69d5ef458d93ddf8c7bc96d5142.tar.xz
hwdec: warn on unsupported hwdec option value
Previously, when mpv was invoked with unsupported hwdec value, such as --hwdec=foobar, there was no indication that it doesn't exist. The reason it's not validated during options parsing is that the name is only evaluated when selecting hwdec for actual decoding, by matching it against runtime list of names from ffmpeg. Additionally, when selecting hwdec for decoding, matching the name came after filtering by codec, hence overall never-matched-name did not necessarily indicate it's unsupported (doesn't exist at all). Now we check the name before filtering by codec, and when done, warn if no hwdec with that name exists at all. This means that an unsupported name will now generate such warning whenever we try to choose a hwdec, i.e. possibly more than once. It's much better than no notification at all, and arguably adequate for a sort of configuration error (linked ffmpeg has no such hwdec name) which we don't validate during option parsing.
-rw-r--r--video/decode/vd_lavc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 69769e3178..20efb26dd3 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -465,6 +465,7 @@ static void select_and_set_hwdec(struct mp_filter *vd)
MP_VERBOSE(vd, "Not trying to use hardware decoding: codec %s is not "
"on whitelist.\n", codec);
} else {
+ bool hwdec_name_supported = false; // relevant only if !hwdec_auto
struct hwdec_info *hwdecs = NULL;
int num_hwdecs = 0;
add_all_hwdec_methods(&hwdecs, &num_hwdecs);
@@ -472,13 +473,14 @@ static void select_and_set_hwdec(struct mp_filter *vd)
for (int n = 0; n < num_hwdecs; n++) {
struct hwdec_info *hwdec = &hwdecs[n];
- const char *hw_codec = mp_codec_from_av_codec_id(hwdec->codec->id);
- if (!hw_codec || strcmp(hw_codec, codec) != 0)
- continue;
-
if (!hwdec_auto && !(bstr_equals0(opt, hwdec->method_name) ||
bstr_equals0(opt, hwdec->name)))
continue;
+ hwdec_name_supported = true;
+
+ const char *hw_codec = mp_codec_from_av_codec_id(hwdec->codec->id);
+ if (!hw_codec || strcmp(hw_codec, codec) != 0)
+ continue;
if (hwdec_auto_safe && !(hwdec->flags & HWDEC_FLAG_WHITELIST))
continue;
@@ -522,8 +524,11 @@ static void select_and_set_hwdec(struct mp_filter *vd)
talloc_free(hwdecs);
- if (!ctx->use_hwdec)
+ if (!ctx->use_hwdec) {
+ if (!hwdec_auto && !hwdec_name_supported)
+ MP_WARN(vd, "Unsupported hwdec: %s\n", ctx->opts->hwdec_api);
MP_VERBOSE(vd, "No hardware decoding available for this codec.\n");
+ }
}
if (ctx->use_hwdec) {