Patch Detail
Show a patch.
GET /api/patches/23757/?format=api
{ "id": 23757, "url": "https://patchwork.libcamera.org/api/patches/23757/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23757/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250707085520.39777-9-stefan.klug@ideasonboard.com>", "date": "2025-07-07T08:55:11", "name": "[v3,8/9] libipa: agc_mean_luminance: Add exposure compensation support", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "816b45a6a50858500b6c92b62a19b8b28a7d0bce", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23757/mbox/", "series": [ { "id": 5273, "url": "https://patchwork.libcamera.org/api/series/5273/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5273", "date": "2025-07-07T08:55:03", "name": "Wdr preparations", "version": 3, "mbox": "https://patchwork.libcamera.org/series/5273/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23757/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23757/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 120BAC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 7 Jul 2025 08:56:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8660868E8C;\n\tMon, 7 Jul 2025 10:56:01 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B2F1768EB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 7 Jul 2025 10:55:57 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 140D91942; \n\tMon, 7 Jul 2025 10:55:31 +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=\"R7gKpb48\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1751878531;\n\tbh=1wKU0pjobuw79Vf1aXQoXME+va0b4U8ybOtk7pQXB0w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=R7gKpb48flSLmcRIGN/wWo8WsoHNWR6UXvnvR83fMs9QFHh/4+tsYm5q/UoInBifc\n\tu5IAej0Qejw1nfwwxhZzHhZDJjgRrZoe9rHWEz/bklnaFvMEcs46Om0jXGjfjwPA6X\n\toeiQ/09MEA6onveocOTcAERmatG9amKWC1k8BlF8=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v3 8/9] libipa: agc_mean_luminance: Add exposure compensation\n\tsupport", "Date": "Mon, 7 Jul 2025 10:55:11 +0200", "Message-ID": "<20250707085520.39777-9-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20250707085520.39777-1-stefan.klug@ideasonboard.com>", "References": "<20250707085520.39777-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. Add support for that in agc_mean_luminance.\n\nThe added exposure compensation can lead to luminance target values that\nare close or above saturation and are therefore never reachable. Add a\nfix for that by limiting the maximum luminance target to 0.95.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v3:\n- Fixed line wrap\n- Collected tags\n\nChanges in v2:\n- Fixed compiler error that slipped through in v1\n- Improved commit message to explain the luminance target limitation\n- Collected tag\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 24 ++++++++++++++++++++++--\n src/ipa/libipa/agc_mean_luminance.h | 6 ++++++\n 2 files changed, 28 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex ebdb4d755741..ff96a381ffce 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,8 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16;\n */\n \n AgcMeanLuminance::AgcMeanLuminance()\n-\t: frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0)\n+\t: exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s),\n+\t relativeLuminanceTarget_(0)\n {\n }\n \n@@ -368,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@@ -424,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": [ "v3", "8/9" ] }