[{"id":35707,"web_url":"https://patchwork.libcamera.org/comment/35707/","msgid":"<175706897863.1787083.18235128373581372732@neptunite.rasen.tech>","date":"2025-09-05T10:42:58","subject":"Re: [PATCH v3 06/19] libipa: exposure_mode_helper: Remove\n\tunnecessary clamp calls","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-08-15 19:29:26)\n> Except for the first iteration of the loop and in the case of an empty\n> gains_ vector, the values were run through clamp two times which is\n> unnecessary. Remove that by clamping the initial value.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v3:\n> - Collected tags\n> ---\n>  src/ipa/libipa/exposure_mode_helper.cpp | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index cd81503e07d6..21efc4356afa 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -197,8 +197,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>                 return { minExposureTime_, minGain_, exposure / (minExposureTime_ * minGain_) };\n>  \n>         utils::Duration exposureTime;\n> -       double stageGain = 1.0;\n> -       double lastStageGain = 1.0;\n> +       double stageGain = clampGain(1.0);\n> +       double lastStageGain = stageGain;\n>         double gain;\n>  \n>         for (unsigned int stage = 0; stage < gains_.size(); stage++) {\n> @@ -215,7 +215,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \n>                 /* Clamp the gain to lastStageGain and regulate exposureTime. */\n>                 if (stageExposureTime * lastStageGain >= exposure) {\n> -                       exposureTime = clampExposureTime(exposure / clampGain(lastStageGain));\n> +                       exposureTime = clampExposureTime(exposure / lastStageGain);\n>                         gain = clampGain(exposure / exposureTime);\n>  \n>                         return { exposureTime, gain, exposure / (exposureTime * gain) };\n> @@ -223,7 +223,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \n>                 /* Clamp the exposureTime to stageExposureTime and regulate gain. */\n>                 if (stageExposureTime * stageGain >= exposure) {\n> -                       exposureTime = clampExposureTime(stageExposureTime);\n> +                       exposureTime = stageExposureTime;\n>                         gain = clampGain(exposure / exposureTime);\n>  \n>                         return { exposureTime, gain, exposure / (exposureTime * gain) };\n> @@ -239,7 +239,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>          * stages to use then the default stageGain of 1.0 is used so that\n>          * exposure time is maxed before gain is touched at all.\n>          */\n> -       exposureTime = clampExposureTime(exposure / clampGain(stageGain));\n> +       exposureTime = clampExposureTime(exposure / stageGain);\n>         gain = clampGain(exposure / exposureTime);\n>  \n>         return { exposureTime, gain, exposure / (exposureTime * gain) };\n> -- \n> 2.48.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6714CBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  5 Sep 2025 10:43:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7599269361;\n\tFri,  5 Sep 2025 12:43:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BCB746935B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Sep 2025 12:43:04 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:dbfb:387c:7405:52bc])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 399131666; \n\tFri,  5 Sep 2025 12:41:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JizR14bG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757068914;\n\tbh=6E9vQCjfVp+q0oKK0HqP+l+pWT4xnlpsZc9hGrAdhp0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=JizR14bGdXLBXrtvdCLz7AkitGnwMdSDU1eZli06DELKq+G0BLjsJB5IVoKmOmm3G\n\tutwnbDkhsiQEmY3/JnLfpFu0odx5haykrqqcQEaEhCXojXqs72TeJDqvy1XOIlpyHI\n\tYWhhPFkIu1Otsdmjh24GIbvl7et7+OTaMuPMGq2c=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250815102945.1602071-7-stefan.klug@ideasonboard.com>","References":"<20250815102945.1602071-1-stefan.klug@ideasonboard.com>\n\t<20250815102945.1602071-7-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 06/19] libipa: exposure_mode_helper: Remove\n\tunnecessary clamp calls","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tIsaac Scott <isaac.scott@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 05 Sep 2025 19:42:58 +0900","Message-ID":"<175706897863.1787083.18235128373581372732@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]