From 07c8c16bef24b878a77eee7f99c5cd201a01c63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Thu, 25 Jun 2026 18:03:14 +0200 Subject: [PATCH] vd_lavc: allow disabling codec hwdec per-device --- video/decode/vd_lavc.c | 8 ++++++++ video/hwdec.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index ff6a22a52f..a662992025 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -589,6 +589,14 @@ static void select_and_set_hwdec(struct mp_filter *vd) const struct hwcontext_fns *fns = hwdec_get_hwcontext_fns(hwdec->lavc_device); + if (fns && fns->is_codec_allowed && + !fns->is_codec_allowed(ctx->hwdec_dev, hwdec->codec->id)) + { + MP_WARN(vd, "Hardware decoding of '%s' is disabled on this " + "device.\n", codec); + av_buffer_unref(&ctx->hwdec_dev); + continue; + } if (fns && fns->is_emulated && fns->is_emulated(ctx->hwdec_dev)) { if (hwdec_auto) { MP_VERBOSE(vd, "Not using emulated API.\n"); diff --git a/video/hwdec.h b/video/hwdec.h index e7734e5d7e..6b62eb81af 100644 --- a/video/hwdec.h +++ b/video/hwdec.h @@ -109,6 +109,9 @@ struct hwcontext_fns { struct hwcontext_create_dev_params *params); // Return whether this is using some sort of sub-optimal emulation layer. bool (*is_emulated)(struct AVBufferRef *hw_device_ctx); + // Return whether hardware decoding of the given codec is allowed on this + // device. If NULL, all codecs are assumed to be allowed. + bool (*is_codec_allowed)(struct AVBufferRef *hw_device_ctx, int av_codec_id); }; // The parameter is of type enum AVHWDeviceType (as in int to avoid extensive