From 0a467085d265f67cc98a757037274b9d529809d6 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Sun, 24 May 2020 00:36:50 +0200 Subject: [PATCH] UI: Set 8x8 as minimum selectable resolution Since libobs internally rounds to various powers of 2 to support SSE functions, resolutions that are too low can get rounded to zero. libobs will fail to startup with a zero resolution, so if a user accidentally entered anything that rounded to zero OBS would become unusable without manual fixing by editing the profile .ini. --- UI/window-basic-main.cpp | 6 +++--- UI/window-basic-settings.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index fb011d654..5164d3519 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -3706,14 +3706,14 @@ int OBSBasic::ResetVideo() ovi.gpu_conversion = true; ovi.scale_type = GetScaleType(basicConfig); - if (ovi.base_width == 0 || ovi.base_height == 0) { + if (ovi.base_width < 8 || ovi.base_height < 8) { ovi.base_width = 1920; ovi.base_height = 1080; config_set_uint(basicConfig, "Video", "BaseCX", 1920); config_set_uint(basicConfig, "Video", "BaseCY", 1080); } - if (ovi.output_width == 0 || ovi.output_height == 0) { + if (ovi.output_width < 8 || ovi.output_height < 8) { ovi.output_width = ovi.base_width; ovi.output_height = ovi.base_height; config_set_uint(basicConfig, "Video", "OutputCX", @@ -4727,7 +4727,7 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) resizeOutput->setEnabled(!obs_video_active()); - if (width == 0 || height == 0) + if (width < 8 || height < 8) resizeOutput->setEnabled(false); scaleFilteringMenu = new QMenu(QTStr("ScaleFiltering")); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 94a4bfc6d..472467294 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -103,6 +103,11 @@ static inline bool ResTooHigh(uint32_t cx, uint32_t cy) return cx > 16384 || cy > 16384; } +static inline bool ResTooLow(uint32_t cx, uint32_t cy) +{ + return cx < 8 || cy < 8; +} + /* parses "[width]x[height]", string, i.e. 1024x768 */ static bool ConvertResText(const char *res, uint32_t &cx, uint32_t &cy) { @@ -137,7 +142,7 @@ static bool ConvertResText(const char *res, uint32_t &cx, uint32_t &cy) if (lexer_getbasetoken(lex, &token, IGNORE_WHITESPACE)) return false; - if (ResTooHigh(cx, cy)) { + if (ResTooHigh(cx, cy) || ResTooLow(cx, cy)) { cx = cy = 0; return false; }