Patch Detail
Show a patch.
GET /api/patches/23510/?format=api
{ "id": 23510, "url": "https://patchwork.libcamera.org/api/patches/23510/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23510/", "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": "<20250611013245.133785-5-bryan.odonoghue@linaro.org>", "date": "2025-06-11T01:32:14", "name": "[04/35] libcamera: software_isp: Move benchmark code to its own class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c5a0f995b18e08d412628858ecb008f6a654d64b", "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/23510/mbox/", "series": [ { "id": 5212, "url": "https://patchwork.libcamera.org/api/series/5212/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5212", "date": "2025-06-11T01:32:10", "name": "Add GLES 2.0 GPUISP to libcamera", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5212/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23510/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23510/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 91B73C3324\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 11 Jun 2025 01:33:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2780C68DBD;\n\tWed, 11 Jun 2025 03:33:14 +0200 (CEST)", "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BE1268DC3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 11 Jun 2025 03:33:12 +0200 (CEST)", "by mail-wr1-x42a.google.com with SMTP id\n\tffacd0b85a97d-3a522224582so3747629f8f.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Jun 2025 18:33:12 -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-4532514138asm5680625e9.3.2025.06.10.18.33.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Jun 2025 18:33:11 -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=\"hSvov2um\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1749605592; x=1750210392;\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=6ZXBan3FwbSk2Nm4RT9dBvDX34LkuEvl73zB9SkoswY=;\n\tb=hSvov2umOVaV99r7UsafNZe5/DvFtxXcU2vSLh5Icm4nzlYmWYsa3Y9aclaTIbDbPK\n\t1S+4kwR+nvDkeSOXSCo1VjQSkQ2JBsujqGEcGGsfZX79vYZn8Qw/Ui3BDXnkqzF2/6ub\n\tDRxBdGSY+TZL7P/nX4CgSRpCD+XkcJ31jDIYBgbKIWbFgYsoG3S6+d0hTB/oRo8uT8Jn\n\ttWewBnjOUoirJESUUyXnwR2tzmL2xNz3qgHmi1vNi/ODNObQZwnnXIsMlkF+WivRgct/\n\tki2KHVFEneyeId5eNUcrHtGhkkMjwBsBYEFMWPWGJo4jWK38cgsRbf5pBM76irgYm/wk\n\tFvPw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1749605592; x=1750210392;\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=6ZXBan3FwbSk2Nm4RT9dBvDX34LkuEvl73zB9SkoswY=;\n\tb=F0pjXpCr1o5CDPFXNZ4wh6/DDnMHaFPMHE9/Sadmp4r0bQmuUU9VZFJ8C+qBZR2t1T\n\tPWO9SEaZQQv50rXRpBkh8UhrkU8s7CB6d4/tLqEW+BkOXVfqHhtoTyYs6m/FZcGvC/hF\n\t6153O87kYEvYxup5GXWTTtScX6H942v29azq9qhvPpCnvr6IB1UbOyNwDtiPm68Kzthf\n\tOXjR2J85leDAEuAk8lrV81YaOtm0Ziaxjt4kHjimDp7LpzmlTD81K1NjiwuVOx7C3KRQ\n\tP3aijSMQol05+kT8w1TmYS2XwpsujUBi/ivV9yydxuG/8oOKuOUnTADAefjaObFPLtb0\n\tbw5g==", "X-Gm-Message-State": "AOJu0Yy4ELw3Yf7grq5ZV89WCd8ltzJr1q1j3OleyeLfq34UHubqVecR\n\tf8fhyeg5TxkWwDdP/TJMCRjKt/JBLJMraAPpxaajxOjvBGIWfEaTPRKvmJNSmGHFvrlARV8FQGG\n\tKYhIv8cI=", "X-Gm-Gg": "ASbGncvicX88Hn/yQBaU1kBWeXLyjQ5RkaudYQ7UOK8RuMONFIvoyhAACZbAXEClD4k\n\tquXt469j+jYxZkl8p1aG7CBuRbURGT4VYkYO7dNSV5AaVG1lxKWsmUFtsj6A5H6kipom0MC4rfP\n\tizaLK5raUhQh9e7IX+dQ/BGbSmuHVyORCa1IDimmfTWuA+x8dBw12Lp07l12S6WTE9p73oTrcgc\n\t46bq3hbayHxHd8LF/V4GzcaFn7isHwa+HO04Zn8SAOyheezZA+OMZotn9JmIi5S9+2XgKoAI9GC\n\tE7ThNsRDrlPoCoRLEVwmRss/GRW+NIdAgH8Hw6uFM9g4HI5+b3FNe1qJ9F4VOCmH3TpptRYqgiq\n\tBkJmGZmLdDC2/zI2AyvIasMl4P/4sQPfk6sJtXVbt0A==", "X-Google-Smtp-Source": "AGHT+IFS3Gg902FhBlh8vQnpHTi6KmXmH+HxaJEfioPW0HjqZciOQjIdzixjfPrGEUtsNyYTiJcf5A==", "X-Received": "by 2002:a05:6000:1886:b0:3a5:2653:7322 with SMTP id\n\tffacd0b85a97d-3a558691999mr782157f8f.3.1749605591808; \n\tTue, 10 Jun 2025 18:33:11 -0700 (PDT)", "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "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 04/35] libcamera: software_isp: Move benchmark code to its\n\town class", "Date": "Wed, 11 Jun 2025 02:32:14 +0100", "Message-ID": "<20250611013245.133785-5-bryan.odonoghue@linaro.org>", "X-Mailer": "git-send-email 2.49.0", "In-Reply-To": "<20250611013245.133785-1-bryan.odonoghue@linaro.org>", "References": "<20250611013245.133785-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>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../internal/software_isp/benchmark.h | 36 +++++++\n .../internal/software_isp/meson.build | 1 +\n src/libcamera/software_isp/benchmark.cpp | 93 +++++++++++++++++++\n src/libcamera/software_isp/debayer_cpu.cpp | 36 +------\n src/libcamera/software_isp/debayer_cpu.h | 7 +-\n src/libcamera/software_isp/meson.build | 1 +\n 6 files changed, 135 insertions(+), 39 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 00000000..8af25015\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/benchmark.h\n@@ -0,0 +1,36 @@\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+\n+namespace libcamera {\n+\n+class Benchmark\n+{\n+public:\n+\tBenchmark();\n+\t~Benchmark();\n+\n+\tvoid startFrame(void);\n+\tvoid finishFrame(void);\n+\n+private:\n+\tunsigned int measuredFrames_;\n+\tint64_t frameProcessTime_;\n+\ttimespec frameStartTime_;\n+\t/* Skip 30 frames for things to stabilize then measure 30 frames */\n+\tstatic constexpr unsigned int kFramesToSkip = 30;\n+\tstatic constexpr unsigned int kLastFrameToMeasure = 60;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build\nindex ea3f3f1c..df7c3b97 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 00000000..b3da3c41\n--- /dev/null\n+++ b/src/libcamera/software_isp/benchmark.cpp\n@@ -0,0 +1,93 @@\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()\n+\t: measuredFrames_(0), frameProcessTime_(0)\n+{\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+\tif (measuredFrames_ >= Benchmark::kLastFrameToMeasure)\n+\t\treturn;\n+\n+\tframeStartTime_ = {};\n+\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime_);\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 (measuredFrames_ >= Benchmark::kLastFrameToMeasure)\n+\t\treturn;\n+\n+\tmeasuredFrames_++;\n+\n+\tif (measuredFrames_ <= Benchmark::kFramesToSkip)\n+\t\treturn;\n+\n+\ttimespec frameEndTime = {};\n+\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);\n+\tframeProcessTime_ += timeDiff(frameEndTime, frameStartTime_);\n+\n+\tif (measuredFrames_ == Benchmark::kLastFrameToMeasure) {\n+\t\tconst unsigned int measuredFrames = Benchmark::kLastFrameToMeasure -\n+\t\t\t\t\t\t Benchmark::kFramesToSkip;\n+\t\tLOG(Benchmark, Info)\n+\t\t\t<< \"Processed \" << measuredFrames\n+\t\t\t<< \" frames in \" << frameProcessTime_ / 1000 << \"us, \"\n+\t\t\t<< frameProcessTime_ / (1000 * measuredFrames)\n+\t\t\t<< \" us/frame\";\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 66f6038c..8d30bf4a 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -554,9 +554,6 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg,\n \t\t\tlineBuffers_[i].resize(lineBufferLength_);\n \t}\n \n-\tmeasuredFrames_ = 0;\n-\tframeProcessTime_ = 0;\n-\n \treturn 0;\n }\n \n@@ -746,24 +743,9 @@ void DebayerCpu::process4(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-\tif (measuredFrames_ < DebayerCpu::kLastFrameToMeasure) {\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@@ -817,21 +799,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n \tdmaSyncers.clear();\n \n \t/* Measure before emitting signals */\n-\tif (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&\n-\t ++measuredFrames_ > DebayerCpu::kFramesToSkip) {\n-\t\ttimespec frameEndTime = {};\n-\t\tclock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);\n-\t\tframeProcessTime_ += timeDiff(frameEndTime, frameStartTime);\n-\t\tif (measuredFrames_ == DebayerCpu::kLastFrameToMeasure) {\n-\t\t\tconst unsigned int measuredFrames = DebayerCpu::kLastFrameToMeasure -\n-\t\t\t\t\t\t\t DebayerCpu::kFramesToSkip;\n-\t\t\tLOG(Debayer, Info)\n-\t\t\t\t<< \"Processed \" << measuredFrames\n-\t\t\t\t<< \" frames in \" << frameProcessTime_ / 1000 << \"us, \"\n-\t\t\t\t<< frameProcessTime_ / (1000 * measuredFrames)\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 89a89893..182607cd 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/software_isp/swstats_cpu.h\"\n \n@@ -160,11 +161,7 @@ private:\n \tunsigned int xShift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n \tbool swapRedBlueGains_;\n-\tunsigned int measuredFrames_;\n-\tint64_t frameProcessTime_;\n-\t/* Skip 30 frames for things to stabilize then measure 30 frames */\n-\tstatic constexpr unsigned int kFramesToSkip = 30;\n-\tstatic constexpr unsigned int kLastFrameToMeasure = 60;\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 aac7eda7..59fa5f02 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": [ "04/35" ] }