[v1] software_isp: debayer_egl: Consider border for scaling
diff mbox series

Message ID 20260611191513.595489-1-robert.mader@collabora.com
State New
Headers show
Series
  • [v1] software_isp: debayer_egl: Consider border for scaling
Related show

Commit Message

Robert Mader June 11, 2026, 7:15 p.m. UTC
The debayer algorithm produces a sligtly smaller output resolution
compared to the input one, using a border at the edges depending on the
pattern. This wasn't considered when scaling to the final output buffer
size, resulting in garbage pixels at the right - or in case or 90 degree
rotated sensors - the bottom of the image.

Use the correct algorithm output size instead - the maximum output
buffer size.

Fixes: f520b29fe (libcamera: software_isp: debayer_egl: Add an eGL Debayer class)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
---
 src/libcamera/software_isp/debayer_egl.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 8e52b45ae..f857e0271 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -404,8 +404,9 @@  void DebayerEGL::setShaderVariableValues(const DebayerParams &params)
 	 * Scale input to output size, keeping the aspect ratio and preferring
 	 * cropping over black bars.
 	 */
-	GLfloat scale = std::max((GLfloat)window_.width / width_,
-				 (GLfloat)window_.height / height_);
+	Size maxInputSize = sizes(inputPixelFormat_, {width_, height_}).max;
+	GLfloat scale = std::max((GLfloat)window_.width / maxInputSize.width,
+				 (GLfloat)window_.height / maxInputSize.height);
 	GLfloat trans = -(1.0f - scale);
 	GLfloat projMatrix[] = {
 		scale, 0, 0, 0,