Show a patch.

GET /api/1.1/patches/24467/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 24467,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24467/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24467/",
    "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": "<20250925221708.7471-6-hansg@kernel.org>",
    "date": "2025-09-25T22:17:07",
    "name": "[v2,5/6] libcamera: software_isp: Add valid flag to struct SwIspStats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3d4b66478073a5e64f15f3055aa036c81b94b42d",
    "submitter": {
        "id": 239,
        "url": "https://patchwork.libcamera.org/api/1.1/people/239/?format=api",
        "name": "Hans de Goede",
        "email": "hansg@kernel.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24467/mbox/",
    "series": [
        {
            "id": 5459,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5459/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5459",
            "date": "2025-09-25T22:17:02",
            "name": "ipa: software_isp: AGC: Fox AGC oscillation bug",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5459/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24467/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24467/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 84113C3332\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Sep 2025 22:17:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77DCA6B601;\n\tFri, 26 Sep 2025 00:17:30 +0200 (CEST)",
            "from tor.source.kernel.org (tor.source.kernel.org\n\t[IPv6:2600:3c04:e001:324:0:1991:8:25])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CB93969367\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Sep 2025 00:17:19 +0200 (CEST)",
            "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id E616961296\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Sep 2025 22:17:18 +0000 (UTC)",
            "by smtp.kernel.org (Postfix) with ESMTPSA id E19C6C4CEF7;\n\tThu, 25 Sep 2025 22:17:17 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=kernel.org header.i=@kernel.org\n\theader.b=\"P+rX+Bha\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1758838638;\n\tbh=6EgO+Cwy6VnHEnTNl8HJyuH0z9NTyUOpzOrpIFPwbFk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P+rX+BhaV9IJwHLMT0JMpauaNJLkaA0b2W60dX9XJ/hCHOgsFLZdtsbZ/JfjR47JB\n\tO9qctxvth9pNMyMactv4VnjTArn9kEXpYku6SWbEJl42MSBd3qeY05OIO2CI3RikYR\n\tSrDiORrNUJwmabU1AfbdspaluPAChBmNkk2wWJJt6coMEk84q+0CXCxzACY/ebD5w/\n\tDVLIkxSO+k0U5Flk64X/Kbh7obXn41nDY1c/KuA2Hd5IUdCMIHR35/QpXOvTPSmm02\n\ty4nTSs9uGkZE5vCk8tAuQlO5Wmj1R2/LNyu4Knp3sWUn5MbbTZpHeRaunw3ISRQIU/\n\thlOzLofQN6BEQ==",
        "From": "Hans de Goede <hansg@kernel.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Hans de Goede <hansg@kernel.org>",
        "Subject": "[PATCH v2 5/6] libcamera: software_isp: Add valid flag to struct\n\tSwIspStats",
        "Date": "Fri, 26 Sep 2025 00:17:07 +0200",
        "Message-ID": "<20250925221708.7471-6-hansg@kernel.org>",
        "X-Mailer": "git-send-email 2.51.0",
        "In-Reply-To": "<20250925221708.7471-1-hansg@kernel.org>",
        "References": "<20250925221708.7471-1-hansg@kernel.org>",
        "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": "Generating statistics for every single frame is not really necessary.\n\nHowever a roundtrip through ipa_->processStats() still need to be done\nevery frame, even if there are no stats to make the IPA generate metadata\nfor every frame.\n\nAdd a valid flag to the statistics struct to let the IPA know when there\nare no statistics for the frame being processed and modify the IPA to\nonly generate metadata for frames without valid statistics.\n\nThis is a preparation patch for skipping statistics generation for some\nframes.\n\nSigned-off-by: Hans de Goede <hansg@kernel.org>\n---\n include/libcamera/internal/software_isp/swisp_stats.h | 4 ++++\n src/ipa/simple/algorithms/agc.cpp                     | 3 +++\n src/ipa/simple/algorithms/awb.cpp                     | 3 +++\n src/ipa/simple/algorithms/blc.cpp                     | 3 +++\n src/ipa/simple/soft_simple.cpp                        | 3 +++\n src/libcamera/software_isp/debayer_cpu.cpp            | 2 +-\n src/libcamera/software_isp/swstats_cpu.cpp            | 4 +++-\n src/libcamera/software_isp/swstats_cpu.h              | 2 +-\n 8 files changed, 21 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/software_isp/swisp_stats.h b/include/libcamera/internal/software_isp/swisp_stats.h\nindex ae11f112..cbcfd351 100644\n--- a/include/libcamera/internal/software_isp/swisp_stats.h\n+++ b/include/libcamera/internal/software_isp/swisp_stats.h\n@@ -20,6 +20,10 @@ namespace libcamera {\n  * wrap around.\n  */\n struct SwIspStats {\n+\t/**\n+\t * \\brief Indicates if the statistics buffer contains valid data\n+\t */\n+\tbool valid;\n \t/**\n \t * \\brief Holds the sum of all sampled red pixels\n \t */\ndiff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\nindex 3471cc88..e4e24113 100644\n--- a/src/ipa/simple/algorithms/agc.cpp\n+++ b/src/ipa/simple/algorithms/agc.cpp\n@@ -107,6 +107,9 @@ void Agc::process(IPAContext &context,\n \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n \n+\tif (!stats->valid)\n+\t\treturn;\n+\n \t/*\n \t * Calculate Mean Sample Value (MSV) according to formula from:\n \t * https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf\ndiff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\nindex cf567e89..ddd0b791 100644\n--- a/src/ipa/simple/algorithms/awb.cpp\n+++ b/src/ipa/simple/algorithms/awb.cpp\n@@ -61,6 +61,9 @@ void Awb::process(IPAContext &context,\n \t};\n \tmetadata.set(controls::ColourGains, mdGains);\n \n+\tif (!stats->valid)\n+\t\treturn;\n+\n \t/*\n \t * Black level must be subtracted to get the correct AWB ratios, they\n \t * would be off if they were computed from the whole brightness range\ndiff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp\nindex 8c1e9ed0..616da0ee 100644\n--- a/src/ipa/simple/algorithms/blc.cpp\n+++ b/src/ipa/simple/algorithms/blc.cpp\n@@ -60,6 +60,9 @@ void BlackLevel::process(IPAContext &context,\n \t};\n \tmetadata.set(controls::SensorBlackLevels, blackLevels);\n \n+\tif (!stats->valid)\n+\t\treturn;\n+\n \tif (context.configuration.black.level.has_value())\n \t\treturn;\n \ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex b147aca2..e1c8e21a 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -318,6 +318,9 @@ void IPASoftSimple::processStats(const uint32_t frame,\n \t\talgo->process(context_, frame, frameContext, stats_, metadata);\n \tmetadataReady.emit(frame, metadata);\n \n+\tif (!stats_->valid)\n+\t\treturn;\n+\n \t/* Sanity check */\n \tif (!sensorControls.contains(V4L2_CID_EXPOSURE) ||\n \t    !sensorControls.contains(V4L2_CID_ANALOGUE_GAIN)) {\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 2dc85e5e..bfa60888 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -851,7 +851,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n \t *\n \t * \\todo Pass real bufferId once stats buffer passing is changed.\n \t */\n-\tstats_->finishFrame(frame, 0);\n+\tstats_->finishFrame(frame, 0, true);\n \toutputBufferReady.emit(output);\n \tinputBufferReady.emit(input);\n }\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 4b77b360..da91f912 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -313,11 +313,13 @@ void SwStatsCpu::startFrame(void)\n  * \\brief Finish statistics calculation for the current frame\n  * \\param[in] frame The frame number\n  * \\param[in] bufferId ID of the statistics buffer\n+ * \\param[in] valid Indicates if the statistics for the current frame are valid\n  *\n  * This may only be called after a successful setWindow() call.\n  */\n-void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)\n+void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId, bool valid)\n {\n+\tstats_.valid = valid;\n \t*sharedStats_ = stats_;\n \tstatsReady.emit(frame, bufferId);\n }\ndiff --git a/src/libcamera/software_isp/swstats_cpu.h b/src/libcamera/software_isp/swstats_cpu.h\nindex 26a2f462..6ac3c4de 100644\n--- a/src/libcamera/software_isp/swstats_cpu.h\n+++ b/src/libcamera/software_isp/swstats_cpu.h\n@@ -41,7 +41,7 @@ public:\n \tint configure(const StreamConfiguration &inputCfg);\n \tvoid setWindow(const Rectangle &window);\n \tvoid startFrame();\n-\tvoid finishFrame(uint32_t frame, uint32_t bufferId);\n+\tvoid finishFrame(uint32_t frame, uint32_t bufferId, bool valid);\n \n \tvoid processLine0(unsigned int y, const uint8_t *src[])\n \t{\n",
    "prefixes": [
        "v2",
        "5/6"
    ]
}