From 650c8faaafb6c8564a34822938e04eb12408e7e3 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Fri, 3 Jul 2015 10:26:18 -0700 Subject: [PATCH] UI: Use default scaled res. of 1280x720 or equiv. Originally this value defaulted to 1.5 downscaling, but on very high resolution displays this would cause the default to be above 1280x720, which is not ideal for streaming/recording due to the CPU usage requirements. Instead, it will now find the closest resolution with a pixel count equivalent to or closest below 1280x720, and use that instead. --- obs/window-basic-main.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index e62d10e8c..d21f84132 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -531,6 +531,22 @@ bool OBSBasic::InitService() return true; } +static const double scaled_vals[] = +{ + 1.0, + 1.25, + (1.0/0.75), + 1.5, + (1.0/0.6), + 1.75, + 2.0, + 2.25, + 2.5, + 2.75, + 3.0, + 0.0 +}; + bool OBSBasic::InitBasicConfigDefaults() { vector monitors; @@ -618,10 +634,20 @@ bool OBSBasic::InitBasicConfigDefaults() config_set_default_uint (basicConfig, "Video", "BaseCX", cx); config_set_default_uint (basicConfig, "Video", "BaseCY", cy); - cx = cx * 10 / 15; - cy = cy * 10 / 15; - config_set_default_uint (basicConfig, "Video", "OutputCX", cx); - config_set_default_uint (basicConfig, "Video", "OutputCY", cy); + int i = 0; + uint32_t scale_cx = cx; + uint32_t scale_cy = cy; + + /* use a default scaled resolution that has a pixel count no higher + * than 1280x720 */ + while (((scale_cx * scale_cy) > (1280 * 720)) && scaled_vals[i] > 0.0) { + double scale = scaled_vals[i++]; + scale_cx = uint32_t(double(cx) / scale); + scale_cy = uint32_t(double(cy) / scale); + } + + config_set_default_uint (basicConfig, "Video", "OutputCX", scale_cx); + config_set_default_uint (basicConfig, "Video", "OutputCY", scale_cy); config_set_default_uint (basicConfig, "Video", "FPSType", 0); config_set_default_string(basicConfig, "Video", "FPSCommon", "30");