Patch Detail
Show a patch.
GET /api/patches/24799/?format=api
{ "id": 24799, "url": "https://patchwork.libcamera.org/api/patches/24799/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24799/", "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": "<20251024085130.995967-34-stefan.klug@ideasonboard.com>", "date": "2025-10-24T08:50:57", "name": "[v1,33/35] libipa: agc_mean_luminance: Make startup frames and regulations speed configurable", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "3c0518a03832fc078af2583626daddb47bd89b3a", "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/24799/mbox/", "series": [ { "id": 5524, "url": "https://patchwork.libcamera.org/api/series/5524/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5524", "date": "2025-10-24T08:50:24", "name": "rkisp1: pipeline rework for PFC", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5524/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24799/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24799/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 2811FBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Oct 2025 08:53:20 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D33F260971;\n\tFri, 24 Oct 2025 10:53:19 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D0D160938\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Oct 2025 10:53:18 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:7edc:62f4:c118:1549])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id F04C51E46; \n\tFri, 24 Oct 2025 10:51:32 +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=\"HO8MhuxT\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761295893;\n\tbh=zcuiv9yXlvr31uOtzmfQAHWhJ9/2QeBPoCVD0DK3llI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=HO8MhuxTuh4AjHTwdhdVf//Fh9tYgHvsNgXKi22jTtWbGnozriqnep/ZxnCpQb95k\n\t+ljmsLcn2OtTaRCotxHP600GgmqXGv4PyUGnjg6kjKyJ17QedmeTy8jWlKV7pOXZvf\n\t9+aMeFbLCUmGEmHTwN0Bs0vm/oA4gRGDMNfjuCFc=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v1 33/35] libipa: agc_mean_luminance: Make startup frames and\n\tregulations speed configurable", "Date": "Fri, 24 Oct 2025 10:50:57 +0200", "Message-ID": "<20251024085130.995967-34-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20251024085130.995967-1-stefan.klug@ideasonboard.com>", "References": "<20251024085130.995967-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": "The rkisp1 has now a good synchronization between sensor settings/isp\nparams and stats. It can therefore benefit from a faster regulation. To\ndo that without breaking others IPAs that use AgcMeanLuminance, move\nregulation speed and startup frames into member variables that can be\nset at runtime.\n\nAs this requires the introduction of a protected access modifier. This\nwas added, so that most of the previously public functions are now also\nprotected, because public visibility is not needed.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 25 +++++++++++++++++++++----\n src/ipa/libipa/agc_mean_luminance.h | 4 ++++\n 2 files changed, 25 insertions(+), 4 deletions(-)", "diff": "diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex 64f36bd75dd2..0cd3fbee99e8 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -34,7 +34,7 @@ namespace ipa {\n * Number of frames for which to run the algorithm at full speed, before slowing\n * down to prevent large and jarring changes in exposure from frame to frame.\n */\n-static constexpr uint32_t kNumStartupFrames = 10;\n+static constexpr uint32_t kDefaultNumStartupFrames = 10;\n \n /*\n * Default relative luminance target\n@@ -144,7 +144,8 @@ static constexpr double kMaxRelativeLuminanceTarget = 0.95;\n */\n \n AgcMeanLuminance::AgcMeanLuminance()\n-\t: exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s),\n+\t: numStartupFrames_(kDefaultNumStartupFrames), regulationSpeed_(0.2),\n+\t exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s),\n \t relativeLuminanceTarget_(0)\n {\n }\n@@ -554,10 +555,10 @@ double AgcMeanLuminance::effectiveYTarget() const\n */\n utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue)\n {\n-\tdouble speed = 0.2;\n+\tdouble speed = regulationSpeed_;\n \n \t/* Adapt instantly if we are in startup phase. */\n-\tif (frameCount_ < kNumStartupFrames)\n+\tif (frameCount_ < numStartupFrames_)\n \t\tspeed = 1.0;\n \n \t/*\n@@ -649,6 +650,22 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n * their configure() function.\n */\n \n+/**\n+ * \\var AgcMeanLuminance::numStartupFrames_\n+ * \\brief The number of startup frames\n+ *\n+ * During this number of frames after startup, the regulation is very aggressive\n+ * to reach the target value within one or two cycles.\n+ *\n+ * \\var AgcMeanLuminance::regulationSpeed_\n+ * The regulation speed. This controls the speed at which new target values are\n+ * applied. The new target value is calculated as:\n+ *\n+ * \\code{.unparsed}\n+ * value = target * speed + oldValue * (1.0 - speed)\n+ * \\endcode\n+ */\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\nindex d7ec548e3e58..b176c3e28410 100644\n--- a/src/ipa/libipa/agc_mean_luminance.h\n+++ b/src/ipa/libipa/agc_mean_luminance.h\n@@ -42,6 +42,7 @@ public:\n \t\tdouble yTarget;\n \t};\n \n+protected:\n \tvoid configure(utils::Duration lineDuration, const CameraSensorHelper *sensorHelper);\n \tint parseTuningData(const YamlObject &tuningData);\n \n@@ -79,6 +80,9 @@ public:\n \t\tframeCount_ = 0;\n \t}\n \n+\tuint32_t numStartupFrames_;\n+\tdouble regulationSpeed_;\n+\n private:\n \tvirtual double estimateLuminance(const double gain) const = 0;\n \n", "prefixes": [ "v1", "33/35" ] }