Show a patch.

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

{
    "id": 23220,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/23220/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23220/",
    "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": "<20250422215920.4297-8-bryan.odonoghue@linaro.org>",
    "date": "2025-04-22T21:59:00",
    "name": "[07/27] libcamera: swstats_cpu: Add processFrame() method",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": false,
    "hash": "e127176207be0a23467cd1c0eaf5a03fffceeeba",
    "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/23220/mbox/",
    "series": [
        {
            "id": 5142,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5142/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5142",
            "date": "2025-04-22T21:58:53",
            "name": "RFC: Add in a eGL based GPUISP in libcamera",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5142/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23220/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23220/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 2C1D4C331F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Apr 2025 21:59:36 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C748A68B2E;\n\tTue, 22 Apr 2025 23:59:35 +0200 (CEST)",
            "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1CFA868ADC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Apr 2025 23:59:30 +0200 (CEST)",
            "by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-43cebe06e9eso47638665e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Apr 2025 14:59:30 -0700 (PDT)",
            "from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie.\n\t[188.141.3.146]) by smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-44092d2eccesm2726615e9.20.2025.04.22.14.59.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Apr 2025 14:59:28 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"mmrfnrki\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1745359169; x=1745963969;\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=0Ek6jmyDtRYKIUfKdQ2Duk5zmK3pCbgsZ+bQyRX+gec=;\n\tb=mmrfnrkixhkvZdaunLhDPWfdHBP9+BRKQHNFa8TLQi8KPKxJf6/B0pDxuenryla+dd\n\tHgRCvqR4JZT4n465qYzxOiw8dLysT7st0KtjDbJar9JbSlCSTJjKl7SbeokcARh7ewZQ\n\tKACGAvo/YuNJSCT2M0TC8ry/H8zTpvvIPh0pRGWNHdQMUUpR3etYcMOY/LMuOkA4pbFc\n\tAwa+FlIl7InhcLppOC99QOaRCuZLGdiV5FNc36dJsw6SD7mYDPg6HHPBunM4ZTX6pNuL\n\toyfX4fvv/t5rqa0xbhHVhAavGjA+IhQkqVVaqW+IIoHtNgaZ0RYxTE64eiCM0IHFkVS+\n\t0ghw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1745359169; x=1745963969;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=0Ek6jmyDtRYKIUfKdQ2Duk5zmK3pCbgsZ+bQyRX+gec=;\n\tb=pMvoK1bDborg0Zoj58LqWyICbfWskhiqnMoymN+jFREUxwFXbKOF9g+QarhBgux5Tt\n\tif3GaUWDa6Rlg5IGo8LFREDAqI1As22vJJ1GIGLoD+JE/+aBlVduOqxz49B6RREtfkEO\n\tJKbr8ILsM6cc/APrpL/LsuHghqUaczM7G7LVP/5dkLrJ46FKAbZn9nudt+cNKVJbx+jU\n\t0FeEKHEruzcvkJILhEKS748PxMOqeeUYLsc+Sf6YhtYGeNm/wiEJr1Vv4U7HJj3zMHRv\n\tHFOR42t2LDM4/HragtniVg5pNvnGMzRavA00SfmycQXwqWa9HwoAA8X4AZby/Bpfdahw\n\tMObA==",
        "X-Gm-Message-State": "AOJu0YzoUj7QVzWIDfS4s828LABaYI1ZySwruC3Dohm12mxabdxN+AG+\n\t+A9R2vgEeMU2dpKEVuMj1U6xXDM0aaQZU8o9pRxMO3tULYPSK2wyeq7G7QqggmACZgL1DKxuKJV\n\tMe+Y=",
        "X-Gm-Gg": "ASbGnctZmYIbvMFXP7aLfWQPfnACRFWUyP/Y+A9NIVrcDnthCXKavNPcHUFvEveLskd\n\tglfAq4LjLDFr3Og/Nug5a6Lp6XOkRaVLga8LdI1K+ZKZsVE4LveaWzsgiQeVq1H1IAUGaJ7eHT7\n\txHsrAR+KUeur/IIgWy6HUwQodm+CT53+sD/FTie41t1HL4hL+DtPK889JEiD/Us5xlGtV5I+JA4\n\tCFHVi1Wg9r2zrdIs59SRv3NZUZf5ciEoim3HOVx2A52V5YvMdxLG4gTF132PMSRHGrjfXcrdL5C\n\t36wg852SaJIxhPhOVMRm8pHcIhBDvHVobmhSyp7LxLUFRz9+Rrj9jOsu5xRZ8bNAClacxEMsGeT\n\tX7kqT2fEtdJGiLsYvlh68",
        "X-Google-Smtp-Source": "AGHT+IHmZmFyH8dP26NLUxZpRzrfIDqhpoAvHdN+xIYOB6zlvzv1v5Hk7cI1KkWr0p5qV6qNUB76iQ==",
        "X-Received": "by 2002:a05:600c:5491:b0:43c:eeee:b706 with SMTP id\n\t5b1f17b1804b1-4406abf93c8mr136303875e9.24.1745359169461; \n\tTue, 22 Apr 2025 14:59:29 -0700 (PDT)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org,\n\tbod.linux@nxsw.ie",
        "Subject": "[PATCH 07/27] libcamera: swstats_cpu: Add processFrame() method",
        "Date": "Tue, 22 Apr 2025 22:59:00 +0100",
        "Message-ID": "<20250422215920.4297-8-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250422215920.4297-1-bryan.odonoghue@linaro.org>",
        "References": "<20250422215920.4297-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---\nChanges since the RFC:\n- Make processFrame() call startFrame() and finishFrame() rather then\n  making the caller do this\n- Add doxygen documentation for processFrame()\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n src/libcamera/software_isp/swstats_cpu.cpp | 51 ++++++++++++++++++++++\n src/libcamera/software_isp/swstats_cpu.h   | 12 +++++\n 2 files changed, 63 insertions(+)",
    "diff": "diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 5e4246a9..af407b4d 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@@ -360,11 +361,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@@ -385,6 +389,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@@ -425,4 +430,50 @@ 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+\tbench_.startFrame();\n+\tstartFrame();\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 */\ndiff --git a/src/libcamera/software_isp/swstats_cpu.h b/src/libcamera/software_isp/swstats_cpu.h\nindex 26a2f462..fa47cec9 100644\n--- a/src/libcamera/software_isp/swstats_cpu.h\n+++ b/src/libcamera/software_isp/swstats_cpu.h\n@@ -18,12 +18,16 @@\n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/framebuffer.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@@ -42,6 +46,7 @@ public:\n \tvoid setWindow(const Rectangle &window);\n \tvoid startFrame();\n \tvoid finishFrame(uint32_t frame, uint32_t bufferId);\n+\tvoid processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input);\n \n \tvoid processLine0(unsigned int y, const uint8_t *src[])\n \t{\n@@ -65,6 +70,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@@ -77,6 +83,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@@ -89,9 +99,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 */\n",
    "prefixes": [
        "07/27"
    ]
}