2.6.5a: Fix PlayerData, auto-disable DivaMovie if DXVA-HW is available (unless forced - fixes random black backgrounds)

This commit is contained in:
nastys
2021-10-07 23:10:40 +02:00
parent e8c2ac672a
commit 66db5deb2b
5 changed files with 198 additions and 182 deletions
@@ -10,8 +10,9 @@
#include <mfapi.h>
#include <mferror.h>
#include <mftransform.h>
#include <SimpleIni.h>
bool forceSoftwareDecoding = false, debug = false;
bool forceSoftwareDecoding = false, forceHardwareDecoding = false, debug = false;
IDirect3DDeviceManager9* deviceManager;
@@ -146,11 +147,21 @@ VTABLE_HOOK(HRESULT, IMFTransform, ProcessMessage, MFT_MESSAGE_TYPE eMessage, UL
if (SUCCEEDED(result))
INSTALL_VTABLE_HOOK(This, ProcessOutput, 25);
}
else
else if (!forceHardwareDecoding && eMessage == MFT_MESSAGE_SET_D3D_MANAGER && result == 0)
{
static bool warn = false;
if(!warn) MessageBoxW(0, L"Your system supports DXVA hardware decoding.\nIt is highly recommended to disable DivaMovie (in Plugins and Patches).", L"DivaMovie", MB_ICONWARNING);
warn = true;
if (!warn)
{
MessageBoxW(0, L"Your system supports DXVA hardware decoding.\nDivaMovie will be disabled.\n\nIt is highly recommended to restart the game now.", L"DivaMovie", MB_ICONWARNING);
CSimpleIniW ini_reader;
ini_reader.SetUnicode(false);
ini_reader.LoadFile(MASTER_CONFIG_FILE);
ini_reader.SetValue(L"plugins", L"DivaMovie.dva", L"0");
ini_reader.SaveFile(MASTER_CONFIG_FILE);
warn = true;
}
}
return result;
}
@@ -183,6 +194,7 @@ HOOK(HRESULT, DXVA2CreateDirect3DDeviceManager, PROC_ADDRESS("dxva2.dll", "DXVA2
void loadConfig() {
forceSoftwareDecoding = GetPrivateProfileIntW(L"general", L"force_software_decoding", 0, CONFIG_FILE) > 0 ? true : false;
forceHardwareDecoding = GetPrivateProfileIntW(L"general", L"force_hardware_decoding", 0, CONFIG_FILE) > 0 ? true : false;
debug = GetPrivateProfileIntW(L"general", L"debug", 0, CONFIG_FILE) > 0 ? true : false;
}
@@ -200,6 +212,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
PluginConfig::PluginConfigOption config[] = {
{ PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"force_software_decoding", L"general", CONFIG_FILE, L"Force Software Decoding", L"Use software decoding even on systems that support DXVA hardware decoding.", false } },
{ PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"force_hardware_decoding", L"general", CONFIG_FILE, L"Force Hardware Decoding", L"Do not disable DivaMovie on systems that support DXVA hardware decoding.", false } },
{ PluginConfig::CONFIG_BOOLEAN, new PluginConfig::PluginConfigBooleanData{ L"debug", L"general", CONFIG_FILE, L"Debug", L"Enable PRINT (possibly at the cost of performance).", false } },
};
@@ -210,7 +223,7 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
{
return L"DivaMovie Plugin by Skyth\n\nDivaMovie enables movies on systems that does not support DXVA hardware decoding.";
return L"DivaMovie Plugin by Skyth\n\nDivaMovie enables movies on systems that do not support DXVA hardware decoding.";
}
extern "C" __declspec(dllexport) PluginConfig::PluginConfigArray GetPluginOptions(void)