From patchwork Tue Oct 28 17:08:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Wang X-Patchwork-Id: 24854 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 7183DC32CE for ; Tue, 28 Oct 2025 17:09:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 18E93607F4; Tue, 28 Oct 2025 18:09:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nErLtTwr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 39D18607E5 for ; Tue, 28 Oct 2025 18:09:05 +0100 (CET) Received: from rui-Precision-7560.local (unknown [209.216.122.90]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6220A16A7; Tue, 28 Oct 2025 18:07:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761671236; bh=c4T8Q10S0W1EbJ7ObczOLcOiIE/Idualcu82YoHQtPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nErLtTwr20e3f9Ga2dFzW+YDQPPgfiFKN13C9Ax5dXbz2Zh1aJBWjG/Y8jnEsOBcx H4vzVsbjs/gBdM1BSioupmh05gkrBqOdfOWlio8Yk7mOfdBgU6S2dbR9BWfjiV7pX4 tVtOqMiBWxI/n8pwy3zxcXAJizJNnNNYHmQ58oYY= From: Rui Wang To: libcamera-devel@lists.libcamera.org Cc: Rui Wang Subject: [PATCH v1 02/16] ipa: rkisp1: algorithms: add Denoise ISO helpers Date: Tue, 28 Oct 2025 13:08:31 -0400 Message-ID: <20251028170847.2673396-2-rui.wang@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028170847.2673396-1-rui.wang@ideasonboard.com> References: <20251028170847.2673396-1-rui.wang@ideasonboard.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" Provide reusable ISO computation and band selection helpers. computeIso derives an effective ISO value from the AGC gain (approx ISO = gain * 100). selectIsoBand searches the tuning ISO level table for the appropriate band given the current ISO, falling back to the last band if ISO exceeds all defined ranges. Signed-off-by: Rui Wang --- src/ipa/rkisp1/algorithms/denoise.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/denoise.h b/src/ipa/rkisp1/algorithms/denoise.h index 8f109db4..d97301f0 100644 --- a/src/ipa/rkisp1/algorithms/denoise.h +++ b/src/ipa/rkisp1/algorithms/denoise.h @@ -7,6 +7,8 @@ #pragma once +#include "../ipa_context.h" + #include "algorithm.h" namespace libcamera { @@ -27,8 +29,34 @@ class DenoiseBaseAlgorithm : public ipa::rkisp1::Algorithm protected: DenoiseBaseAlgorithm() = default; ~DenoiseBaseAlgorithm() = default; + + unsigned computeIso(const IPAContext &context, + const IPAFrameContext &frameContext) const; + template + int selectIsoBand(unsigned iso, const LevelContainer &levels) const; }; +inline unsigned DenoiseBaseAlgorithm::computeIso(const IPAContext &context, + const IPAFrameContext &frameContext) const +{ + double ag = frameContext.agc.gain ? frameContext.agc.gain + : context.activeState.agc.automatic.gain; + return static_cast(ag * 100.0 + 0.5); +} + +template +int DenoiseBaseAlgorithm::selectIsoBand(unsigned iso, const LevelContainer &levels) const +{ + if (levels.empty()) + return -1; + int idx = 0; + while (idx < static_cast(levels.size()) && iso > levels[idx].maxIso) + ++idx; + if (idx >= static_cast(levels.size())) + idx = static_cast(levels.size()) - 1; + return idx; +} + } /* namespace ipa::rkisp1::algorithms */ } /* namespace libcamera */