Patch Detail
Show a patch.
GET /api/1.1/patches/27008/?format=api
{ "id": 27008, "url": "https://patchwork.libcamera.org/api/1.1/patches/27008/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27008/", "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": "<20260621002305.3763752-5-laurent.pinchart@ideasonboard.com>", "date": "2026-06-21T00:23:05", "name": "[4/4] libcamera: vector: Add clamp() member function", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "68c86a39d7dda369f34abe0a884a8076ea51b1da", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27008/mbox/", "series": [ { "id": 6010, "url": "https://patchwork.libcamera.org/api/1.1/series/6010/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6010", "date": "2026-06-21T00:23:01", "name": "libcamera: vector: Add clamp() function", "version": 1, "mbox": "https://patchwork.libcamera.org/series/6010/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27008/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27008/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 5EB84C3307\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jun 2026 00:23:18 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D6439656F4;\n\tSun, 21 Jun 2026 02:23:17 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E4329656E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jun 2026 02:23:12 +0200 (CEST)", "from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1056E268;\n\tSun, 21 Jun 2026 02:22:36 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ULA9vr5u\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782001356;\n\tbh=sw9YqKgDYcqB85sXmuOJ+W8a6HWiz4GDP0cDtZxX6t8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ULA9vr5u9S6CSuuzzwq9DbeMtUzgQ1qQF1DmUaTbBn64AmL/TotseYhl6oR0W3SeX\n\t2HAsHjEmhasWXnAZl9ZS6erfcGb1YTi7tEN2nZ2/eUdjrtmKNbuZI9EXW+XsDS6xxW\n\tzbmmhBSCGGRYqrHRoozZK6oGItGef8WkaZYqv5Qk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH 4/4] libcamera: vector: Add clamp() member function", "Date": "Sun, 21 Jun 2026 03:23:05 +0300", "Message-ID": "<20260621002305.3763752-5-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>", "References": "<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>", "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: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nProvide a member function that performs a std::clamp() given a scalar\nhigh and low values to clamp to.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since Kieran's version:\n\n- Use apply()\n- Fix typos in commit message\n---\n include/libcamera/internal/vector.h | 7 +++++++\n src/libcamera/vector.cpp | 8 ++++++++\n test/vector.cpp | 1 +\n 3 files changed, 16 insertions(+)", "diff": "diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h\nindex 7c90d6542352..0270651a0ef7 100644\n--- a/include/libcamera/internal/vector.h\n+++ b/include/libcamera/internal/vector.h\n@@ -185,6 +185,13 @@ public:\n \t\treturn apply(*this, [](T a, T b) -> T { return std::max(a, b); }, scalar);\n \t}\n \n+\tconstexpr Vector clamp(T low, T high) const\n+\t{\n+\t\treturn apply(*this,\n+\t\t\t [](T v, T lo, T hi) -> T { return std::clamp(v, lo, hi); },\n+\t\t\t low, high);\n+\t}\n+\n \tconstexpr T dot(const Vector<T, Rows> &other) const\n \t{\n \t\tT ret = 0;\ndiff --git a/src/libcamera/vector.cpp b/src/libcamera/vector.cpp\nindex 47b3d1af36d9..a135ab498e17 100644\n--- a/src/libcamera/vector.cpp\n+++ b/src/libcamera/vector.cpp\n@@ -224,6 +224,14 @@ LOG_DEFINE_CATEGORY(Vector)\n * \\return The element-wise maximum of this vector and \\a scalar\n */\n \n+/**\n+ * \\fn Vector::clamp(T low, T high) const\n+ * \\brief Clamp the vector element-wise between \\a low and \\a high\n+ * \\param[in] low The lower limit\n+ * \\param[in] high The upper limit\n+ * \\return A vector with each element clamped between \\a low and \\a high\n+ */\n+\n /**\n * \\fn Vector::dot(const Vector<T, Rows> &other) const\n * \\brief Compute the dot product\ndiff --git a/test/vector.cpp b/test/vector.cpp\nindex 4ff908e8f682..2f3d97d93dcc 100644\n--- a/test/vector.cpp\n+++ b/test/vector.cpp\n@@ -72,6 +72,7 @@ protected:\n \t\tASSERT_EQ(v2.min(4.0), (Vector<double, 3>{{ 1.0, 4.0, 4.0 }}));\n \t\tASSERT_EQ(v2.max(v3), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n \t\tASSERT_EQ(v2.max(4.0), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n+\t\tASSERT_EQ(v2.clamp(2.0, 6.0), (Vector<double, 3>{{ 2.0, 4.0, 6.0 }}));\n \n \t\tASSERT_EQ(v2.dot(v3), 52.0);\n \n", "prefixes": [ "4/4" ] }