Patch Detail
Show a patch.
GET /api/patches/25501/?format=api
{ "id": 25501, "url": "https://patchwork.libcamera.org/api/patches/25501/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25501/", "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": "<20251211232246.31330-8-bryan.odonoghue@linaro.org>", "date": "2025-12-11T23:22:32", "name": "[v5,07/20] libcamera: software_isp: Move benchmark code to its own class", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e649df0ecaf565f7fcee3de762f7979ab1801975", "submitter": { "id": 175, "url": "https://patchwork.libcamera.org/api/people/175/?format=api", "name": "Bryan O'Donoghue", "email": "bryan.odonoghue@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25501/mbox/", "series": [ { "id": 5656, "url": "https://patchwork.libcamera.org/api/series/5656/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5656", "date": "2025-12-11T23:22:25", "name": "GPUISP precursor series", "version": 5, "mbox": "https://patchwork.libcamera.org/series/5656/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25501/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25501/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 52487C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Dec 2025 23:23:39 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F1CE61643;\n\tFri, 12 Dec 2025 00:23:39 +0100 (CET)", "from mail-pf1-x430.google.com (mail-pf1-x430.google.com\n\t[IPv6:2607:f8b0:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C04506162E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Dec 2025 00:23:37 +0100 (CET)", "by mail-pf1-x430.google.com with SMTP id\n\td2e1a72fcca58-7ade456b6abso498248b3a.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Dec 2025 15:23:37 -0800 (PST)", "from inspiron14p-linux (M106185144161.v4.enabler.ne.jp.\n\t[106.185.144.161]) by smtp.gmail.com with ESMTPSA id\n\td2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 11 Dec 2025 15:23:35 -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=\"pFVETq9Z\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765495416; x=1766100216;\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=yyoWJ0Rzqed6amy1jTZnt8wvjKyWv6LvwRUBP/6g4Vc=;\n\tb=pFVETq9ZUY1ZCsVxxPv//3v8ywHNkah/2vvxPc9SmJsBfW46jnvKNEZu/0n6I/qspQ\n\tk977NrhG7rXs7tdHgCmQ4vM0el8f1HDBYIZr3kYFd1FAl9gipvO2LKMF9QnS3y73RbGl\n\tF+RBM5Y1qvSu9+ruBu+j7oegO9Zj8+YQVfaw/OR8EokqfQ9aPccDUgpjuOSLXaOh+IKt\n\tnb35R6nFszFAGlp4lHpFS5ASdwtuHzcSkaLlo566nHsrlF95kkqY8aEuTucj0C2+op23\n\teAAYA+lO/Q9phtPOlpVMVAI1jHRKl95hz6REg+WUfSGHwYtj6p3BYgs+/Gu0Clklnq0t\n\tLdRg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765495416; x=1766100216;\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=yyoWJ0Rzqed6amy1jTZnt8wvjKyWv6LvwRUBP/6g4Vc=;\n\tb=RsaYpgz6L+i8mR31HELuU4w5o8zuGBgzC9FaFgDLGU6b/dqfciYQ4r7ZDAauVWWvoE\n\tBUNzFFi1W1iekqsLgkaOXlSXIzwX71U2xEHTj9RWsIzaC1O73mTia9YOf8S5ZZTpoUHn\n\t1e4sfSWYIj4LaikzOghqcvDfpcKJoeWacwgJQdsA5holFw5Wq1KOjEJrjDj6QrrgbJMm\n\tlM1RbsYLFSeRdYIostdsrYZ+kfxbkQrCUQK5U9pP3KzJlFO3EyTfU+oi3r6iSGNmsWKu\n\tLeqpCwRBr3HWkhPFb7ga0aJKI1tg5sJ1Tz9I4+U2LouP3olqCexiew+nmcSqW20nnsbe\n\towtw==", "X-Gm-Message-State": "AOJu0YwJZwpFVwH+d/AGCViX8mKyeSer4/7PySkRqASYjlxeQuVksWx+\n\tgFopuji2GCK0rWuW5Z2nNQnImj4TSmymaYO6WkqF8vRj1achi4sUwhMgtN0/u0NA61wRflkn9J5\n\tyu22n", "X-Gm-Gg": "AY/fxX5MECzUT04Ekk0u1LDPYdKpv92UDoGa/ApzKTzxHzZ+z7/o7CDUModVhX690fg\n\tsGp6TmeyGMoJIQ2yO8UIj+5QIoiHZ5Plg9HOlnsaw7lUqTeIR9I3lKsu57qpeTsGJ3WImZZRNu7\n\tOetpXQMaq6GVpNbH3MrKMkiTm7BljRnAi08lYdOOLFoQnaoU/6Ehwvz2eg2SbKpRDSVP+o2FKN0\n\tcBuIbgYo5qx5HeT0Z7FxWKj0NSAy5MKKV84D6As0Td++4xhWGmD7F9cUWwK5VEjlmWn5p18lCw+\n\tmqJd7ONVw9KP2z6HoOv2Y4TQvj4ksahdCEO/UmT6EkCfHHquujevSrbsMSBbaduImP1rzp4DrYj\n\tSSGGMLCkpw8kPWBokR76EZzznbXMarzXUDgEjDMPSW6/8rnO5kJnzNHGiY04ilFwHNT3CcvOCcF\n\tHJ+EyK4JxHEDa6cq0qYwjQj7Q1gfJZctRMDbb1MHZ3ArY7qiJzpTZZmwigAdHmjw==", "X-Google-Smtp-Source": "AGHT+IGbE1aZD3b8OZ3QcYgnlyk0aKGnmJvYcOviuY7pnbknc8oKcXDIT1qMeiVLq3A42cpApSppvw==", "X-Received": "by 2002:a05:6a00:1d9d:b0:7e8:4471:8d0 with SMTP id\n\td2e1a72fcca58-7f669a93165mr161366b3a.49.1765495416130; \n\tThu, 11 Dec 2025 15:23:36 -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\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tMilan Zamazal <mzamazal@redhat.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>", "Subject": "[PATCH v5 07/20] libcamera: software_isp: Move benchmark code to its\n\town class", "Date": "Thu, 11 Dec 2025 23:22:32 +0000", "Message-ID": "<20251211232246.31330-8-bryan.odonoghue@linaro.org>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20251211232246.31330-1-bryan.odonoghue@linaro.org>", "References": "<20251211232246.31330-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\nMove the code for the builtin benchmark to its own small\nBenchmark class.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n[bod: Fixed up some drift in this patch since initial propostion]\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../internal/software_isp/benchmark.h | 39 ++++++++\n .../internal/software_isp/meson.build | 1 +\n src/libcamera/software_isp/benchmark.cpp | 92 +++++++++++++++++++\n src/libcamera/software_isp/debayer_cpu.cpp | 45 +--------\n src/libcamera/software_isp/debayer_cpu.h | 6 +-\n src/libcamera/software_isp/meson.build | 1 +\n 6 files changed, 138 insertions(+), 46 deletions(-)\n create mode 100644 include/libcamera/internal/software_isp/benchmark.h\n create mode 100644 src/libcamera/software_isp/benchmark.cpp", "diff": "diff --git a/include/libcamera/internal/software_isp/benchmark.h b/include/libcamera/internal/software_isp/benchmark.h\nnew file mode 100644\nindex 000000000..0680d6cd9\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/benchmark.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Red Hat Inc.\n+ *\n+ * Authors:\n+ * Hans de Goede <hdegoede@redhat.com>\n+ *\n+ * Simple builtin benchmark to measure software ISP processing times\n+ */\n+\n+#pragma once\n+\n+#include <stdint.h>\n+#include <time.h>\n+#include <libcamera/base/log.h>\n+#include \"libcamera/internal/global_configuration.h\"\n+\n+namespace libcamera {\n+\n+class Benchmark\n+{\n+public:\n+\tBenchmark(const GlobalConfiguration &configuration);\n+\t~Benchmark();\n+\n+\tvoid startFrame(void);\n+\tvoid finishFrame(void);\n+\n+private:\n+\ttimespec frameStartTime_;\n+\tbool measure;\n+\t/* Skip 30 frames for things to stabilize then measure 30 frames */\n+\tunsigned int encounteredFrames_ = 0;\n+\tint64_t frameProcessTime_ = 0;\n+\tunsigned int skipBeforeMeasure_ = 30;\n+\tunsigned int framesToMeasure_ = 30;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build\nindex ea3f3f1c1..df7c3b97d 100644\n--- a/include/libcamera/internal/software_isp/meson.build\n+++ b/include/libcamera/internal/software_isp/meson.build\n@@ -1,6 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libcamera_internal_headers += files([\n+ 'benchmark.h',\n 'debayer_params.h',\n 'software_isp.h',\n 'swisp_stats.h',\ndiff --git a/src/libcamera/software_isp/benchmark.cpp b/src/libcamera/software_isp/benchmark.cpp\nnew file mode 100644\nindex 000000000..1a00ae569\n--- /dev/null\n+++ b/src/libcamera/software_isp/benchmark.cpp\n@@ -0,0 +1,92 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Red Hat Inc.\n+ *\n+ * Authors:\n+ * Hans de Goede <hdegoede@redhat.com>\n+ *\n+ * Simple builtin benchmark to measure software ISP processing times\n+ */\n+\n+#include \"libcamera/internal/software_isp/benchmark.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Benchmark)\n+\n+/**\n+ * \\class Benchmark\n+ * \\brief Simple builtin benchmark\n+ *\n+ * Simple builtin benchmark to measure software ISP processing times.\n+ */\n+\n+/**\n+ * \\brief Constructs a Benchmark object\n+ */\n+Benchmark::Benchmark(const GlobalConfiguration &configuration)\n+{\n+\tskipBeforeMeasure_ = configuration.option<unsigned int>(\n+\t\t\t\t\t\t{ \"software_isp\", \"measure\", \"skip\" })\n+\t\t\t\t\t\t\t.value_or(skipBeforeMeasure_);\n+\tframesToMeasure_ = configuration.option<unsigned int>(\n+\t\t\t\t\t\t{ \"software_isp\", \"measure\", \"number\" })\n+\t\t\t\t\t\t\t.value_or(framesToMeasure_);\n+}\n+\n+Benchmark::~Benchmark()\n+{\n+}\n+\n+static inline int64_t timeDiff(timespec &after, timespec &before)\n+{\n+\treturn (after.tv_sec - before.tv_sec) * 1000000000LL +\n+\t (int64_t)after.tv_nsec - (int64_t)before.tv_nsec;\n+}\n+\n+/**\n+ * \\brief Start measuring process time for a single frame\n+ *\n+ * Call this function before processing frame data to start measuring\n+ * the process time for a frame.\n+ */\n+void Benchmark::startFrame(void)\n+{\n+\tmeasure = framesToMeasure_ > 0 &&\n+\t\t encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ &&\n+\t\t ++encounteredFrames_ > skipBeforeMeasure_;\n+\n+\tif (measure) {\n+\t\tframeStartTime_ = {};\n+\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime_);\n+\t}\n+}\n+\n+/**\n+ * \\brief Finish measuring process time for a single frame\n+ *\n+ * Call this function after processing frame data to finish measuring\n+ * the process time for a frame.\n+ *\n+ * This function will log frame processing time information after\n+ * Benchmark::kLastFrameToMeasure frames have been processed.\n+ */\n+void Benchmark::finishFrame(void)\n+{\n+\tif (measure) {\n+\t\ttimespec frameEndTime = {};\n+\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);\n+\t\tframeProcessTime_ += timeDiff(frameEndTime, frameStartTime_);\n+\t\tif (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) {\n+\t\t\tLOG(Benchmark, Info)\n+\t\t\t\t<< \"Processed \" << framesToMeasure_\n+\t\t\t\t<< \" frames in \" << frameProcessTime_ / 1000 << \"us, \"\n+\t\t\t\t<< frameProcessTime_ / (1000 * framesToMeasure_)\n+\t\t\t\t<< \" us/frame\";\n+\t\t}\n+\t}\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 67a303c65..b92c6a904 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -42,7 +42,7 @@ namespace libcamera {\n * \\param[in] configuration The global configuration\n */\n DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const GlobalConfiguration &configuration)\n-\t: stats_(std::move(stats))\n+\t: stats_(std::move(stats)), bench_(configuration)\n {\n \t/*\n \t * Reading from uncached buffers may be very slow.\n@@ -58,13 +58,6 @@ DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const GlobalConfigurat\n \tenableInputMemcpy_ =\n \t\tconfiguration.option<bool>({ \"software_isp\", \"copy_input_buffer\" }).value_or(true);\n \n-\tskipBeforeMeasure_ = configuration.option<unsigned int>(\n-\t\t\t\t\t\t { \"software_isp\", \"measure\", \"skip\" })\n-\t\t\t\t .value_or(skipBeforeMeasure_);\n-\tframesToMeasure_ = configuration.option<unsigned int>(\n-\t\t\t\t\t\t{ \"software_isp\", \"measure\", \"number\" })\n-\t\t\t\t .value_or(framesToMeasure_);\n-\n \t/* Initialize color lookup tables */\n \tfor (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {\n \t\tred_[i] = green_[i] = blue_[i] = i;\n@@ -571,9 +564,6 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg,\n \t\t\tlineBuffers_[i].resize(lineBufferLength_);\n \t}\n \n-\tencounteredFrames_ = 0;\n-\tframeProcessTime_ = 0;\n-\n \treturn 0;\n }\n \n@@ -765,27 +755,9 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst)\n \t}\n }\n \n-namespace {\n-\n-inline int64_t timeDiff(timespec &after, timespec &before)\n-{\n-\treturn (after.tv_sec - before.tv_sec) * 1000000000LL +\n-\t (int64_t)after.tv_nsec - (int64_t)before.tv_nsec;\n-}\n-\n-} /* namespace */\n-\n void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n {\n-\ttimespec frameStartTime;\n-\n-\tbool measure = framesToMeasure_ > 0 &&\n-\t\t encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ &&\n-\t\t ++encounteredFrames_ > skipBeforeMeasure_;\n-\tif (measure) {\n-\t\tframeStartTime = {};\n-\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime);\n-\t}\n+\tbench_.startFrame();\n \n \tstd::vector<DmaSyncer> dmaSyncers;\n \tfor (const FrameBuffer::Plane &plane : input->planes())\n@@ -840,18 +812,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n \tdmaSyncers.clear();\n \n \t/* Measure before emitting signals */\n-\tif (measure) {\n-\t\ttimespec frameEndTime = {};\n-\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);\n-\t\tframeProcessTime_ += timeDiff(frameEndTime, frameStartTime);\n-\t\tif (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) {\n-\t\t\tLOG(Debayer, Info)\n-\t\t\t\t<< \"Processed \" << framesToMeasure_\n-\t\t\t\t<< \" frames in \" << frameProcessTime_ / 1000 << \"us, \"\n-\t\t\t\t<< frameProcessTime_ / (1000 * framesToMeasure_)\n-\t\t\t\t<< \" us/frame\";\n-\t\t}\n-\t}\n+\tbench_.finishFrame();\n \n \t/*\n \t * Buffer ids are currently not used, so pass zeros as its parameter.\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 1cd411f26..aff32491e 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -17,6 +17,7 @@\n \n #include <libcamera/base/object.h>\n \n+#include \"libcamera/internal/software_isp/benchmark.h\"\n #include \"libcamera/internal/bayer_format.h\"\n #include \"libcamera/internal/global_configuration.h\"\n #include \"libcamera/internal/software_isp/swstats_cpu.h\"\n@@ -161,10 +162,7 @@ private:\n \tunsigned int xShift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n \tbool swapRedBlueGains_;\n-\tunsigned int encounteredFrames_;\n-\tint64_t frameProcessTime_;\n-\tunsigned int skipBeforeMeasure_ = 30;\n-\tunsigned int framesToMeasure_ = 30;\n+\tBenchmark bench_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build\nindex aac7eda7b..59fa5f02a 100644\n--- a/src/libcamera/software_isp/meson.build\n+++ b/src/libcamera/software_isp/meson.build\n@@ -8,6 +8,7 @@ if not softisp_enabled\n endif\n \n libcamera_internal_sources += files([\n+ 'benchmark.cpp',\n 'debayer.cpp',\n 'debayer_cpu.cpp',\n 'software_isp.cpp',\n", "prefixes": [ "v5", "07/20" ] }