aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2024-01-09 23:41:01 +0800
committerZhao Zhili <zhilizhao@tencent.com>2024-01-12 10:49:54 +0800
commit564a15b2ee12b029b81bc20afa74ea620be7879e (patch)
tree14487fa5883e6454d28b21fce3ebd4771b2c78dd
parent38aca1dc9af24787b7ff246ddb1541ae4f03d192 (diff)
downloadffmpeg-564a15b2ee12b029b81bc20afa74ea620be7879e.tar.gz
fftools/ffplay_renderer: Add device selection support
The device can be selected by GPU name or index. For example, ffplay -hwaccel cuda \ -vulkan_params device="NVIDIA GeForce RTX 3060" \ foo.mp4 ffplay -hwaccel cuda -vulkan_params device="0" foo.mp4 Please note that select device by index only supported by hwcontext, not by libplacebo. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--fftools/ffplay_renderer.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fftools/ffplay_renderer.c b/fftools/ffplay_renderer.c
index 4e9e33b675..e1c2f07896 100644
--- a/fftools/ffplay_renderer.c
+++ b/fftools/ffplay_renderer.c
@@ -209,6 +209,16 @@ static int add_device_extension(const AVDictionary *opt,
return av_dict_set(dict, dev_ext_key, ext_list, AV_DICT_DONT_STRDUP_VAL);
}
+static const char *select_device(const AVDictionary *opt)
+{
+ const AVDictionaryEntry *entry;
+
+ entry = av_dict_get(opt, "device", NULL, 0);
+ if (entry)
+ return entry->value;
+ return NULL;
+}
+
static int create_vk_by_hwcontext(VkRenderer *renderer,
const char **ext, unsigned num_ext,
const AVDictionary *opt)
@@ -229,7 +239,7 @@ static int create_vk_by_hwcontext(VkRenderer *renderer,
}
ret = av_hwdevice_ctx_create(&ctx->hw_device_ref, AV_HWDEVICE_TYPE_VULKAN,
- NULL, dict, 0);
+ select_device(opt), dict, 0);
av_dict_free(&dict);
if (ret < 0)
return ret;
@@ -367,6 +377,7 @@ static int create_vk_by_placebo(VkRenderer *renderer,
.opt_extensions = optional_device_exts,
.num_opt_extensions = FF_ARRAY_ELEMS(optional_device_exts),
.extra_queues = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
+ .device_name = select_device(opt),
));
if (!ctx->placebo_vulkan)
return AVERROR_EXTERNAL;