From patchwork Fri Sep 19 09:40:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24415 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 BBBD6C328C for ; Fri, 19 Sep 2025 09:41:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B7AA6B5AA; Fri, 19 Sep 2025 11:41:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hdma1xc5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 729546B5A7 for ; Fri, 19 Sep 2025 11:41:11 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:4d54:eab8:98ca:163b]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 10BD8842; Fri, 19 Sep 2025 11:39:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758274791; bh=wuVocP0PxGUEMxd0Ahj37h1AcvbUWZUDWSbY5rD3MIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hdma1xc575D0jBjuGHw712k7NuyYm/K6JsneWFuPyN+PDSNnWvTsovRcElaouQdI0 znynJm8prYhFb9s7tl2dpturAjNYvbevEGB4LUSUuFdMVc57zeXkNxhJDX9hB9fASN nhz3r1e6fH6dHl2feX9EgZirQtGR9p1e1/x28vhU= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Isaac Scott , Daniel Scally , Paul Elder Subject: [PATCH v5 06/19] libipa: exposure_mode_helper: Remove unnecessary clamp calls Date: Fri, 19 Sep 2025 11:40:21 +0200 Message-ID: <20250919094041.183031-7-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250919094041.183031-1-stefan.klug@ideasonboard.com> References: <20250919094041.183031-1-stefan.klug@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" Except for the first iteration of the loop and in the case of an empty gains_ vector, the values were run through clamp two times which is unnecessary. Remove that by clamping the initial value. Signed-off-by: Stefan Klug Reviewed-by: Isaac Scott Reviewed-by: Daniel Scally Reviewed-by: Paul Elder --- Changes in v4: - Collected tag Changes in v3: - Collected tags --- src/ipa/libipa/exposure_mode_helper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index e806731047cf..f2de1d8e4229 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -197,8 +197,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const return { minExposureTime_, minGain_, exposure / (minExposureTime_ * minGain_) }; utils::Duration exposureTime; - double stageGain = 1.0; - double lastStageGain = 1.0; + double stageGain = clampGain(1.0); + double lastStageGain = stageGain; double gain; for (unsigned int stage = 0; stage < gains_.size(); stage++) { @@ -215,7 +215,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const /* Clamp the gain to lastStageGain and regulate exposureTime. */ if (stageExposureTime * lastStageGain >= exposure) { - exposureTime = clampExposureTime(exposure / clampGain(lastStageGain)); + exposureTime = clampExposureTime(exposure / lastStageGain); gain = clampGain(exposure / exposureTime); return { exposureTime, gain, exposure / (exposureTime * gain) }; @@ -223,7 +223,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const /* Clamp the exposureTime to stageExposureTime and regulate gain. */ if (stageExposureTime * stageGain >= exposure) { - exposureTime = clampExposureTime(stageExposureTime); + exposureTime = stageExposureTime; gain = clampGain(exposure / exposureTime); return { exposureTime, gain, exposure / (exposureTime * gain) }; @@ -239,7 +239,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const * stages to use then the default stageGain of 1.0 is used so that * exposure time is maxed before gain is touched at all. */ - exposureTime = clampExposureTime(exposure / clampGain(stageGain)); + exposureTime = clampExposureTime(exposure / stageGain); gain = clampGain(exposure / exposureTime); return { exposureTime, gain, exposure / (exposureTime * gain) };