summaryrefslogtreecommitdiff
path: root/libavfilter/vf_libplacebo.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2022-12-04 15:22:13 +0100
committerTimo Rothenpieler <timo@rothenpieler.org>2022-12-04 15:22:13 +0100
commitee650398ec29861a1fe5c8d1a905cc340e82378d (patch)
treeb825f19878b680f2379becd8f72b8d1be62e4af5 /libavfilter/vf_libplacebo.c
parentfc016fd665903b61bcf37c5d23897fe951f5d8e6 (diff)
downloadffmpeg-ee650398ec29861a1fe5c8d1a905cc340e82378d.tar.gz
avfilter/vf_libplacebo: ensure filter hwdevice is a vulkan one
Before this, the filter blindly casts to AVVulkanDeviceContext and passes invalid values to libplacebo if it's not.
Diffstat (limited to 'libavfilter/vf_libplacebo.c')
-rw-r--r--libavfilter/vf_libplacebo.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 3678b60b7d..d3c62d12a4 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -252,6 +252,7 @@ static int init_vulkan(AVFilterContext *avctx)
{
int err = 0;
LibplaceboContext *s = avctx->priv;
+ const AVHWDeviceContext *avhwctx;
const AVVulkanDeviceContext *hwctx;
uint8_t *buf = NULL;
size_t buf_len;
@@ -261,7 +262,15 @@ static int init_vulkan(AVFilterContext *avctx)
return AVERROR(EINVAL);
}
- hwctx = ((AVHWDeviceContext*) avctx->hw_device_ctx->data)->hwctx;
+ avhwctx = avctx->hw_device_ctx->data;
+
+ if (avhwctx->type != AV_HWDEVICE_TYPE_VULKAN) {
+ av_log(s, AV_LOG_ERROR, "Expected vulkan hwdevice for vf_libplacebo, got %s.\n",
+ av_hwdevice_get_type_name(avhwctx->type));
+ return AVERROR(EINVAL);
+ }
+
+ hwctx = avhwctx->hwctx;
/* Import libavfilter vulkan context into libplacebo */
s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(