From 2316a5e64d0180047ce20d83fed9ab00f0f056a9 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 27 Jan 2024 10:11:01 +1100 Subject: [PATCH] [host] dxgi: ensure 24-bit packed output is properly aligned --- host/platform/Windows/capture/DXGI/src/pp/rgb24.c | 7 +++++-- 1 file changed, 5 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 0d797cef9..ae6ed87eb 100644 --- a/host/platform/Windows/capture/DXGI/src/pp/rgb24.c +++ b/host/platform/Windows/capture/DXGI/src/pp/rgb24.c @@ -78,8 +78,11 @@ static bool rgb24_configure(void * opaque, if (!this.pshader) { - this.width = (*cols * 3 + 3) / 4; - this.height = *rows; + /* we must align to 64 byte boundaries to avoid breaking dmabuf import */ + this.width = ALIGN_TO((*cols * 3 + 3) / 4, 64); + + /* adjust for the aligned width */ + this.height = ((*rows * *cols) + this.width - 1) / this.width; char sOutputWidth[6], sOutputHeight[6]; snprintf(sOutputWidth , sizeof(sOutputWidth) , "%d", this.width );