obs-ffmpeg: Set needs_compat_ver before struct version checks

Because 4a8e8bb1bd 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.
This commit is contained in:
Ryan Foster 2024-03-27 14:12:26 -04:00
parent 8c9e4c2822
commit 24470b351a

View file

@ -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;
}