From patchwork Thu Oct 29 12:58:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28675 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 409D7C3261 for ; Thu, 29 Oct 2026 12:59:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7AAEE690D5; Thu, 29 Oct 2026 13:59:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qZL2W/rU"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B0916909F for ; Thu, 29 Oct 2026 13:58:49 +0100 (CET) Received: from pb-laptop.local (185.221.143.99.nat.pool.zt.hu [185.221.143.99]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 975DE929 for ; Thu, 29 Oct 2026 13:56:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1793278596; bh=t5Fn66Sg3G8aZ3trFDCe6yWlv+vXx+w4nD9C16q5PgA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qZL2W/rUmb+1LFU786UsET+35GF7YNBGT5D4KQwemRxsVeNSrwO41LLwdCItwrLKL C1D2A4RoaSCNRExUw3F6ttiSDi2Qscqk1u6yw3u+LbEbuy18Lva7LDnM7nTiBKa9Kt daHoi8p6WImv//DdC4DyhE5bHbpaCGMb8q5+JNwY= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v5 09/24] ipa: libipa: exposure_mode_helper: Remove `lastStageGain` Date: Thu, 29 Oct 2026 13:58:29 +0100 Message-ID: <20261029125844.170324-10-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261029125844.170324-1-barnabas.pocze@ideasonboard.com> References: <20261029125844.170324-1-barnabas.pocze@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" There is no need for a separate variable, `stageGain` already contains the previous stage's gain at the beginning of the loop. Moving the assignment to a later point removes the need for a separate variable. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/ipa/libipa/exposure_mode_helper.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 4ec31f54c3..4076d6f385 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -241,12 +241,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const } double stageGain = clampGain(1.0); - double lastStageGain = stageGain; for (const auto &stage : stages_) { utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime, &quantGain); - stageGain = clampGain(stage.gain); /* * We perform the clamping on both exposure time and gain in @@ -256,9 +254,9 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const * the stage limits are initialised. */ - /* Clamp the gain to lastStageGain and regulate exposureTime. */ - if (stageExposureTime * lastStageGain >= exposure) { - exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain); + /* Clamp the gain to that of the last stage and regulate exposure time. */ + if (stageExposureTime * stageGain >= exposure) { + exposureTime = clampExposureTime(exposure / stageGain, &quantGain); gain = clampGain(exposure / exposureTime, &quantGain2); quantGain *= quantGain2; @@ -266,7 +264,9 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const exposure / (exposureTime * gain * quantGain) }; } - /* Clamp the exposureTime to stageExposureTime and regulate gain. */ + /* Clamp the exposure time to stageExposureTime and regulate gain. */ + stageGain = clampGain(stage.gain); + if (stageExposureTime * stageGain >= exposure) { exposureTime = stageExposureTime; gain = clampGain(exposure / exposureTime, &quantGain2); @@ -275,8 +275,6 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const return { exposureTime, gain, quantGain, exposure / (exposureTime * gain * quantGain) }; } - - lastStageGain = stageGain; } /*