Patch Detail
Show a patch.
GET /api/1.1/patches/24825/?format=api
{ "id": 24825, "url": "https://patchwork.libcamera.org/api/1.1/patches/24825/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24825/", "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": "<20251026233048.175689-3-kieran.bingham@ideasonboard.com>", "date": "2025-10-26T23:30:39", "name": "[2/6] test: libipa: Add tests for Quantizers", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "790eb93534ac981f904f0038a291da31879c188f", "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/24825/mbox/", "series": [ { "id": 5532, "url": "https://patchwork.libcamera.org/api/1.1/series/5532/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5532", "date": "2025-10-26T23:30:37", "name": "libipa: Introduce a Quantized type", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5532/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24825/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24825/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 EB980BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Oct 2025 23:31:01 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43F4F606F5;\n\tMon, 27 Oct 2025 00:30:58 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EDB6606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Oct 2025 00:30:54 +0100 (CET)", "from charm.hippo-penny.ts.net (unknown [209.38.108.23])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 821B9E9B;\n\tMon, 27 Oct 2025 00:29:06 +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=\"rlxMtj8E\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761521346;\n\tbh=CenjjyPxspM0Qea0KDApsn4fVOkAyGFz8PmOvbVj8Oo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=rlxMtj8EstVSPg9Xwpf8lhRj7U6htgnTdEBXI+CpPgzC4Eyr2CcCvibLpzokPxamv\n\tUALgI8Ewpg54LBPu4kHX7xKmW6HOdlmWAxKW5+fWEypxP6xwpxUoP821p38BIvcrqk\n\tJwktoSgCRaaQSbf3HaN3ppz+LkE8FCuDgwMCx+MY=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH 2/6] test: libipa: Add tests for Quantizers", "Date": "Sun, 26 Oct 2025 23:30:39 +0000", "Message-ID": "<20251026233048.175689-3-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20251026233048.175689-1-kieran.bingham@ideasonboard.com>", "References": "<20251026233048.175689-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/ipa/libipa/meson.build | 1 +\n test/ipa/libipa/quantized.cpp | 149 ++++++++++++++++++++++++++++++++++\n 2 files changed, 150 insertions(+)\n create mode 100644 test/ipa/libipa/quantized.cpp", "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..51db62a1b88a\n--- /dev/null\n+++ b/test/ipa/libipa/quantized.cpp\n@@ -0,0 +1,149 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2025, 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 <map>\n+#include <stdint.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+using namespace ipa;\n+\n+class BrightnessHueQuantizer : public Quantizer<int8_t>\n+{\n+public:\n+\tBrightnessHueQuantizer(float val) { set(val); }\n+\tBrightnessHueQuantizer(int8_t val) { set(val); }\n+\n+\tint8_t fromFloat(float v) const override\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn static_cast<int8_t>(std::clamp<int>(quantized, -128, 127));\n+\t}\n+\n+\tfloat toFloat(int8_t v) const override\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\n+\n+class ContrastSaturationQuantizer : public Quantizer<uint8_t>\n+{\n+public:\n+\tContrastSaturationQuantizer(float val) { set(val); }\n+\tContrastSaturationQuantizer(uint8_t val) { set(val); }\n+\n+\tuint8_t fromFloat(float v) const override\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn static_cast<uint8_t>(std::clamp<int>(quantized, 0, 255));\n+\t}\n+\n+\tfloat toFloat(uint8_t v) const override\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\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 * Test construction from non-float/non-T type (Expected Fail)\n+\t\t * These should be a compile-time error if uncommented:\n+\t\t */\n+\t\t// BrightnessQ bad1(15); // overloaded ‘BrightnessHueQuantizer(int)’ is ambiguous\n+\t\t// BrightnessQ bad2(0xff); // overloaded ‘BrightnessHueQuantizer(int)’ is ambiguous\n+\t\t// ContrastQ bad3(0x33); // overloaded ‘ContrastSaturationQuantizer(int)’ is ambiguous\n+\t\t// ContrastQ bad4(55U); // overloaded ‘ContrastSaturationQuantizer(unsigned int)’ is ambiguous\n+\n+\t\t/* Test equality */\n+\t\t{\n+\t\t\tBrightnessQ b1(0.5f), b2((int8_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 moving */\n+\t\t{\n+\t\t\tBrightnessQ b1(0.25f);\n+\t\t\tBrightnessQ b2 = std::move(b1); // Allow move semantics\n+\t\t\tif (b2.value() != 0.25f)\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/* Test assignment / storage in generic type */\n+\t\t{\n+\t\t\tContrastQ c(1.5f);\n+\t\t\tQuantized<uint8_t> q;\n+\n+\t\t\tq = c;\n+\t\t\tif (q.value() != c.value())\n+\t\t\t\treturn TestFail;\n+\n+\t\t\tif (q.quantized() != c.quantized())\n+\t\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstd::cout << \"Quantised tests passed successfully.\" << std::endl;\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(QuantizedTest)\n", "prefixes": [ "2/6" ] }