Patch Detail
Show a patch.
GET /api/patches/21478/?format=api
{ "id": 21478, "url": "https://patchwork.libcamera.org/api/patches/21478/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21478/", "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": "<20241002161933.247091-8-stefan.klug@ideasonboard.com>", "date": "2024-10-02T16:19:25", "name": "[v1,7/8,WIP] ipa: Add debug controls to the agc algorithm", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "96ac90ded3681108b5b74b175b160713c4c36b30", "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/21478/mbox/", "series": [ { "id": 4648, "url": "https://patchwork.libcamera.org/api/series/4648/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4648", "date": "2024-10-02T16:19:18", "name": "Add support for IPA debugging metadata", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4648/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21478/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21478/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 978F3BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 2 Oct 2024 16:20:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4CDD36352A;\n\tWed, 2 Oct 2024 18:20:38 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F3486352F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 2 Oct 2024 18:20:36 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b246:b33f:c662:8ae1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 569093098;\n\tWed, 2 Oct 2024 18:19:03 +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=\"JRKcnTTP\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727885943;\n\tbh=iUsHsXLqGVAZ7tiP76+J/RvkInfoITXfi1DDTtx72YA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JRKcnTTP06dd+D9YpP/g8pQ9O2CgcJTLu8IuxdOdGY4xsOpGFkwyirTfG+CdXZ8DG\n\tEWbAjLWJbPnu9SyHt4u9EslV44N5IlknM3djYEjS9g9abLC+aHTzOCPdSx49Ix8S0p\n\tQHW0HZeK6WJyR5qjmOmTfDydn3Puuva3ko4y7vz4=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v1 7/8] [WIP] ipa: Add debug controls to the agc algorithm", "Date": "Wed, 2 Oct 2024 18:19:25 +0200", "Message-ID": "<20241002161933.247091-8-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20241002161933.247091-1-stefan.klug@ideasonboard.com>", "References": "<20241002161933.247091-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": "Add a few (arbitrary) debug metadata to the agc algorithm. This shows\nhow easy it is to add debug metadata to an ipa even for classes that\ndon't have direct access to the metadata list or the context like\nAgcMeanLuminance. The control_ids_debug.yaml was autogenerated by\ncalling utils/gen-debug-controls.py\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 8 ++++++++\n src/ipa/libipa/agc_mean_luminance.h | 4 ++++\n src/ipa/rkisp1/algorithms/agc.cpp | 8 ++++++++\n src/libcamera/control_ids_debug.yaml | 17 ++++++++++++++++-\n 4 files changed, 36 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex f97ef11771c4..bd0f85afcd2e 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -133,6 +133,11 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16;\n * values.\n */\n \n+/**\n+ * \\var AgcMeanLuminance::debugMeta_\n+ * \\brief DebugMetadata helper\n+ */\n+\n AgcMeanLuminance::AgcMeanLuminance()\n \t: frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0)\n {\n@@ -541,8 +546,11 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n \t\texposureModeHelpers_.at(exposureModeIndex);\n \n \tdouble gain = estimateInitialGain();\n+\tdebugMeta_.set<float>(controls::debug::AgcInitialGain, static_cast<float>(gain));\n \tgain = constraintClampGain(constraintModeIndex, yHist, gain);\n \n+\tdebugMeta_.set<float>(controls::debug::AgcNewGain, static_cast<float>(gain));\n+\n \t/*\n \t * We don't check whether we're already close to the target, because\n \t * even if the effective exposure value is the same as the last frame's\ndiff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\nindex 576d28be8eb0..428465a11a36 100644\n--- a/src/ipa/libipa/agc_mean_luminance.h\n+++ b/src/ipa/libipa/agc_mean_luminance.h\n@@ -16,6 +16,7 @@\n \n #include <libcamera/controls.h>\n \n+#include \"libcamera/internal/debug_controls.h\"\n #include \"libcamera/internal/yaml_parser.h\"\n \n #include \"exposure_mode_helper.h\"\n@@ -71,6 +72,9 @@ public:\n \t\tframeCount_ = 0;\n \t}\n \n+protected:\n+\tDebugMetadata debugMeta_;\n+\n private:\n \tvirtual double estimateLuminance(const double gain) const = 0;\n \ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 17d074d9c03e..2dcee0ceaccf 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -139,6 +139,8 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData)\n {\n \tint ret;\n \n+\tdebugMeta_.assignUpstream(&context.debugMetadata);\n+\n \tret = parseTuningData(tuningData);\n \tif (ret)\n \t\treturn ret;\n@@ -444,6 +446,12 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\t\t frameContext.agc.exposureMode,\n \t\t\t hist, effectiveExposureValue);\n \n+\tdebugMeta_.set<float>(controls::debug::AgcAnalogGain, aGain);\n+\tdebugMeta_.set<float>(controls::debug::AgcDigitalGain, dGain);\n+\n+\tconst auto &data = hist.data();\n+\tdebugMeta_.set<Span<const int64_t>>(controls::debug::AgcHistogram, Span(reinterpret_cast<const int64_t *>(&data[0]), data.size()));\n+\n \tLOG(RkISP1Agc, Debug)\n \t\t<< \"Divided up shutter, analogue gain and digital gain are \"\n \t\t<< shutterTime << \", \" << aGain << \" and \" << dGain;\ndiff --git a/src/libcamera/control_ids_debug.yaml b/src/libcamera/control_ids_debug.yaml\nindex 11ddfd7cc8d8..d1da5cca2364 100644\n--- a/src/libcamera/control_ids_debug.yaml\n+++ b/src/libcamera/control_ids_debug.yaml\n@@ -8,4 +8,19 @@\n # set through Request::controls() and returned out through Request::metadata().\n vendor: debug\n controls:\n-\n+- AgcAnalogGain:\n+ type: float\n+ description: Debug control AgcAnalogGain found in src/ipa/rkisp1/algorithms/agc.cpp:448\n+- AgcDigitalGain:\n+ type: float\n+ description: Debug control AgcDigitalGain found in src/ipa/rkisp1/algorithms/agc.cpp:449\n+- AgcHistogram:\n+ type: int64_t\n+ description: Debug control AgcHistogram found in src/ipa/rkisp1/algorithms/agc.cpp:452\n+ size: '[n]'\n+- AgcInitialGain:\n+ type: float\n+ description: Debug control AgcInitialGain found in src/ipa/libipa/agc_mean_luminance.cpp:543\n+- AgcNewGain:\n+ type: float\n+ description: Debug control AgcNewGain found in src/ipa/libipa/agc_mean_luminance.cpp:546\n", "prefixes": [ "v1", "7/8", "WIP" ] }