From 60834a5719d8b61e462c359a594232c70e67e869 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 4 May 2022 12:23:20 +1000 Subject: [PATCH] [host] xcb/pipewire/nfbc: use `min` and correct inverted logic --- host/platform/Linux/capture/XCB/src/xcb.c | 5 +++-- host/platform/Linux/capture/pipewire/src/pipewire.c | 4 ++-- host/platform/Windows/capture/NVFBC/src/nvfbc.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/host/platform/Linux/capture/XCB/src/xcb.c b/host/platform/Linux/capture/XCB/src/xcb.c index 37344857..13303cf0 100644 --- a/host/platform/Linux/capture/XCB/src/xcb.c +++ b/host/platform/Linux/capture/XCB/src/xcb.c @@ -20,6 +20,7 @@ #include "interface/capture.h" #include "interface/platform.h" +#include "common/util.h" #include "common/option.h" #include "common/debug.h" #include "common/event.h" @@ -273,8 +274,8 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame, frame->screenWidth = this->width; frame->screenHeight = this->height; frame->frameWidth = this->width; - frame->frameHeight = maxHeight > this->height ? this->height : maxHeight; - frame->truncated = maxHeight > this->height; + frame->frameHeight = min(maxHeight, this->height); + frame->truncated = maxHeight < this->height; frame->pitch = this->width * 4; frame->stride = this->width; frame->format = CAPTURE_FMT_BGRA; diff --git a/host/platform/Linux/capture/pipewire/src/pipewire.c b/host/platform/Linux/capture/pipewire/src/pipewire.c index 4b9a1876..2e1c9730 100644 --- a/host/platform/Linux/capture/pipewire/src/pipewire.c +++ b/host/platform/Linux/capture/pipewire/src/pipewire.c @@ -428,8 +428,8 @@ static CaptureResult pipewire_waitFrame(CaptureFrame * frame, frame->screenWidth = this->width; frame->screenHeight = this->height; frame->frameWidth = this->width; - frame->frameHeight = maxHeight > this->height ? this->height : maxHeight; - frame->truncated = maxHeight > this->height; + frame->frameHeight = min(maxHeight, this->height); + frame->truncated = maxHeight < this->height; frame->pitch = this->width * bpp; frame->stride = this->width; frame->rotation = CAPTURE_ROT_0; diff --git a/host/platform/Windows/capture/NVFBC/src/nvfbc.c b/host/platform/Windows/capture/NVFBC/src/nvfbc.c index 73d63d0d..904637e2 100644 --- a/host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -23,6 +23,7 @@ #include "common/windebug.h" #include "windows/mousehook.h" #include "windows/force_compose.h" +#include "common/util.h" #include "common/array.h" #include "common/option.h" #include "common/framebuffer.h" @@ -560,8 +561,7 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame, frame->screenWidth = this->grabWidth; frame->screenHeight = this->grabHeight; frame->frameWidth = this->grabWidth; - frame->frameHeight = maxHeight < this->grabHeight ? - maxHeight : this->grabHeight; + frame->frameHeight = min(maxHeight, this->grabHeight); frame->truncated = maxHeight < this->grabHeight; frame->pitch = this->shmStride * 4; frame->stride = this->shmStride;