[{"id":35318,"web_url":"https://patchwork.libcamera.org/comment/35318/","msgid":"<175467578889.4081879.5544388001943292958@ping.linuxembedded.co.uk>","date":"2025-08-08T17:56:28","subject":"Re: [PATCH v2 05/16] libipa: exposure_mode_helper: Remove double\n\tcalculation of lastStageGain","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-08-08 15:12:43)\n> lastStageGain gets recalculated unconditionally even though it is the\n> stageGain of the last stage. Refactor for increased simplicity and\n> efficiency.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/libipa/exposure_mode_helper.cpp | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index d0a61908c966..3c758851679f 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -198,10 +198,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \n>         utils::Duration exposureTime;\n>         double stageGain = 1.0;\n> +       double lastStageGain = 1.0;\n>         double gain;\n>  \n>         for (unsigned int stage = 0; stage < gains_.size(); stage++) {\n> -               double lastStageGain = stage == 0 ? 1.0 : clampGain(gains_[stage - 1]);\n>                 utils::Duration stageExposureTime = clampExposureTime(exposureTimes_[stage]);\n>                 stageGain = clampGain(gains_[stage]);\n>  \n> @@ -228,6 +228,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \n>                         return { exposureTime, gain, exposure / (exposureTime * gain) };\n>                 }\n> +\n> +               lastStageGain = stageGain;\n\nLooks good ...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>         }\n>  \n>         /*\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 C8B45BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Aug 2025 17:56:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03BD76084D;\n\tFri,  8 Aug 2025 19:56:33 +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 953396084D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Aug 2025 19:56:31 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 67E2299F;\n\tFri,  8 Aug 2025 19:55:41 +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=\"fKQGfJEt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754675741;\n\tbh=CzhKkPRxZYxRoNQ5jtU2GNjL9Ny7Kd2qES6DNn6yxko=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=fKQGfJEt0931VSUBGizHR1nXtX5xNj46xu7h4K3ZoLQoExXqU7RE8Sy4j9wpQQXqv\n\tuAnC1NxDSAKkDSUUajIjB/9EKdX5fwgIdNxIgxchW9fMHUDMOxVlvJwQCOsm/KsNKX\n\tBZUTr6vM8dRPB8/jhPUT7uLHpcX5K6zlP2iOKM0o=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250808141315.413839-6-stefan.klug@ideasonboard.com>","References":"<20250808141315.413839-1-stefan.klug@ideasonboard.com>\n\t<20250808141315.413839-6-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 05/16] libipa: exposure_mode_helper: Remove double\n\tcalculation of lastStageGain","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 08 Aug 2025 18:56:28 +0100","Message-ID":"<175467578889.4081879.5544388001943292958@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}},{"id":35343,"web_url":"https://patchwork.libcamera.org/comment/35343/","msgid":"<d6789fa5-7839-44e5-95a5-ea2592c064ac@ideasonboard.com>","date":"2025-08-11T14:38:32","subject":"Re: [PATCH v2 05/16] libipa: exposure_mode_helper: Remove double\n\tcalculation of lastStageGain","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Stefan\n\nOn 08/08/2025 15:12, Stefan Klug wrote:\n> lastStageGain gets recalculated unconditionally even though it is the\n> stageGain of the last stage. Refactor for increased simplicity and\n> efficiency.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\nMuch nicer:\n\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n>   src/ipa/libipa/exposure_mode_helper.cpp | 4 +++-\n>   1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index d0a61908c966..3c758851679f 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -198,10 +198,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>   \n>   \tutils::Duration exposureTime;\n>   \tdouble stageGain = 1.0;\n> +\tdouble lastStageGain = 1.0;\n>   \tdouble gain;\n>   \n>   \tfor (unsigned int stage = 0; stage < gains_.size(); stage++) {\n> -\t\tdouble lastStageGain = stage == 0 ? 1.0 : clampGain(gains_[stage - 1]);\n>   \t\tutils::Duration stageExposureTime = clampExposureTime(exposureTimes_[stage]);\n>   \t\tstageGain = clampGain(gains_[stage]);\n>   \n> @@ -228,6 +228,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>   \n>   \t\t\treturn { exposureTime, gain, exposure / (exposureTime * gain) };\n>   \t\t}\n> +\n> +\t\tlastStageGain = stageGain;\n>   \t}\n>   \n>   \t/*","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 11CD8BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Aug 2025 14:38:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CA53869245;\n\tMon, 11 Aug 2025 16:38:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED8A069236\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Aug 2025 16:38:34 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D55DD82A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Aug 2025 16:37:42 +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=\"TWzQJ/zs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754923062;\n\tbh=5seOTeC0HQV0k12CKCGAdcf+HmsDvGLr/UOnfSlm5Vc=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=TWzQJ/zsBkc3xjQaHPnQpOkT0gdk3EiqdGFJIJxGSzfcuKdohzsmMKrIngPTheQuy\n\tj7R1x5Y0ciLhRWYmq19KQz4jArHyFo3KoViKQyHPSH0O1m9prZz4kwHQgCJqTlCylv\n\tZNp8171jRgfXRlRRlsdF/CFmhDh4qXfvdLrGclWk=","Message-ID":"<d6789fa5-7839-44e5-95a5-ea2592c064ac@ideasonboard.com>","Date":"Mon, 11 Aug 2025 15:38:32 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 05/16] libipa: exposure_mode_helper: Remove double\n\tcalculation of lastStageGain","To":"libcamera-devel@lists.libcamera.org","References":"<20250808141315.413839-1-stefan.klug@ideasonboard.com>\n\t<20250808141315.413839-6-stefan.klug@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","In-Reply-To":"<20250808141315.413839-6-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}}]