aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeak3d <pfau@peak3d.de>2019-04-08 21:29:44 +0200
committerpeak3d <pfau@peak3d.de>2019-04-08 21:29:44 +0200
commitd40bebaefe8f05d7cbebbab9a1e7177198d3be60 (patch)
tree351367c1296432a4c914be7519fe75a860a3250c
parent39c78c004b6892f27186dffc322ac753cf6104de (diff)
Find 3:2 pullback when searching for matching resolutions
-rw-r--r--xbmc/windowing/Resolution.cpp50
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");
}