From patchwork Fri Oct 16 20:28:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28477 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 7903BC324C for ; Fri, 16 Oct 2026 20:28:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8AEF868E5A; Fri, 16 Oct 2026 22:28:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="i6caZUD0"; dkim-atps=neutral Received: from mail-vk1-xa2f.google.com (mail-vk1-xa2f.google.com [IPv6:2607:f8b0:4864:20::a2f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D072768E4F for ; Fri, 16 Oct 2026 22:28:34 +0200 (CEST) Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-5e6b5794d26so407504e0c.1 for ; Fri, 16 Oct 2026 13:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792182514; x=1792787314; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fg6Wz5w0q7kuOpsuRFpHbNzx99wbLonQMAQ8qZfNWf8=; b=i6caZUD08+u0MiN5IZsP/A75DKSl3EOreSFozXllQYDWTQ90nrobf5NWtt8SrrPyy3 ZtTydsym5yxeTu2xphTSPkhOnpJIF53kSkjfbqhC+XpcqGELsGxyIeEw2yx3rpEwesQa DPbFbW1Fr9ihG1I7PHYTPgsen05j1W3mCMsCUEAfn+2bz+BxrB6uvWHUcL73Auy3BxvG tlSv1nVgzKnDK+Cx0VVJwu9S6ndy+spN7KJ2p9jbVL/sWP3Dd2nPn9ZXcAAj6xAUOzsk CGeITJrPjHonkfYkt1FkeTJnR4Rqhu24V3SOgxt7e78LYBAszlb2BQetpDw+FJyg13MF LuXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792182514; x=1792787314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=fg6Wz5w0q7kuOpsuRFpHbNzx99wbLonQMAQ8qZfNWf8=; b=yqBT3Q6obii1IeLbZyXCIliINwwznO07AqwnaHnp/Tq+MUUbm3NgD4rC6UKW2CZPYE zlffwJFWZRiQqGT7F3IRMsK4IzXV2F6ChfPwlKWb4laGFMdEoFwwolOVwl/iusfs+XLy RM7DHFgWmsrVQvK3nJQs2ksWEiXkStYfJDey+LDwfatBkqTiO7pZAIPDWqmfQRTGfYMy Kmrj5CCjZDWX2SQMJYP6n2c/aqDdeOjCxt7W3L4R7LHkcXVjSP5ePULeHkGrDGP2mrfo bUP3DswVDmTR+XYVT09WFHPoBX0VmGKzkJA37117Ozdf8N62Tjx8mGr8umRdOh3BT9+1 zSqw== X-Gm-Message-State: AFq9FYIWqzO38rpjrs6VNfFZrhbsoRT37pb1+4W0siXA3hb5tMQ2meWB BfqK3A313ehvXxZypCkaSmFSX/6PN+V3m51tjN1W4KGPomg3MP/M7o+eE1+1QyHLPOk= X-Gm-Gg: AYBFou1WNVgGlUVo9dC3uSkS+VgfFtQC5YzCQJ8Zvc2mqS17XWIN0Tf/v1CwdQWSpnM Zbvf6XYeoRpppPnlgNuB7McIuRzGAZ9FT/F9+oPDdKEn2kn0yeDTvRtV9bgRIsu6mSiabJacETt iBKWsHXnMigZYLyDDrNxyxscg1NKpsfMNGP0oT7rlQK3+4VNDO2NZv2ySUPAJOrZVd3EYDjK5xk eR0c63kViuG86DRAqdy+IKGmDVoo7dg+GHfV1/+YhnnZ5oLX849KGjJiFMIwNiJ23Tz65QGgQ23 uRrgmdW+iSWyF5/OKDH7cWjFJJAQNpd9mYnxSV4B6OoYGgJOS8+6IVWRkTgFD857aqGFpOeHf6l yvBr8Mj0KAJruJ/KL2AV5cAXuPMwB1U0rj1I+zsqLiLwywc+IrOwoLgUaEyUCS4bwGjFwSpQgcG JqWa6Xsz4R5D+wF5LTWVqfyr39IzKRUQBCD7ayJypzVPpXRbdrUQ3e+d/+R5MfD3RG1pEi+KxCF CPH3dN7kdwtR0XyYsiCHeCGpBb8geKd54BXhm4= X-Received: by 2002:a05:6122:d2a:b0:5e2:b1d5:2d6f with SMTP id 71dfb90a1353d-5ea980ce974mr1400061e0c.20.1792182513686; Fri, 16 Oct 2026 13:28:33 -0700 (PDT) Received: from localhost ([2601:19c:4a00:897d:3391:ed89:5571:41a8]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ea9b2fef79sm2422500e0c.1.2026.10.16.13.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 13:28:33 -0700 (PDT) From: Ray Strode To: libcamera-devel@lists.libcamera.org Cc: kieran.bingham@ideasonboard.com, bod.linux@nxsw.ie, laurent.pinchart@ideasonboard.com Subject: [PATCH v3 05/11] software-isp: Expose the configured image crop Date: Fri, 16 Oct 2026 16:28:12 -0400 Message-ID: <20261016202818.1405645-6-halfline@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261016202818.1405645-1-halfline@gmail.com> References: <20261015223604.311616-1-halfline@gmail.com> <20261016202818.1405645-1-halfline@gmail.com> 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" From: Ray Strode This commit makes the image region selected by the debayer available to the pipeline handler, so ScalerCrop metadata can describe the processed output. The CPU and EGL backends crop input differently. CPU debayering keeps an output-sized window whose origin depends on the Bayer pattern and output channel order, while EGL scales a centered crop to fill the output. The pipeline currently cannot retrieve the region chosen by either backend. Each backend returns its actual configured image crop in input-buffer coordinates. The EGL crop is retained before statistics alignment, so the returned rectangle describes the image rather than its metering samples. Signed-off-by: Ray Strode --- .../libcamera/internal/software_isp/software_isp.h | 1 + src/libcamera/software_isp/debayer.cpp | 11 +++++++++++ src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/debayer_cpu.h | 4 ++++ src/libcamera/software_isp/debayer_egl.cpp | 3 ++- src/libcamera/software_isp/debayer_egl.h | 2 ++ src/libcamera/software_isp/software_isp.cpp | 14 ++++++++++++++ 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index b8b24bb1..1e54a4fe 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -67,6 +67,7 @@ public: const std::vector> &outputCfgs, const ipa::softisp::IPAConfigInfo &configInfo, ControlInfoMap *ipaControls); + Rectangle inputCrop() const; int exportBuffers(const Stream *stream, unsigned int count, std::vector> *buffers); diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index a4854e51..14b09937 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -66,6 +66,17 @@ Debayer::~Debayer() } /** + * \fn Rectangle Debayer::inputCrop() const + * \brief Retrieve the input region visible in the configured output + * + * The rectangle is in input-buffer coordinates and excludes any additional + * alignment performed for statistics sampling. It is valid after a successful + * configure() call. + * + * \return The configured image crop + */ + +/** * \fn int Debayer::configure() * \brief Configure the debayer object according to the passed in parameters * \param[in] inputCfg The input configuration diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 55685226..7ffdaea1 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -53,6 +53,7 @@ public: virtual void stop() {} virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; + virtual Rectangle inputCrop() const = 0; virtual const SharedFD &getStatsFD() = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 2c88c9e1..1e037a79 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -46,6 +46,10 @@ public: int start() override; void stop() override; SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override; + Rectangle inputCrop() const override + { + return window_.translatedBy({ static_cast(xShift_), 0 }); + } const SharedFD &getStatsFD() override { return stats_->getStatsFD(); } private: diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 9f3dc752..cd9ad888 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -327,7 +327,8 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, * The GPU scales the visible sensor crop to outputSize_. Statistics * consume the original input buffer, so use sensor coordinates here. */ - stats_->setWindow(debayerCrop(inputCfg.size, nativeOutputSize_, outputSize_)); + inputCrop_ = debayerCrop(inputCfg.size, nativeOutputSize_, outputSize_); + stats_->setWindow(inputCrop_); inputBufferCount_ = inputCfg.bufferCount; outputBufferCount_ = outputCfg.bufferCount; diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 52b8aa07..5a4cd2d8 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -60,6 +60,7 @@ public: const SharedFD &getStatsFD() override { return stats_->getStatsFD(); } SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override; + Rectangle inputCrop() const override { return inputCrop_; } private: static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); @@ -111,6 +112,7 @@ private: GLint contrastExpUniformDataIn_; Size nativeOutputSize_; + Rectangle inputCrop_; std::unique_ptr stats_; eGL egl_; uint32_t width_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index a4097605..c0c55fbf 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -306,6 +306,20 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, } /** + * \brief Retrieve the input region used to produce the configured output + * + * The rectangle is expressed in input-buffer pixels, before any Bayer + * alignment applied by the statistics engine. It is valid after configure() + * succeeds and describes the selected CPU or EGL debayer backend. + * + * \return The configured input crop + */ +Rectangle SoftwareIsp::inputCrop() const +{ + return debayer_->inputCrop(); +} + +/** * \brief Export the buffers from the Software ISP * \param[in] stream Output stream exporting the buffers * \param[in] count Number of buffers to allocate