1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-29 10:32:15 +00:00

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.
This commit is contained in:
Avi Halachmi (:avih) 2022-03-06 13:06:21 +02:00 committed by avih
parent 7f67a553f6
commit 836e87e6d4

View File

@ -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) {