From patchwork Mon Nov 2 10:15:55 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: 28744 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 AA037C3302 for ; Mon, 2 Nov 2026 10:16:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B9686A047; Mon, 2 Nov 2026 11:16:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f2Jrchzz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 065B4691FF for ; Mon, 2 Nov 2026 11:16:17 +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 B49D924BD; Mon, 2 Nov 2026 11:14:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1793614440; bh=1wh7JAKnykEzCRMlVjjgeoN52xsMlM6t1wsWHqoo/Y4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f2JrchzzOLsv8SHmp4kI/rtHKv2XFw+Rv7n3FU8FKUZWsY4gCrbZYxl6R6g8IsWsW RjN8own+6dIBcfnVdq9LMPrTRbBHvdmvs9v/N5nSlwFE6VWS804mPfUJ9JQ9ZlVFm1 LJTY2q9C7UefNzfiOmZT3kTehTQPIk9BoWgYceb0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi Subject: [PATCH v6 09/24] ipa: libipa: exposure_mode_helper: Remove `lastStageGain` Date: Mon, 2 Nov 2026 11:15:55 +0100 Message-ID: <20261102101610.877390-10-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261102101610.877390-1-barnabas.pocze@ideasonboard.com> References: <20261102101610.877390-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; } /*