From 84dd68dd2b147cef322b6788842b2166b7a9e653 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 27 Jan 2024 11:14:04 +1100 Subject: [PATCH] [host] dxgi: correct 24-bit packed output height calculation bug --- host/platform/Windows/capture/DXGI/src/pp/rgb24.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/host/platform/Windows/capture/DXGI/src/pp/rgb24.c b/host/platform/Windows/capture/DXGI/src/pp/rgb24.c index 57db422ec..700b767d5 100644 --- a/host/platform/Windows/capture/DXGI/src/pp/rgb24.c +++ b/host/platform/Windows/capture/DXGI/src/pp/rgb24.c @@ -78,11 +78,13 @@ static bool rgb24_configure(void * opaque, if (!this.pshader) { + const unsigned packedPitch = ALIGN_TO(*cols * 3, 4); + /* we must align to 64 byte boundaries to avoid breaking dmabuf import */ - this.width = ALIGN_TO((*cols * 3 + 3) / 4, 64); + this.width = ALIGN_TO(packedPitch / 4, 64); /* adjust for the aligned width */ - this.height = (((*rows * *cols) * 3 + 3) / 4) / this.width; + this.height = (*cols * *rows) / (packedPitch / 3); char sOutputWidth[6], sOutputHeight[6]; snprintf(sOutputWidth , sizeof(sOutputWidth) , "%d", this.width );