From patchwork Mon Jun 15 18:11:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26889 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5258AC328C for ; Mon, 15 Jun 2026 18:11:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A1CF623F4; Mon, 15 Jun 2026 20:11:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="aQFoeK1i"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5354B623CB for ; Mon, 15 Jun 2026 20:11:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1781547108; cv=none; d=zohomail.com; s=zohoarc; b=Pq1RdWdBYQFMAG3GEvd6lZQbrFWPsgLGluuGflu9+nBK67ia4Gn4HYfbMclPY2Qcda5Y6jURv8dGtRw/y7ImY1lvpWB30sjfVgCvLdQA6PkdvCbXvMm1Ihs1pKs/Zs0ChGBd/YKbkSJx1c3R+WTQ/6x1iMe1BRAmwBAMtpUZ2Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781547108; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZAXU9uCi5AhIgS/BEUBc0Q/GfamaiF2SGNVgJikydzU=; b=ELze0CHi+BZjzPp1a7N+2pNB2N/nqV3Cazq61aOE3GGLD4QkU06wpFnwbefB2e1oCqVpo6MZEBuac8E/GNGACTUWA8x2KdZYhhBF+aj3i0VNEE7qt2km/7u+E5BgdlRcxgxO8tge5/wyCAcYif4XbNsQlI2f+BWZ4Noxs9xAl3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1781547108; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=ZAXU9uCi5AhIgS/BEUBc0Q/GfamaiF2SGNVgJikydzU=; b=aQFoeK1iZX80xAtGOx6FTyw5CV+PiKiFz+fAAPyFP6fKDljbrrwa38ZNDDXhNpEm a65h6Qa85zyBh99qc2nF/fBxZu6+0vIR/DoDEl/PpQ1f2PoqfOXRiRvb7j3Z9WX2mSP FUyZEpjh2+aiw1uG3Xnd5hmV3E1O/Pyar40+ljcA= Received: by mx.zohomail.com with SMTPS id 1781547106989329.82710404195325; Mon, 15 Jun 2026 11:11:46 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v2] software_isp: debayer_egl: Consider border for scaling Date: Mon, 15 Jun 2026 20:11:27 +0200 Message-ID: <20260615181127.97555-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 native (i.e. unscaled) output size instead - the maximum output buffer size. While on it use outputSize_ for better readability and adopt the scaling comment slightly. Fixes: f520b29fe (libcamera: software_isp: debayer_egl: Add an eGL Debayer class) Signed-off-by: Robert Mader --- Changes in V2: - Instead of recomputing the native output size, save it in configure() - Use outputSize_ instead of window_ for better readability - Small changes to comment and commit message --- src/libcamera/software_isp/debayer_egl.cpp | 10 ++++++---- src/libcamera/software_isp/debayer_egl.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index fd8de3942..521316657 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -337,6 +337,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, outputPixelFormat_ = outputCfg.pixelFormat; outputSize_ = outputCfg.size; + nativeOutputSize_ = outSizeRange.max; window_.x = ((inputCfg.size.width - outputCfg.size.width) / 2) & ~(inputConfig_.patternSize.width - 1); @@ -408,11 +409,12 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms) 1.0f / (height_ - 1) }; GLfloat Stride = (GLfloat)width_ / (shaderStridePixels_ / bytesPerPixel_); /* - * Scale input to output size, keeping the aspect ratio and preferring - * cropping over black bars. + * Scale the output size from the native size the algorithm produces for + * the input size. Keep the aspect ratio and prefer cropping over black + * bars. */ - GLfloat scale = std::max((GLfloat)window_.width / width_, - (GLfloat)window_.height / height_); + GLfloat scale = std::max((GLfloat)outputSize_.width / nativeOutputSize_.width, + (GLfloat)outputSize_.height / nativeOutputSize_.height); GLfloat trans = -(1.0f - scale); GLfloat projMatrix[] = { scale, 0, 0, 0, diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 943410fdd..fbd5430e4 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -102,6 +102,7 @@ private: /* Contrast */ GLint contrastExpUniformDataIn_; + Size nativeOutputSize_; Rectangle window_; std::unique_ptr stats_; eGL egl_;