Patch Detail
Show a patch.
GET /api/1.1/patches/22191/?format=api
{ "id": 22191, "url": "https://patchwork.libcamera.org/api/1.1/patches/22191/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22191/", "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": "<20241205192519.49104-6-hdegoede@redhat.com>", "date": "2024-12-05T19:25:19", "name": "[resend,5/5] libcamera: swstats_cpu: Add processFrame() method", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "2d17decffe9749a830f95c0f75ce6aaed8ab3e81", "submitter": { "id": 102, "url": "https://patchwork.libcamera.org/api/1.1/people/102/?format=api", "name": "Hans de Goede", "email": "hdegoede@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22191/mbox/", "series": [ { "id": 4853, "url": "https://patchwork.libcamera.org/api/1.1/series/4853/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4853", "date": "2024-12-05T19:25:14", "name": "libcamera: Add swstats_cpu::processFrame()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4853/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22191/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22191/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 B6BE7C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 5 Dec 2024 19:25:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6653666122;\n\tThu, 5 Dec 2024 20:25:42 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 770B266116\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 5 Dec 2024 20:25:39 +0100 (CET)", "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-688-4DIuD31APMqNO8nfP5IATw-1;\n\tThu, 05 Dec 2024 14:25:37 -0500", "from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.15])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid 352791955EB3 for <libcamera-devel@lists.libcamera.org>;\n\tThu, 5 Dec 2024 19:25:36 +0000 (UTC)", "from localhost.localdomain (unknown [10.39.192.39])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 0B97E19560A0; Thu, 5 Dec 2024 19:25:34 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"ANXr28u2\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1733426738;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=VcG0lGOjHrsKtfowIFSdgN7NPkKe4C7E7661F7gCJF8=;\n\tb=ANXr28u29G2E2jpt+2beYlcVxx3BpAKPOizkfAhXCbkY36zz2dPTaKdm7cph9uXGgpmr58\n\tF8lRXlvyaNvcBanrgI8RQRbR2p0/ID/IhOws1l0H2GN2rqo0vblwG57i/Hu9Bh/kqQ1JPk\n\t9rR6zR5cO7dmVXTX4RHcq4LNXOI3QLE=", "X-MC-Unique": "4DIuD31APMqNO8nfP5IATw-1", "X-Mimecast-MFC-AGG-ID": "4DIuD31APMqNO8nfP5IATw", "From": "Hans de Goede <hdegoede@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>, Hans de Goede <hdegoede@redhat.com>", "Subject": "[PATCH resend 5/5] libcamera: swstats_cpu: Add processFrame() method", "Date": "Thu, 5 Dec 2024 20:25:19 +0100", "Message-ID": "<20241205192519.49104-6-hdegoede@redhat.com>", "In-Reply-To": "<20241205192519.49104-1-hdegoede@redhat.com>", "References": "<20241205192519.49104-1-hdegoede@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.15", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "wggMOiqjXCfYqjIEFQDCaQvRCNNQ8mXzoHunXJWhrp0_1733426736", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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 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()\n---\n .../internal/software_isp/swstats_cpu.h | 12 +++++\n src/libcamera/software_isp/swstats_cpu.cpp | 51 +++++++++++++++++++\n 2 files changed, 63 insertions(+)", "diff": "diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\nindex 26a2f462..fa47cec9 100644\n--- a/include/libcamera/internal/software_isp/swstats_cpu.h\n+++ b/include/libcamera/internal/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 */\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex aa5654dc..1ff15f5b 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 */\n", "prefixes": [ "resend", "5/5" ] }