Merge branch 'vapoursynth' into feature

This commit is contained in:
arch1t3cht 2023-11-03 02:27:20 +01:00
commit fd753c58a5

View file

@ -32,6 +32,13 @@
#ifdef _WIN32
#define VSSCRIPT_SO "vsscript.dll"
#ifdef _WIN64
#define VS_INSTALL_REGKEY L"Software\\VapourSynth"
#else
#define VS_INSTALL_REGKEY L"Software\\VapourSynth-32"
#endif
#else
#ifdef __APPLE__
#define VSSCRIPT_SO "libvapoursynth-script.dylib"
@ -61,11 +68,39 @@ VapourSynthWrapper::VapourSynthWrapper() {
// VSScript assumes it's only loaded once, so unlike AVS we can't unload it when the refcount reaches zero
if (!vs_loaded) {
#ifdef _WIN32
std::wstring vsscriptDLLpath = L"";
HKEY hKey;
LONG lRes = RegOpenKeyEx(HKEY_CURRENT_USER, VS_INSTALL_REGKEY, 0, KEY_READ, &hKey);
if (lRes != ERROR_SUCCESS) {
lRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, VS_INSTALL_REGKEY, 0, KEY_READ, &hKey);
}
if (lRes == ERROR_SUCCESS) {
WCHAR szBuffer[512];
DWORD dwBufferSize = sizeof(szBuffer);
ULONG nError;
nError = RegQueryValueEx(hKey, L"VSScriptDLL", 0, nullptr, (LPBYTE)szBuffer, &dwBufferSize);
RegCloseKey(hKey);
if (nError == ERROR_SUCCESS)
vsscriptDLLpath = szBuffer;
}
if (vsscriptDLLpath.length()) {
hLib = LoadLibraryW(vsscriptDLLpath.c_str());
}
if (!hLib) {
#define CONCATENATE(x, y) x ## y
#define _Lstr(x) CONCATENATE(L, x)
hLib = LoadLibraryW(_Lstr(VSSCRIPT_SO));
hLib = LoadLibraryW(_Lstr(VSSCRIPT_SO));
#undef _Lstr
#undef CONCATENATE
}
#else
hLib = dlopen(VSSCRIPT_SO, DLOPEN_FLAGS);
#endif