diff options
author | Markus Pfau <pfau@peak3d.de> | 2019-04-08 22:03:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 22:03:25 +0200 |
commit | 4077a17fa001a19ddaf1ddbc60af3154b3240a88 (patch) | |
tree | 70bf4eb8c1cbbd46992e88a3ca71a7b6b62b3bc0 | |
parent | e17f937f130cfb20df80b9f7a8cb0efb24d3de10 (diff) | |
parent | d40bebaefe8f05d7cbebbab9a1e7177198d3be60 (diff) |
Merge pull request #15877 from peak3d/3_2_pullback
Find 3:2 pullback when searching for matching resolutions
-rw-r--r-- | xbmc/windowing/Resolution.cpp | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/xbmc/windowing/Resolution.cpp b/xbmc/windowing/Resolution.cpp index 8efa7d2ba9..1921dd260e 100644 --- a/xbmc/windowing/Resolution.cpp +++ b/xbmc/windowing/Resolution.cpp @@ -105,7 +105,7 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei CLog::Log(LOGDEBUG, "Trying to find exact refresh rate"); - for (const auto &mode : indexList) + for (const auto& mode : indexList) { auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); @@ -125,7 +125,7 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei CLog::Log(LOGDEBUG, "No exact whitelisted resolution matched, trying double refresh rate"); - for (const auto &mode : indexList) + for (const auto& mode : indexList) { auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); @@ -143,11 +143,33 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei } } + CLog::Log(LOGDEBUG, "No double whitelisted resolution matched, trying 3:2 pullback"); + + for (const auto& mode : indexList) + { + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are exact and have 2.5 times the refresh rate + // allow macroblock alignement / padding errors (e.g. 1080 mod16 == 8) + if (((height == info.iScreenHeight && width <= info.iScreenWidth + 8) || + (width == info.iScreenWidth && height <= info.iScreenHeight + 8)) && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + { + CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); + resolution = i; + return; + } + } + CLog::Log(LOGDEBUG, "No double refresh rate whitelisted resolution matched, trying current resolution"); if (width <= curr.iScreenWidth && height <= curr.iScreenHeight - && (MathUtils::FloatEquals(curr.fRefreshRate, fps, 0.01f) || MathUtils::FloatEquals(curr.fRefreshRate, fps * 2, 0.01f))) + && (MathUtils::FloatEquals(curr.fRefreshRate, fps, 0.01f) + || MathUtils::FloatEquals(curr.fRefreshRate, fps * 2, 0.01f) + || MathUtils::FloatEquals(curr.fRefreshRate, fps * 2.5f, 0.01f))) { CLog::Log(LOGDEBUG, "Matched current Resolution %s (%d)", curr.strMode.c_str(), resolution); return; @@ -157,7 +179,7 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei const RESOLUTION_INFO desktop_info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(CDisplaySettings::GetInstance().GetCurrentResolution()); - for (const auto &mode : indexList) + for (const auto& mode : indexList) { auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); @@ -175,7 +197,7 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei CLog::Log(LOGDEBUG, "Default resolution doesn't provide reqired refreshrate, trying default resolution with double refreshrate"); - for (const auto &mode : indexList) + for (const auto& mode : indexList) { auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); @@ -191,6 +213,24 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei } } + CLog::Log(LOGDEBUG, "Default resolution doesn't provide reqired refreshrate, trying default resolution with 3:2 pullback"); + + for (const auto& mode : indexList) + { + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are desktop resolution but have 2.5 times the refresh rate + if (info.iScreenWidth == desktop_info.iScreenWidth && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + { + CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); + resolution = i; + return; + } + } + CLog::Log(LOGDEBUG, "No whitelisted resolution matched"); } |