summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-08-06 16:24:19 +0100
committersr55 <[email protected]>2019-08-12 18:41:57 +0100
commit69b1a484539ec62b65cfc6320b39ca44a6e5627d (patch)
treecbdab42ee79c7b0c802ec331d77cefa9d345a7ba
parent8b09ede89942b630a0fbdee77d914059d590c379 (diff)
NVEnc: Check SDK version and disable feature if driver is too old. Prevent re-checks by caching result.
-rw-r--r--libhb/nvenc_common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libhb/nvenc_common.c b/libhb/nvenc_common.c
index 15d839e2d..538ea4f39 100644
--- a/libhb/nvenc_common.c
+++ b/libhb/nvenc_common.c
@@ -35,6 +35,7 @@ int hb_nvenc_h265_available()
#endif
}
+static int isAvailable = -1;
int hb_check_nvenc_available()
{
if (is_hardware_disabled())
@@ -42,6 +43,10 @@ int hb_check_nvenc_available()
return 0;
}
+ if (isAvailable != -1){
+ return isAvailable;
+ }
+
#if HB_PROJECT_FEATURE_NVENC
uint32_t nvenc_ver;
void *context = NULL;
@@ -49,15 +54,25 @@ int hb_check_nvenc_available()
int loadErr = nvenc_load_functions(&nvenc_dl, context);
if (loadErr < 0) {
+ isAvailable = 0;
return 0;
}
NVENCSTATUS apiErr = nvenc_dl->NvEncodeAPIGetMaxSupportedVersion(&nvenc_ver);
if (apiErr != NV_ENC_SUCCESS)
{
+ isAvailable = 0;
+ return 0;
+ }
+
+ hb_log("Nvenc version %d.%d\n", nvenc_ver >> 4, nvenc_ver & 0xf);
+ if ((NVENCAPI_MAJOR_VERSION << 4 | NVENCAPI_MINOR_VERSION) > nvenc_ver) {
+ hb_log("NVENC version not supported. Disabling feature.");
+ isAvailable = 0;
return 0;
}
+ isAvailable = 1;
return 1;
#else
return 0;