From patchwork Tue Nov 25 00:08:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Wang X-Patchwork-Id: 25168 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 1AC4BC3257 for ; Tue, 25 Nov 2025 00:09:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 95C2060A8A; Tue, 25 Nov 2025 01:09:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ekordYg9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0FCA4608CF for ; Tue, 25 Nov 2025 01:09:01 +0100 (CET) Received: from rui-Precision-7560.local (unknown [IPv6:2607:fea8:935b:7220:cb34:a7b8:53d:5466]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 068FAC75; Tue, 25 Nov 2025 01:06:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1764029212; bh=c9z/FY4uG8M2ilmBF1G6vgwpSHEjI/ddJW8v9kh5h70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekordYg9aV6bWrcVLgxrrDWpz0yBF3AUScMXBKa4sTO+rRucl6SLxYvE7U72VvBdQ YnguZVHlsMf0HhjaTjdcCXiVRnboDkQHwWGFTLPbjGZrpizRCma57WVN83rXeE+78Q He2pQIiS5o5lsy/S1CvV6nNZAMsVy9HVW/IHFU6U= From: Rui Wang To: libcamera-devel@lists.libcamera.org Cc: Rui Wang Subject: [PATCH v1 01/11] ipa: rkisp1: algorithms: Add exposure index computation helpers Date: Mon, 24 Nov 2025 19:08:38 -0500 Message-ID: <20251125000848.4103786-2-rui.wang@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251125000848.4103786-1-rui.wang@ideasonboard.com> References: <20251125000848.4103786-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" Introduce computeExposureIndex() to derive an exposure index value from the AGC gain (approximately exposureIndex = gain * 100), and selectExposureIndexBand() to search through a container of exposure index levels and select the appropriate tuning band for the current exposure index. These helpers provide reusable functionality for exposure-index-banded tuning in denoising algorithms, enabling more precise algorithm configuration based on lighting conditions. Signed-off-by: Rui Wang --- src/ipa/rkisp1/algorithms/denoise.h | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/denoise.h diff --git a/src/ipa/rkisp1/algorithms/denoise.h b/src/ipa/rkisp1/algorithms/denoise.h new file mode 100644 index 00000000..8907dc4e --- /dev/null +++ b/src/ipa/rkisp1/algorithms/denoise.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Ideas On Board + * + * RkISP1 Denoising Algorithms Base Class + */ + +#pragma once + +#include "../ipa_context.h" + +#include "algorithm.h" + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +class DenoiseBaseAlgorithm : public ipa::rkisp1::Algorithm +{ +protected: + DenoiseBaseAlgorithm() = default; + ~DenoiseBaseAlgorithm() = default; + + virtual uint32_t computeExposureIndex(const IPAContext &context, + const IPAFrameContext &frameContext) const; + template + uint32_t selectExposureIndexBand(unsigned exposureIndex, + const LevelContainer &levels) const; +}; + +inline unsigned DenoiseBaseAlgorithm::computeExposureIndex(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 +uint32_t DenoiseBaseAlgorithm::selectExposureIndexBand(unsigned exposureIndex, + const LevelContainer &levels) const +{ + if (levels.empty()) + return -1; + uint32_t idx = 0; + while (idx < static_cast(levels.size()) && exposureIndex > levels[idx].maxExposureIndex) + ++idx; + if (idx >= static_cast(levels.size())) + idx = static_cast(levels.size()) - 1; + return idx; +} + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */