Show a patch.

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

{
    "id": 25404,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25404/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25404/",
    "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": "<20251210003139.43606-9-bryan.odonoghue@linaro.org>",
    "date": "2025-12-10T00:31:25",
    "name": "[v4,08/20] libcamera: swstats_cpu: Add processFrame() method",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8f92db05134eaefb9f0516e086b01cbe12e4c8f9",
    "submitter": {
        "id": 175,
        "url": "https://patchwork.libcamera.org/api/1.1/people/175/?format=api",
        "name": "Bryan O'Donoghue",
        "email": "bryan.odonoghue@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25404/mbox/",
    "series": [
        {
            "id": 5644,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5644/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5644",
            "date": "2025-12-10T00:31:17",
            "name": "GPUISP precursor series",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5644/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25404/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25404/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 34903BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Dec 2025 00:32:21 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DEB796143D;\n\tWed, 10 Dec 2025 01:32:20 +0100 (CET)",
            "from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com\n\t[IPv6:2607:f8b0:4864:20::102f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E38C06142A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 01:32:18 +0100 (CET)",
            "by mail-pj1-x102f.google.com with SMTP id\n\t98e67ed59e1d1-343514c7854so180144a91.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Dec 2025 16:32:18 -0800 (PST)",
            "from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp.\n\t[150.147.107.6]) by smtp.gmail.com with ESMTPSA id\n\t98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 09 Dec 2025 16:32:16 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"zf1yMxU7\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765326737; x=1765931537;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=nLU/ifYTrqqo3T8wLQWtPEibbZ9LrJLctjntqk+s2D8=;\n\tb=zf1yMxU7HGX+0U2oxQM3zFrMb98Ap9UciDan+a/Jv7/Y5XXm/EWPm4x1+YKkTUB19X\n\t93/2KEPeyatYG4tIRK7BUtIuktTO1DuzSqnWRtsNKJknK+pduADGnCIfWXsPhVBCtNzO\n\tBIImsLPqM3cwJh4LXIcgP2cMXEAfHWFFjsa5Qi0DwkftjGh2RbNVWj1g57cVFtdKo2Cc\n\t/f5Xc9IYKoZJgaFfEa5N1uMzq2wA/e8yodCpW07DoChVc4K4JTPDrF7Ui5JqemlPNTlB\n\tnrMeFV0CiHmrd3Jf10L8om/kEZYk62OugD5ySy3/PjycSvF7EGk5FU0DTT8wQlUS1MPK\n\tOtiQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765326737; x=1765931537;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=nLU/ifYTrqqo3T8wLQWtPEibbZ9LrJLctjntqk+s2D8=;\n\tb=UQAJpsvb/buFRrXW8aO11p+6mwLCpowZQdL/c8EkhL5NWAf0tnXBoClO3pib+mVQDb\n\tqz9KtaxukTLqWHbJqCKng9NNDHEUNIFwZ+plVHO36DYhofR3I6NagGAQRhmJAzd6lcFo\n\tYwnTD108Ww0ec5ZEGdZj4+/2PDmpLFhp/wzBudVQ+hsVDSUWIMfZ158iuO94OptwwFrR\n\thDd/EKrijnIYZQAaU8N9PNPFHgT5h7ylc7oD1eK3xJDZp722w+fJaThwVMwLLupeQbEU\n\tCmVvvk8lW7MGjlvqge7OJxf8jQCaA/QQbjbfwffvqZD1meCyQ9OjnNt7qUadYVeLKkDH\n\tElMA==",
        "X-Gm-Message-State": "AOJu0YxGfqx00EducNmbUGK8UAjSLkLJj4o6fU+3q7GgoxdxpZZ2jZWx\n\tFtQ/g0zEY6iHhWL0NRwooa6kfNczIKVyOgkf80nSi230vwPwPtq3Ctc2qbQC51hlAoMtJ5GWsyz\n\tblHWV",
        "X-Gm-Gg": "AY/fxX5iJSZxsGqpa1zq1OjYPcjh4otVcPKR9f8pS6vni0Nz8basKSgEWXVptgNNmxs\n\to+7twyX3OVQv4Yjv6Tzmlz4xiNobnnjClaEgGfO6mhSHinbmPw+41dDASoOLURD8mjKcMH6EDJA\n\tOJJ9RIPozzAcpZh/OSfow5k14ZrMgaOCA7IyQPXCVohwRTQCvBnIv+1bFuiZ1HLkGKrKBeqk3+g\n\tUQh8BD9zg0Aqko8JDwcZ8OrNJNFrhdjG1nXyzuuUGvNqkzs8U7/87HVDrfMGoZuPrRGzdvELqJW\n\tgtuKrIIADyHZRr+6lKD3HFPPy4BxGYtXWXsL52DJBmqOdELaKgAasynlDa52vhd9Zuurs3pfGN2\n\tFpGHxoG/EbRt4KP/9iqIUrRBejZxqMiBsHReEHTtZ03dfsBYc7C9cXhFJyqjeOUNLPtTOcnaFZr\n\txQsMP8ucUBGrhsLW0posqs4uD1Vs3IMym30fRzsQNE7a/lpHb5hZZ2IECEs0B8G7bB",
        "X-Google-Smtp-Source": "AGHT+IFKNZiqjjyeqToULgHNenvAI23o6yXjUG+lj6msTTZFOxDQUZjBLP6WLO//3/y62mcxx1ouzg==",
        "X-Received": "by 2002:a17:90b:1645:b0:343:e692:f8d7 with SMTP id\n\t98e67ed59e1d1-34a728d5782mr521146a91.11.1765326737174; \n\tTue, 09 Dec 2025 16:32:17 -0800 (PST)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "pavel@ucw.cz, Hans de Goede <hdegoede@redhat.com>,\n\tMilan Zamazal <mzamazal@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "Subject": "[PATCH v4 08/20] libcamera: swstats_cpu: Add processFrame() method",
        "Date": "Wed, 10 Dec 2025 00:31:25 +0000",
        "Message-ID": "<20251210003139.43606-9-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20251210003139.43606-1-bryan.odonoghue@linaro.org>",
        "References": "<20251210003139.43606-1-bryan.odonoghue@linaro.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": "From: Hans de Goede <hdegoede@redhat.com>\n\nAdd a method to the SwstatsCpu class to process a whole Framebuffer in\none go, rather then line by line. This is useful for gathering stats\nwhen debayering is not necessary or is not done on the CPU.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n[bod: various rebase splats fixed]\n[bod: Added constructor Doxygen header]\n[bod: Squashed a fix from Hans to calculate stats on every 4th frame]\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../internal/software_isp/swstats_cpu.h       | 15 +++-\n src/libcamera/software_isp/software_isp.cpp   |  5 +-\n src/libcamera/software_isp/swstats_cpu.cpp    | 69 ++++++++++++++++++-\n 3 files changed, 84 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\nindex fae575f85..64b3e23f5 100644\n--- a/include/libcamera/internal/software_isp/swstats_cpu.h\n+++ b/include/libcamera/internal/software_isp/swstats_cpu.h\n@@ -18,18 +18,23 @@\n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/framebuffer.h\"\n+#include \"libcamera/internal/global_configuration.h\"\n #include \"libcamera/internal/shared_mem_object.h\"\n #include \"libcamera/internal/software_isp/swisp_stats.h\"\n \n+#include \"benchmark.h\"\n+\n namespace libcamera {\n \n class PixelFormat;\n+class MappedFrameBuffer;\n struct StreamConfiguration;\n \n class SwStatsCpu\n {\n public:\n-\tSwStatsCpu();\n+\tSwStatsCpu(const GlobalConfiguration &configuration);\n \t~SwStatsCpu() = default;\n \n \t/*\n@@ -50,6 +55,7 @@ public:\n \tvoid setWindow(const Rectangle &window);\n \tvoid startFrame(uint32_t frame);\n \tvoid finishFrame(uint32_t frame, uint32_t bufferId);\n+\tvoid processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input);\n \n \tvoid processLine0(uint32_t frame, unsigned int y, const uint8_t *src[])\n \t{\n@@ -79,6 +85,7 @@ public:\n \n private:\n \tusing statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[]);\n+\tusing processFrameFn = void (SwStatsCpu::*)(MappedFrameBuffer &in);\n \n \tint setupStandardBayerOrder(BayerFormat::Order order);\n \t/* Bayer 8 bpp unpacked */\n@@ -91,6 +98,10 @@ private:\n \tvoid statsBGGR10PLine0(const uint8_t *src[]);\n \tvoid statsGBRG10PLine0(const uint8_t *src[]);\n \n+\tvoid processBayerFrame2(MappedFrameBuffer &in);\n+\n+\tprocessFrameFn processFrame_;\n+\n \t/* Variables set by configure(), used every line */\n \tstatsProcessFn stats0_;\n \tstatsProcessFn stats2_;\n@@ -103,9 +114,11 @@ private:\n \tSize patternSize_;\n \n \tunsigned int xShift_;\n+\tunsigned int stride_;\n \n \tSharedMemObject<SwIspStats> sharedStats_;\n \tSwIspStats stats_;\n+\tBenchmark bench_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 341c0352c..928a2520c 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -108,14 +108,15 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \t\treturn;\n \t}\n \n-\tauto stats = std::make_unique<SwStatsCpu>();\n+\tconst GlobalConfiguration &configuration = pipe->cameraManager()->_d()->configuration();\n+\n+\tauto stats = std::make_unique<SwStatsCpu>(configuration);\n \tif (!stats->isValid()) {\n \t\tLOG(SoftwareIsp, Error) << \"Failed to create SwStatsCpu object\";\n \t\treturn;\n \t}\n \tstats->statsReady.connect(this, &SoftwareIsp::statsReady);\n \n-\tconst GlobalConfiguration &configuration = pipe->cameraManager()->_d()->configuration();\n \tdebayer_ = std::make_unique<DebayerCpu>(std::move(stats), configuration);\n \tdebayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);\n \tdebayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 55e764b0a..c931edb41 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -16,6 +16,7 @@\n #include <libcamera/stream.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/mapped_framebuffer.h\"\n \n namespace libcamera {\n \n@@ -34,6 +35,15 @@ namespace libcamera {\n  * instead of processing the whole frame.\n  */\n \n+/**\n+ * \\fn SwStatsCpu::SwStatsCpu(const GlobalConfiguration &configuration)\n+ * \\brief Construct a SwStatsCpu object\n+ * \\param[in] configuration Global configuration reference\n+ *\n+ * Creates a SwStatsCpu object and initialises shared memory for statistics\n+ * exchange.\n+ */\n+\n /**\n  * \\fn bool SwStatsCpu::isValid() const\n  * \\brief Gets whether the statistics object is valid\n@@ -144,8 +154,8 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(SwStatsCpu)\n \n-SwStatsCpu::SwStatsCpu()\n-\t: sharedStats_(\"softIsp_stats\")\n+SwStatsCpu::SwStatsCpu(const GlobalConfiguration &configuration)\n+\t: sharedStats_(\"softIsp_stats\"), bench_(configuration)\n {\n \tif (!sharedStats_)\n \t\tLOG(SwStatsCpu, Error)\n@@ -386,11 +396,14 @@ int SwStatsCpu::setupStandardBayerOrder(BayerFormat::Order order)\n  */\n int SwStatsCpu::configure(const StreamConfiguration &inputCfg)\n {\n+\tstride_ = inputCfg.stride;\n+\n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputCfg.pixelFormat);\n \n \tif (bayerFormat.packing == BayerFormat::Packing::None &&\n \t    setupStandardBayerOrder(bayerFormat.order) == 0) {\n+\t\tprocessFrame_ = &SwStatsCpu::processBayerFrame2;\n \t\tswitch (bayerFormat.bitDepth) {\n \t\tcase 8:\n \t\t\tstats0_ = &SwStatsCpu::statsBGGR8Line0;\n@@ -411,6 +424,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg)\n \t\t/* Skip every 3th and 4th line, sample every other 2x2 block */\n \t\tySkipMask_ = 0x02;\n \t\txShift_ = 0;\n+\t\tprocessFrame_ = &SwStatsCpu::processBayerFrame2;\n \n \t\tswitch (bayerFormat.order) {\n \t\tcase BayerFormat::BGGR:\n@@ -475,4 +489,55 @@ void SwStatsCpu::setWindow(const Rectangle &window)\n \twindow_.height &= ~(patternSize_.height - 1);\n }\n \n+void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in)\n+{\n+\tconst uint8_t *src = in.planes()[0].data();\n+\tconst uint8_t *linePointers[3];\n+\n+\t/* Adjust src for starting at window_.y */\n+\tsrc += window_.y * stride_;\n+\n+\tfor (unsigned int y = 0; y < window_.height; y += 2) {\n+\t\tif (y & ySkipMask_) {\n+\t\t\tsrc += stride_ * 2;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\t/* linePointers[0] is not used by any stats0_ functions */\n+\t\tlinePointers[1] = src;\n+\t\tlinePointers[2] = src + stride_;\n+\t\t(this->*stats0_)(linePointers);\n+\t\tsrc += stride_ * 2;\n+\t}\n+}\n+\n+/**\n+ * \\brief Calculate statistics for a frame in one go\n+ * \\param[in] frame The frame number\n+ * \\param[in] bufferId ID of the statistics buffer\n+ * \\param[in] input The frame to process\n+ *\n+ * This may only be called after a successful setWindow() call.\n+ */\n+void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input)\n+{\n+\tif (frame % kStatPerNumFrames) {\n+\t\tfinishFrame(frame, bufferId);\n+\t\treturn;\n+\t}\n+\n+\tbench_.startFrame();\n+\tstartFrame(frame);\n+\n+\tMappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read);\n+\tif (!in.isValid()) {\n+\t\tLOG(SwStatsCpu, Error) << \"mmap-ing buffer(s) failed\";\n+\t\treturn;\n+\t}\n+\n+\t(this->*processFrame_)(in);\n+\tfinishFrame(frame, bufferId);\n+\tbench_.finishFrame();\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "v4",
        "08/20"
    ]
}