Patch Detail
Show a patch.
GET /api/1.1/patches/23165/?format=api
{ "id": 23165, "url": "https://patchwork.libcamera.org/api/1.1/patches/23165/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23165/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250411123641.2144530-9-stefan.klug@ideasonboard.com>", "date": "2025-04-11T12:36:36", "name": "[v2,8/9] libipa: agc_mean_luminance: Add exposure compensation support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bbcc36369e3f58b7df10d3f223c339e7459218e7", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23165/mbox/", "series": [ { "id": 5121, "url": "https://patchwork.libcamera.org/api/1.1/series/5121/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5121", "date": "2025-04-11T12:36:28", "name": "Wdr preparations", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5121/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23165/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23165/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 B90FCC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Apr 2025 12:37:11 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5166168ABA;\n\tFri, 11 Apr 2025 14:37:11 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC3EE68AB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Apr 2025 14:37:09 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A296667;\n\tFri, 11 Apr 2025 14:35:10 +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=\"qhYWYepw\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744374910;\n\tbh=bormeQ45cumqOupY+08k0pBAEDEU+j1PYfniDs9zcY4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qhYWYepwfnCLBSCp1k0Zxw+Xp4ai1iMfACIJnhsntK5ZVdeIlOXhI3u4bR+Eeylo+\n\tBkiIxtVDzC+WTYyR8V2RIXPR6cIf5XMLxn5x3609rkVljYgNWsOpOXe+B6HQC1lBB9\n\tvjXVqB3Dlm4Y9+dcttjnXRrgcQNGRylpdqpn6HYQ=", "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>", "Subject": "[PATCH v2 8/9] libipa: agc_mean_luminance: Add exposure compensation\n\tsupport", "Date": "Fri, 11 Apr 2025 14:36:36 +0200", "Message-ID": "<20250411123641.2144530-9-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250411123641.2144530-1-stefan.klug@ideasonboard.com>", "References": "<20250411123641.2144530-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>\n\n---\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 | 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..f6cb7144b31a 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: exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(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": [ "v2", "8/9" ] }