{"id":23081,"url":"https://patchwork.libcamera.org/api/patches/23081/?format=json","web_url":"https://patchwork.libcamera.org/patch/23081/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250331144352.736700-9-stefan.klug@ideasonboard.com>","date":"2025-03-31T14:43:47","name":"[8/9] libipa: agc_mean_luminance: Add exposure compensation support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a0343f76746b6c6e2cdb3e433cde6a6f73e2baa2","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23081/mbox/","series":[{"id":5094,"url":"https://patchwork.libcamera.org/api/series/5094/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5094","date":"2025-03-31T14:43:39","name":"Wdr preparations","version":1,"mbox":"https://patchwork.libcamera.org/series/5094/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23081/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23081/checks/","tags":{},"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 E53DBC3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Mar 2025 14:44:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 97BA5689A0;\n\tMon, 31 Mar 2025 16:44:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 98B046899D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Mar 2025 16:44:18 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:823a:c275:e8b5:b937])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 272A6725;\n\tMon, 31 Mar 2025 16:42:27 +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=\"iWDG6bJe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743432147;\n\tbh=DsaJdPyfZNhM1/5qcUZRWzLV3yYzuSEh2tyccCDzu7s=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=iWDG6bJeyRAI+YpnwQrKwe906oNOcsEp3nu2wwxUYnh6AbDJCy5ODNjvtk5RLmKE5\n\tGA56hfZhqYdsKcC9aIjrcyq5//jMnEUezFvt0QCx4pU6UhYCX3NprfiJwKbemLgsei\n\tKxRMtsDAQHENTxRZ8a9b3S7D9W+0zSv8hG+IppJU=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH 8/9] libipa: agc_mean_luminance: Add exposure compensation\n\tsupport","Date":"Mon, 31 Mar 2025 16:43:47 +0200","Message-ID":"<20250331144352.736700-9-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20250331144352.736700-1-stefan.klug@ideasonboard.com>","References":"<20250331144352.736700-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Exposure compensation allows to over- or under-expose an\nimage by a given value (typically provided in EV). Add support\nfor that in agc_mean_luminance.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 23 +++++++++++++++++++++--\n src/ipa/libipa/agc_mean_luminance.h   |  6 ++++++\n 2 files changed, 27 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex 9154f083a510..a498b646bdd5 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -44,6 +44,15 @@ static constexpr uint32_t kNumStartupFrames = 10;\n  */\n static constexpr double kDefaultRelativeLuminanceTarget = 0.16;\n \n+/*\n+ * Maximum relative luminance target\n+ *\n+ * This value limits the relative luminance target after applying the exposure\n+ * compensation. Targeting a value above this limit results in saturation\n+ * and the inability to regulate properly.\n+ */\n+static constexpr double kMaxRelativeLuminanceTarget = 0.95;\n+\n /**\n  * \\struct AgcMeanLuminance::AgcConstraint\n  * \\brief The boundaries and target for an AeConstraintMode constraint\n@@ -134,7 +143,7 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16;\n  */\n \n AgcMeanLuminance::AgcMeanLuminance()\n-\t: frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0)\n+\t: frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0), exposureCompensation_(1.0)\n {\n }\n \n@@ -369,6 +378,15 @@ int AgcMeanLuminance::parseTuningData(const YamlObject &tuningData)\n \treturn parseExposureModes(tuningData);\n }\n \n+/**\n+ * \\fn AgcMeanLuminance::setExposureCompensation()\n+ * \\brief Set the exposure compensation value\n+ * \\param[in] gain The exposure compensation gain\n+ *\n+ * This function sets the exposure compensation value to be used in the\n+ * AGC calculations. It is expressed as gain instead of EV.\n+ */\n+\n /**\n  * \\brief Set the ExposureModeHelper limits for this class\n  * \\param[in] minExposureTime Minimum exposure time to allow\n@@ -425,7 +443,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,\n  */\n double AgcMeanLuminance::estimateInitialGain() const\n {\n-\tdouble yTarget = relativeLuminanceTarget_;\n+\tdouble yTarget = std::min(relativeLuminanceTarget_ * exposureCompensation_,\n+\t\t\t\t  kMaxRelativeLuminanceTarget);\n \tdouble yGain = 1.0;\n \n \t/*\ndiff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\nindex c41391cb0b73..cad7ef845487 100644\n--- a/src/ipa/libipa/agc_mean_luminance.h\n+++ b/src/ipa/libipa/agc_mean_luminance.h\n@@ -44,6 +44,11 @@ public:\n \n \tint parseTuningData(const YamlObject &tuningData);\n \n+\tvoid setExposureCompensation(double gain)\n+\t{\n+\t\texposureCompensation_ = gain;\n+\t}\n+\n \tvoid setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,\n \t\t       double minGain, double maxGain);\n \n@@ -84,6 +89,7 @@ private:\n \t\t\t\t   double gain);\n \tutils::Duration filterExposure(utils::Duration exposureValue);\n \n+\tdouble exposureCompensation_;\n \tuint64_t frameCount_;\n \tutils::Duration filteredExposure_;\n \tdouble relativeLuminanceTarget_;\n","prefixes":["8/9"]}