Show a patch.

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

{
    "id": 26667,
    "url": "https://patchwork.libcamera.org/api/patches/26667/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26667/",
    "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": "<20260506230722.1041596-11-devve.3@gmail.com>",
    "date": "2026-05-06T23:07:22",
    "name": "[v2,10/10] test: ipa: libipa: Add CCM row-sum validation test",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "2a1dfe0c28955f2f7cd242968cf52fdd2511a821",
    "submitter": {
        "id": 271,
        "url": "https://patchwork.libcamera.org/api/people/271/?format=api",
        "name": "devve",
        "email": "devve.3@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26667/mbox/",
    "series": [
        {
            "id": 5915,
            "url": "https://patchwork.libcamera.org/api/series/5915/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5915",
            "date": "2026-05-06T23:07:12",
            "name": "OV01A10 sensor support and simple IPA improvements",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5915/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26667/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26667/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 D6835C3307\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 May 2026 23:07:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7C3E4630BB;\n\tThu,  7 May 2026 01:07:42 +0200 (CEST)",
            "from mail-ua1-x92a.google.com (mail-ua1-x92a.google.com\n\t[IPv6:2607:f8b0:4864:20::92a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 924D86327F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 01:07:39 +0200 (CEST)",
            "by mail-ua1-x92a.google.com with SMTP id\n\ta1e0cc1a2514c-95d0476492bso114819241.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 May 2026 16:07:39 -0700 (PDT)",
            "from dexps.speedport.ip\n\t(p200300eda74453cf3cf3f7929e513b94.dip0.t-ipconnect.de.\n\t[2003:ed:a744:53cf:3cf3:f792:9e51:3b94])\n\tby smtp.gmail.com with ESMTPSA id\n\taf79cd13be357-8fc2c25324esm2035266385a.23.2026.05.06.16.07.37\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 06 May 2026 16:07:37 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"VyO39wYf\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20251104; t=1778108858; x=1778713658;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=iuKxaCdLNK1rpp1md2t0A+vNdZQgr0zrLCF8pVdKmlk=;\n\tb=VyO39wYfwsXUXygdkXIOKx8swGbqoFhkVBFnAb1whZT24zxp9DZ3SGik45/8/GNFGp\n\t+LTgY/Ay8+zsPkggU7mi4igVditmdnJSLJvEna2x8Ijg63y/eqWCeAzaLXaes5DxRzTG\n\tkYZxRhfKjxLz4mr7Y3PAYhLiWgeUKqmDdB3UbKj2BrTq22y/WaNPtAVge/nliY/fFb+a\n\tc8LfAHhkaAB890P5eqkdfOS//iMqSGeRyclPF2QEZoLBzvim+NuB+2u7qREMXno2Kemc\n\tDihM/vdyjstLnU43Cg2un6GCIMeXqcNdlhvrVUGlDN4kd5UHxc+/9le7zZizfWRsAM+7\n\tBKGQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1778108858; x=1778713658;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to\n\t:cc:subject:date:message-id:reply-to;\n\tbh=iuKxaCdLNK1rpp1md2t0A+vNdZQgr0zrLCF8pVdKmlk=;\n\tb=VgcUjX4yJnqiRmEZaiR/nw+1DUJRpPkqcfw0rFxYgXu6yd5kipNNTC5pNydpVyHmik\n\tbB1hGgrNTm+I0bcSR7x+Y4wJ7OFlA/p7I1BqdAK27OvikImnMlJHo7QUHse/BngXsbRW\n\tuY8wDKilV9a1jKKGYoPyFZs5OmZT8lXGBqUZ2VpzNC8DXIBMmGXh43nbR297Dx/eH2ld\n\tRsSnJC48poWquav9Pqq2l2OHaKyuwufAqBSxRt75nsbbS4XWztupFnWZJixVD0gMijQI\n\tdSSB6lqjCZEWufR7CQqqmfKpskSrb49oQLBCvTBmV2DEIo2ZU3ngXF0gRlu6ePpYs48I\n\tXHpw==",
        "X-Gm-Message-State": "AOJu0YyXczirCMvcnpOkC/p2vCK4YmJ537UQz7xwz8D+KQ3BysmBxm0u\n\tILtl+iNMffHmjn2VnHfmwlwNkdH8nKCLtJ56L8fIzpo2+DFN4MOLR7RhbmXGtA==",
        "X-Gm-Gg": "AeBDiev6aRTpCityw56Wclc0x5wf8K3Z12Qqd1A6xl9OdSjFPbD/PtJML0/nSjzSsHo\n\tM5EnDQmucOlphL7bh7RV0wSGJP+8rtwMz2HwFEvl6nyh6ZAheFU/1XSpiBME9RgSeOAc17Qoczk\n\tf0meS79So/VLzqTEW4Efhyt+PxwMjmpiKlzWTFxHGqNDmavOIOx8iSQ+Y2Las+X7gdgx+NxudSv\n\tWFbAv40rtvVeCDG8kBWFCr6e0aljLZ6VzT8csJcqkFKYdFvR0X0x6xVrWcTMaDNhp7x9Imssa9O\n\tsnk2vOXGipWMbK/tQegtF+cfSmn17HRY+n3YNSJn6ne5D8DcDJ58FMkDdU+J+LCa3ZmWx9wtWFx\n\t+zdRI6WNcLQUhzH2HKAdRewdxToW1EJu91YaN6m07f27uVfBA5Xxl/3flxwivg/fvHwEfmvYLtM\n\tcBfZizksgH99Udj4ILyaOJv/VN8ixXJZHlxcvs8gmWYaNI55lygGUNTWF2lubcM8E153p1agu5I\n\tfVO9wNAfECk34qbNRKGd92oU7U+RA4CZFlstJ/Zl9g=",
        "X-Received": "by 2002:a67:e102:0:b0:628:5313:11a with SMTP id\n\tada2fe7eead31-630f90ecf9bmr2955890137.28.1778108858210; \n\tWed, 06 May 2026 16:07:38 -0700 (PDT)",
        "From": "d3vv3 <devve.3@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v2 10/10] test: ipa: libipa: Add CCM row-sum validation test",
        "Date": "Thu,  7 May 2026 01:07:22 +0200",
        "Message-ID": "<20260506230722.1041596-11-devve.3@gmail.com>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260506230722.1041596-1-devve.3@gmail.com>",
        "References": "<20260506230722.1041596-1-devve.3@gmail.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": "Verify that each row of a colour correction matrix sums to 1.0\n(luminance preservation property). Tests cover:\n- identity and known-bad inline matrices\n- a real OV01A10 D65 calibrated CCM\n- parsing a multi-entry CCM YAML table via Interpolator<Matrix>\n- detection of a bad entry in YAML\n\nTolerance is 5e-4 to accommodate 4-decimal-place rounding in tuning files.\n\nSigned-off-by: d3vv3 <devve.3@gmail.com>\n---\n test/ipa/libipa/ccm.cpp     | 158 ++++++++++++++++++++++++++++++++++++\n test/ipa/libipa/meson.build |   1 +\n 2 files changed, 159 insertions(+)\n create mode 100644 test/ipa/libipa/ccm.cpp",
    "diff": "diff --git a/test/ipa/libipa/ccm.cpp b/test/ipa/libipa/ccm.cpp\nnew file mode 100644\nindex 00000000..efc0035a\n--- /dev/null\n+++ b/test/ipa/libipa/ccm.cpp\n@@ -0,0 +1,158 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2024-2026, Red Hat Inc.\n+ *\n+ * CCM matrix row-sum validation tests\n+ *\n+ * Each row of a colour correction matrix must sum to 1.0 (luminance\n+ * preservation).  This test verifies that property for inline matrix data\n+ * and for matrices parsed from a YAML CCM table.\n+ */\n+\n+#include \"../../../src/ipa/libipa/interpolator.h\"\n+\n+#include <cmath>\n+#include <iostream>\n+#include <string>\n+#include <unistd.h>\n+\n+#include \"libcamera/base/file.h\"\n+#include \"libcamera/internal/matrix.h\"\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+using namespace ipa;\n+\n+/* Tolerance for floating-point row-sum comparison.\n+ * CCM values in tuning files are typically given to 4 decimal places,\n+ * which can introduce up to ~0.5e-3 rounding error per row. */\n+static constexpr float kRowSumTolerance = 5e-4f;\n+\n+#define ASSERT_TRUE(cond)                             \\\n+\tdo {                                          \\\n+\t\tif (!(cond)) {                        \\\n+\t\t\tcerr << \"FAIL: \" #cond \"\\n\";  \\\n+\t\t\treturn TestFail;              \\\n+\t\t}                                     \\\n+\t} while (0)\n+\n+static bool allRowsSumToOne(const Matrix<float, 3, 3> &m)\n+{\n+\tfor (unsigned int row = 0; row < 3; row++) {\n+\t\tfloat sum = 0.0f;\n+\t\tfor (unsigned int col = 0; col < 3; col++)\n+\t\t\tsum += m[row][col];\n+\t\tif (std::abs(sum - 1.0f) > kRowSumTolerance)\n+\t\t\treturn false;\n+\t}\n+\treturn true;\n+}\n+\n+class CcmRowSumTest : public Test\n+{\n+protected:\n+\tbool writeTempYaml(const std::string &content, std::string &filename)\n+\t{\n+\t\tfilename = \"/tmp/libcamera.ccm.test.XXXXXX\";\n+\t\tint fd = mkstemp(&filename.front());\n+\t\tif (fd == -1)\n+\t\t\treturn false;\n+\t\tssize_t ret = write(fd, content.c_str(), content.size());\n+\t\tclose(fd);\n+\t\treturn ret == static_cast<ssize_t>(content.size());\n+\t}\n+\n+\tstd::unique_ptr<ValueNode> parseYaml(const std::string &content)\n+\t{\n+\t\tstd::string filename;\n+\t\tif (!writeTempYaml(content, filename))\n+\t\t\treturn nullptr;\n+\n+\t\tFile file{ filename };\n+\t\tif (!file.open(File::OpenModeFlag::ReadOnly))\n+\t\t\treturn nullptr;\n+\n+\t\tauto root = YamlParser::parse(file);\n+\t\tunlink(filename.c_str());\n+\t\treturn root;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\t/* --- 1. Known-good identity matrix --- */\n+\t\tMatrix<float, 3, 3> identity{ { 1, 0, 0,\n+\t\t\t\t\t\t0, 1, 0,\n+\t\t\t\t\t\t0, 0, 1 } };\n+\t\tASSERT_TRUE(allRowsSumToOne(identity));\n+\n+\t\t/* --- 2. Known-bad matrix (rows do not sum to 1) --- */\n+\t\tMatrix<float, 3, 3> bad{ { 2, 0, 0,\n+\t\t\t\t\t   0, 1, 0,\n+\t\t\t\t\t   0, 0, 1 } };\n+\t\tASSERT_TRUE(!allRowsSumToOne(bad));\n+\n+\t\t/* --- 3. Typical calibrated CCM (D65, OV01A10) --- */\n+\t\tMatrix<float, 3, 3> d65{ {  1.8163f, -0.7062f, -0.1100f,\n+\t\t\t\t\t   -0.1640f,  1.5736f, -0.4096f,\n+\t\t\t\t\t   -0.0084f, -0.8294f,  1.8378f } };\n+\t\tASSERT_TRUE(allRowsSumToOne(d65));\n+\n+\t\t/* --- 4. Parse a valid CCM table from YAML and validate --- */\n+\t\tconst std::string validYaml =\n+\t\t\t\"- ct: 2856\\n\"\n+\t\t\t\"  ccm: [  1.1248,  0.2210, -0.3458,\\n\"\n+\t\t\t\"         -0.4616,  1.7736, -0.3120,\\n\"\n+\t\t\t\"         -0.4342, -0.9348,  2.3690 ]\\n\"\n+\t\t\t\"- ct: 6500\\n\"\n+\t\t\t\"  ccm: [  1.8163, -0.7062, -0.1100,\\n\"\n+\t\t\t\"         -0.1640,  1.5736, -0.4096,\\n\"\n+\t\t\t\"         -0.0084, -0.8294,  1.8378 ]\\n\"\n+\t\t\t\"- ct: 7500\\n\"\n+\t\t\t\"  ccm: [  1.8953, -0.7980, -0.0973,\\n\"\n+\t\t\t\"         -0.1539,  1.6001, -0.4462,\\n\"\n+\t\t\t\"         -0.0101, -0.7800,  1.7902 ]\\n\";\n+\n+\t\tauto root = parseYaml(validYaml);\n+\t\tASSERT_TRUE(root);\n+\n+\t\tInterpolator<Matrix<float, 3, 3>> interp;\n+\t\tASSERT_TRUE(interp.readYaml(*root, \"ct\", \"ccm\") == 0);\n+\t\tASSERT_TRUE(interp.data().size() == 3);\n+\n+\t\tfor (const auto &[ct, m] : interp.data()) {\n+\t\t\tif (!allRowsSumToOne(m)) {\n+\t\t\t\tcerr << \"CCM at ct=\" << ct\n+\t\t\t\t     << \" has a row that does not sum to 1.0\\n\";\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\t/* --- 5. Detect a bad entry in YAML --- */\n+\t\tconst std::string badYaml =\n+\t\t\t\"- ct: 5000\\n\"\n+\t\t\t\"  ccm: [  2.0000, -0.7062, -0.1100,\\n\"\n+\t\t\t\"         -0.1640,  1.5736, -0.4096,\\n\"\n+\t\t\t\"         -0.0084, -0.8294,  1.8378 ]\\n\";\n+\n+\t\tauto badRoot = parseYaml(badYaml);\n+\t\tASSERT_TRUE(badRoot);\n+\n+\t\tInterpolator<Matrix<float, 3, 3>> badInterp;\n+\t\tASSERT_TRUE(badInterp.readYaml(*badRoot, \"ct\", \"ccm\") == 0);\n+\n+\t\tfor (const auto &[ct, m] : badInterp.data()) {\n+\t\t\tif (allRowsSumToOne(m)) {\n+\t\t\t\tcerr << \"Expected bad CCM at ct=\" << ct\n+\t\t\t\t     << \" to fail row-sum check, but it passed\\n\";\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(CcmRowSumTest)\ndiff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build\nindex c3e25587..8c36800c 100644\n--- a/test/ipa/libipa/meson.build\n+++ b/test/ipa/libipa/meson.build\n@@ -1,6 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libipa_test = [\n+    {'name': 'ccm', 'sources': ['ccm.cpp']},\n     {'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']},\n     {'name': 'histogram', 'sources': ['histogram.cpp']},\n     {'name': 'interpolator', 'sources': ['interpolator.cpp']},\n",
    "prefixes": [
        "v2",
        "10/10"
    ]
}