Show a patch.

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

{
    "id": 26200,
    "url": "https://patchwork.libcamera.org/api/patches/26200/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26200/",
    "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": "<20260219-kbingham-quantizers-v8-2-2b6ff68ead26@ideasonboard.com>",
    "date": "2026-02-19T15:05:03",
    "name": "[v8,02/15] test: libipa: Add tests for Quantized types",
    "commit_ref": "cb40945db608bfa7db39934a01eedb7726d780df",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "71324b6250f8172d5a537ad003245fa0774cce00",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26200/mbox/",
    "series": [
        {
            "id": 5802,
            "url": "https://patchwork.libcamera.org/api/series/5802/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5802",
            "date": "2026-02-19T15:05:01",
            "name": "libipa: Introduce a Quantized type",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/5802/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26200/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26200/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 8F079C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Feb 2026 15:05:21 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 419D36226A;\n\tThu, 19 Feb 2026 16:05:15 +0100 (CET)",
            "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 6482D62254\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Feb 2026 16:05:09 +0100 (CET)",
            "from ping.linuxembedded.co.uk\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 B6043F52;\n\tThu, 19 Feb 2026 16:04:15 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uq386DdE\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771513455;\n\tbh=f1zkzThiM9e+EqzOBESZJHTkIUbFBF32VPJtpPWPfvc=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=uq386DdEyXRwa4t/57GM01ZEfLmrutyB/zZHyjqYEMtA9h7keVehd0LTDFkspOer/\n\tNDDq7gPQYCGzPN1bEkij7MrlqOVUiEfsMvXBQCz8R+JkQN6p3LGYyCGiQLsTLUsIsh\n\tL2G2f7B8oXkRPN5Y5MEDZMm2YKnEgPSjiuIeXviw=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Date": "Thu, 19 Feb 2026 15:05:03 +0000",
        "Subject": "[PATCH v8 02/15] test: libipa: Add tests for Quantized types",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Message-Id": "<20260219-kbingham-quantizers-v8-2-2b6ff68ead26@ideasonboard.com>",
        "References": "<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>",
        "In-Reply-To": "<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tIsaac Scott <isaac.scott@ideasonboard.com>, \n\tPaul Elder <paul.elder@ideasonboard.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tStefan Klug <stefan.klug@ideasonboard.com>",
        "X-Mailer": "b4 0.14.3",
        "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1771513507; l=4765;\n\ti=kieran.bingham@ideasonboard.com; s=20260207;\n\th=from:subject:message-id; \n\tbh=f1zkzThiM9e+EqzOBESZJHTkIUbFBF32VPJtpPWPfvc=;\n\tb=9oh/u9y+TbIaWTFeWHauEPkyZNwXU5kXbkeBMFtJhg5kjh3Fdv3I/0BVLszuyWY/sH9PmoeOF\n\tMurqUDqJILMAKXxx3CIjoSy9OHS5wm2uRwwrxiBN1HNQ7MSWx9pHwBj",
        "X-Developer-Key": "i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY=",
        "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 use case tests for the Quantized types to ensure construction\nand usages are consistent and work as expected.\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\n\nv8:\n - Only use uint8_t\n - Don't output on success\n---\n test/ipa/libipa/meson.build   |   1 +\n test/ipa/libipa/quantized.cpp | 145 ++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 146 insertions(+)",
    "diff": "diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build\nindex 2070bed70222..c3e255871f4f 100644\n--- a/test/ipa/libipa/meson.build\n+++ b/test/ipa/libipa/meson.build\n@@ -5,6 +5,7 @@ libipa_test = [\n     {'name': 'histogram', 'sources': ['histogram.cpp']},\n     {'name': 'interpolator', 'sources': ['interpolator.cpp']},\n     {'name': 'pwl', 'sources': ['pwl.cpp'] },\n+    {'name': 'quantized', 'sources': ['quantized.cpp']},\n ]\n \n foreach test : libipa_test\ndiff --git a/test/ipa/libipa/quantized.cpp b/test/ipa/libipa/quantized.cpp\nnew file mode 100644\nindex 000000000000..f138597f273d\n--- /dev/null\n+++ b/test/ipa/libipa/quantized.cpp\n@@ -0,0 +1,145 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2026, Ideas on Board\n+ *\n+ * Dual Type and Quantizer tests\n+ */\n+\n+#include \"../src/ipa/libipa/quantized.h\"\n+\n+#include <algorithm>\n+#include <cmath>\n+#include <iostream>\n+#include <stdint.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+using namespace ipa;\n+\n+struct BrightnessHueTraits {\n+\tusing QuantizedType = uint8_t;\n+\tstatic QuantizedType fromFloat(float v)\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn std::clamp<int>(quantized, -128, 127);\n+\t}\n+\tstatic float toFloat(QuantizedType v)\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\n+\n+using BrightnessHueQuantizer = Quantized<BrightnessHueTraits>;\n+\n+struct ContrastSaturationTraits {\n+\tusing QuantizedType = uint8_t;\n+\tstatic QuantizedType fromFloat(float v)\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn std::clamp<int>(quantized, 0, 255);\n+\t}\n+\tstatic float toFloat(QuantizedType v)\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\n+\n+using ContrastSaturationQuantizer = Quantized<ContrastSaturationTraits>;\n+\n+using BrightnessQ = BrightnessHueQuantizer;\n+using HueQ = BrightnessHueQuantizer;\n+using ContrastQ = ContrastSaturationQuantizer;\n+using SaturationQ = ContrastSaturationQuantizer;\n+\n+class QuantizedTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\t/* Test construction from float */\n+\t\t{\n+\t\t\tBrightnessQ b(0.5f);\n+\t\t\tif (b.quantized() != 64 || std::abs(b.value() - 0.5f) > 0.01f)\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test construction from T */\n+\t\t{\n+\t\t\tContrastQ c(uint8_t(128));\n+\t\t\tif (c.quantized() != 128 || std::abs(c.value() - 1.0f) > 0.01f)\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Only construction from the exact storage type or a float\n+\t\t * is permitted.\n+\t\t */\n+\t\tstatic_assert(!std::is_constructible_v<BrightnessQ, unsigned int>);\n+\t\tstatic_assert(!std::is_constructible_v<BrightnessQ, int8_t>);\n+\t\tstatic_assert(!std::is_constructible_v<BrightnessQ, double>);\n+\t\tstatic_assert(!std::is_constructible_v<ContrastQ, int>);\n+\t\tstatic_assert(!std::is_constructible_v<ContrastQ, int8_t>);\n+\t\tstatic_assert(!std::is_constructible_v<ContrastQ, unsigned int>);\n+\n+\t\t/* Test equality */\n+\t\t{\n+\t\t\tBrightnessQ b1(0.5f), b2(uint8_t(64));\n+\t\t\tif (!(b1 == b2))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test inequality */\n+\t\t{\n+\t\t\tBrightnessQ b1(0.5f), b2(-0.5f);\n+\t\t\tif (!(b1 != b2))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test copying */\n+\t\t{\n+\t\t\tBrightnessQ b1(0.25f);\n+\t\t\tBrightnessQ b2 = b1;\n+\t\t\tif (!(b1 == b2))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test assignment */\n+\t\t{\n+\t\t\tContrastQ c1(1.5f);\n+\t\t\tContrastQ c2(0.0f);\n+\t\t\tc2 = c1;\n+\t\t\tif (!(c1 == c2))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test construction from different floats mapping to same\n+\t\t * quantized value\n+\t\t */\n+\t\t{\n+\t\t\t/* Two floats that have the same quantized value. */\n+\t\t\tconst float f1 = 1.007f;\n+\t\t\tconst float f2 = 1.008f;\n+\n+\t\t\tContrastQ c1(f1);\n+\t\t\tContrastQ c2(f2);\n+\n+\t\t\t/* Quantized values must match */\n+\t\t\tif (!(c1.quantized() == c2.quantized()))\n+\t\t\t\treturn TestFail;\n+\n+\t\t\t/* Float values must now match */\n+\t\t\tif (!(c1.value() == c2.value()))\n+\t\t\t\treturn TestFail;\n+\n+\t\t\tif (!(c1 == c2))\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(QuantizedTest)\n",
    "prefixes": [
        "v8",
        "02/15"
    ]
}