Show a patch.

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

{
    "id": 26998,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26998/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26998/",
    "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": "<20260621-kbingham-awb-saturation-v1-1-b91ea59c6cfb@ideasonboard.com>",
    "date": "2026-06-20T23:00:28",
    "name": "[1/7] libcamera: vector: Add clamp operation",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "d399256626d024ff41e1cb4414ed1895b3cff748",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26998/mbox/",
    "series": [
        {
            "id": 6009,
            "url": "https://patchwork.libcamera.org/api/1.1/series/6009/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6009",
            "date": "2026-06-20T23:00:27",
            "name": "softisp: Fix Saturation and Black level handling",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/6009/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26998/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26998/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 CEA73C3303\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 20 Jun 2026 23:00:45 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1142365702;\n\tSun, 21 Jun 2026 01:00:40 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13AD2656D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jun 2026 01:00:36 +0200 (CEST)",
            "from [192.168.0.240]\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B875CB8B;\n\tSun, 21 Jun 2026 00:59:58 +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=\"i7vb/rGr\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781996398;\n\tbh=9qKWrXCM3qnZu1o6pRQj8bxGCCmlSd/kEaWHYvvQaPo=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=i7vb/rGrMja1RtZGp5eo+td7S0iFW/w3JAF13Um4Phw0FPoZoL2/LgXPn5fkqQRcQ\n\tyTJCJXio+vxhhkZhGkrRk/eiOF+nsYeB4fRrVD7BKazHHBL2ZWEJ+WQOFJZFGA4fP1\n\tgBQShtIMI0xT3r6cZX4tQVpaKYoThHboBNPbTAlM=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Date": "Sun, 21 Jun 2026 00:00:28 +0100",
        "Subject": "[PATCH 1/7] libcamera: vector: Add clamp operation",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Message-Id": "<20260621-kbingham-awb-saturation-v1-1-b91ea59c6cfb@ideasonboard.com>",
        "References": "<20260621-kbingham-awb-saturation-v1-0-b91ea59c6cfb@ideasonboard.com>",
        "In-Reply-To": "<20260621-kbingham-awb-saturation-v1-0-b91ea59c6cfb@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "b4 0.14.2",
        "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1781996434; l=2357;\n\ti=kieran.bingham@ideasonboard.com; s=20260204;\n\th=from:subject:message-id; \n\tbh=9qKWrXCM3qnZu1o6pRQj8bxGCCmlSd/kEaWHYvvQaPo=;\n\tb=wcBL9tQXhGZHKwNGQKtPeZHXRoIGu923Cnic5hspX+2KXHKq3qEsZuk8o5ZsteAFQocNOrEz2\n\t8z2hFZ33oHaBw6T0s41gPtPE8kKvyb3F6OmpbrqGcoA4tB+VWE9ieeR",
        "X-Developer-Key": "i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY=",
        "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": "Provide a helper that will perform a std::clamp given a scaler high and\nlow value to clamp to.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/vector.h | 8 ++++++++\n src/libcamera/vector.cpp            | 8 ++++++++\n test/vector.cpp                     | 1 +\n 3 files changed, 17 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h\nindex 093efafa8982fe553a953316ac794bef46eec5d4..17ecbda50f2dc4363548a4a29639a751a187dac6 100644\n--- a/include/libcamera/internal/vector.h\n+++ b/include/libcamera/internal/vector.h\n@@ -185,6 +185,14 @@ public:\n \t\treturn apply(*this, scalar, [](T a, T b) -> T { return std::max(a, b); });\n \t}\n \n+\tconstexpr Vector clamp(T low, T high) const\n+\t{\n+\t\tVector result;\n+\t\tfor (unsigned int i = 0; i < Rows; i++)\n+\t\t\tresult[i] = std::clamp(data_[i], low, high);\n+\t\treturn result;\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 47b3d1af36d90f9719c527b8458fbfe07412239e..a135ab498e17149b9dc54de7204e8a34262a2da9 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 4ff908e8f682f19d65c55d071fcd300071cf90ac..2f3d97d93dccbe153f2d1cf536423f7446a22aab 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": [
        "1/7"
    ]
}