From 24470b351a2a1e4aeff59a9ca46ddb41f10d3354 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Wed, 27 Mar 2024 14:12:26 -0400 Subject: [PATCH] obs-ffmpeg: Set needs_compat_ver before struct version checks Because 4a8e8bb1bdf2d1efaae75893a544bddab0e2bb2a changed the NVENCAPI_STRUCT_VERSION define to rely on enc->needs_compat_ver, we must do the conditional check and define needs_compat_ver before any structs are initialized because they will check the version when doing so by calling NVENCAPI_STRUCT_VERSION internally. In this case, make sure that we define enc->needs_compat_ver before NV_ENCODE_API_FUNCTION_LIST_VER is called for NV_ENCODE_API_FUNCTION_LIST. --- plugins/obs-ffmpeg/obs-nvenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-nvenc.c b/plugins/obs-ffmpeg/obs-nvenc.c index 11138f837..9d95a2f38 100644 --- a/plugins/obs-ffmpeg/obs-nvenc.c +++ b/plugins/obs-ffmpeg/obs-nvenc.c @@ -1105,6 +1105,9 @@ static void *nvenc_create_internal(enum codec_type codec, obs_data_t *settings, enc->codec = codec; enc->first_packet = true; + if (get_nvenc_ver() == COMPATIBILITY_VERSION) { + enc->needs_compat_ver = true; + } NV_ENCODE_API_FUNCTION_LIST init = {NV_ENCODE_API_FUNCTION_LIST_VER}; switch (enc->codec) { @@ -1128,9 +1131,6 @@ static void *nvenc_create_internal(enum codec_type codec, obs_data_t *settings, if (!init_d3d11(enc, settings)) { goto fail; } - if (get_nvenc_ver() == COMPATIBILITY_VERSION) { - enc->needs_compat_ver = true; - } if (!init_session(enc)) { goto fail; }