History

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.

Timo Rothenpieler committed 3 years ago

Commit ee650391 parent fc016fd1 file · +10 −1Browse files

Unified · Split

libavfilter/vf_libplacebo.c+10−1
@@ -252,6 +252,7 @@ static int init_vulkan(AVFilterContext *avctx) · 251 unmodified lines
252252 {
253253 int err = 0;
254254 LibplaceboContext *s = avctx->priv;
255+ const AVHWDeviceContext *avhwctx;
255256 const AVVulkanDeviceContext *hwctx;
256257 uint8_t *buf = NULL;
257258 size_t buf_len;
@@ -261,7 +262,15 @@ static int init_vulkan(AVFilterContext *avctx) · 3 unmodified lines
261262 return AVERROR(EINVAL);
262263 }
263264
264− hwctx = ((AVHWDeviceContext*) avctx->hw_device_ctx->data)->hwctx;
265+ avhwctx = avctx->hw_device_ctx->data;
266+
267+ if (avhwctx->type != AV_HWDEVICE_TYPE_VULKAN) {
268+ av_log(s, AV_LOG_ERROR, "Expected vulkan hwdevice for vf_libplacebo, got %s.\n",
269+ av_hwdevice_get_type_name(avhwctx->type));
270+ return AVERROR(EINVAL);
271+ }
272+
273+ hwctx = avhwctx->hwctx;
265274
266275 /* Import libavfilter vulkan context into libplacebo */
267276 s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t