From 3608adf4c39325848087dd912700df5c7c0cd9d7 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Fri, 13 Sep 2024 11:55:31 +0200 Subject: [PATCH] nvdec: show gfxcard name in plugin description --- libheif/plugins/decoder_nvdec.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libheif/plugins/decoder_nvdec.cc b/libheif/plugins/decoder_nvdec.cc index 478430089f..c78851c361 100644 --- a/libheif/plugins/decoder_nvdec.cc +++ b/libheif/plugins/decoder_nvdec.cc @@ -48,17 +48,31 @@ static char plugin_name[MAX_PLUGIN_NAME_LENGTH]; static const char *nvdec_plugin_name() { - snprintf(plugin_name, MAX_PLUGIN_NAME_LENGTH, "NVIDIA Video Decoder (Hardware)"); - - // make sure that the string is null-terminated - plugin_name[MAX_PLUGIN_NAME_LENGTH - 1] = 0; - return plugin_name; } static void nvdec_init_plugin() { cuInit(0); + + CUdevice cuDevice = 0; + CUresult result; + result = cuDeviceGet(&cuDevice, 0); + if (result != CUDA_SUCCESS) + { + return; + } + + char szDeviceName[50]; + result = cuDeviceGetName(szDeviceName, sizeof(szDeviceName), cuDevice); + if (result != CUDA_SUCCESS) { + return; + } + + snprintf(plugin_name, MAX_PLUGIN_NAME_LENGTH, "NVIDIA Video Decoder (%s)", szDeviceName); + + // make sure that the string is null-terminated + plugin_name[MAX_PLUGIN_NAME_LENGTH - 1] = 0; } static void nvdec_deinit_plugin()