Show a patch.

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

{
    "id": 25017,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25017/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25017/",
    "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": "<20251113122450.287633-4-kieran.bingham@ideasonboard.com>",
    "date": "2025-11-13T12:24:38",
    "name": "[v3,03/14] ipa: libipa: Provide fixed point quantized traits",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "532f583119f1eab110693f651e1bf1fd8427b159",
    "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/25017/mbox/",
    "series": [
        {
            "id": 5587,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5587/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5587",
            "date": "2025-11-13T12:24:35",
            "name": "libipa: Introduce a Quantized type",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/5587/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25017/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25017/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 15480C32DB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Nov 2025 12:25:02 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26B9960AA0;\n\tThu, 13 Nov 2025 13:25:01 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F0175609E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Nov 2025 13:24:54 +0100 (CET)",
            "from Monstersaurus.infra.iob\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 D2C5ABD2;\n\tThu, 13 Nov 2025 13:22:54 +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=\"p1MIOeNm\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763036574;\n\tbh=PhQGFNwJSBWycnkwVvtA+1mUnzMQWB2S4EWDL7u4f0E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=p1MIOeNmKmmcxYY29h8UMUa2cXBAJmtl3IIb0eG1sKjz2knMbrsEwM6ECl0Mpw+Za\n\tqCHvb63L4632dps4FsntyzhnNXv7/LkGjsFgZOBP8Tqt+lhClZi0fjUJ46gIhBV+I3\n\tmG4o8zSbnBLr4JEW01tV9oYuq7maMLLgRcXTKSsI=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v3 03/14] ipa: libipa: Provide fixed point quantized traits",
        "Date": "Thu, 13 Nov 2025 12:24:38 +0000",
        "Message-ID": "<20251113122450.287633-4-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.50.1",
        "In-Reply-To": "<20251113122450.287633-1-kieran.bingham@ideasonboard.com>",
        "References": "<20251113122450.287633-1-kieran.bingham@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": "Extend the new Quantized type infrastructure by providing a\nFixedPointQTraits template.\n\nThis allows construction of fixed point types with a Quantized storage\nthat allows easy reading of both the underlying quantized type value and\na floating point representation of that same value.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/libipa/fixedpoint.cpp | 114 ++++++++++++++++++++++++++++++++++\n src/ipa/libipa/fixedpoint.h   |  43 +++++++++++++\n 2 files changed, 157 insertions(+)",
    "diff": "diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp\nindex 6b698fc5d680..5b5d3721bf85 100644\n--- a/src/ipa/libipa/fixedpoint.cpp\n+++ b/src/ipa/libipa/fixedpoint.cpp\n@@ -37,6 +37,120 @@ namespace ipa {\n  * \\return The converted value\n  */\n \n+/**\n+ * \\struct libcamera::ipa::FixedPointQTraits\n+ * \\brief Traits type implementing fixed-point quantisation conversions\n+ *\n+ * The FixedPointQTraits structure defines a policy for mapping floating-point\n+ * values to and from fixed-point integer representations. It is parameterised\n+ * by the number of integer bits \\a I, fractional bits \\a F, and the integral\n+ * storage type \\a T. The traits are used with Quantized<Traits> to create a\n+ * quantised type that stores both the fixed-point representation and the\n+ * corresponding floating-point value.\n+ *\n+ * The trait exposes compile-time constants describing the bit layout, limits,\n+ * and scaling factors used in the fixed-point representation.\n+ *\n+ * \\tparam I Number of integer bits\n+ * \\tparam F Number of fractional bits\n+ * \\tparam T Integral type used to store the quantised value\n+ */\n+\n+/**\n+ * \\typedef FixedPointQTraits::QuantizedType\n+ * \\brief The integral storage type used for the fixed-point representation\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::Bits\n+ * \\brief Total number of bits used in the fixed-point format (I + F)\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::BitMask\n+ * \\brief Bit mask selecting all valid bits in the fixed-point representation\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::qmin\n+ * \\brief Minimum representable quantised integer value\n+ *\n+ * This corresponds to the most negative value for signed formats or zero for\n+ * unsigned formats.\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::qmax\n+ * \\brief Maximum representable quantised integer value\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::min\n+ * \\brief Minimum representable floating-point value corresponding to qmin\n+ */\n+\n+/**\n+ * \\var FixedPointQTraits::max\n+ * \\brief Maximum representable floating-point value corresponding to qmax\n+ */\n+\n+/**\n+ * \\fn FixedPointQTraits::fromFloat(float v)\n+ * \\brief Convert a floating-point value to a fixed-point integer\n+ * \\param[in] v The floating-point value to be converted\n+ * \\return The quantised fixed-point integer representation\n+ *\n+ * The conversion rounds the floating-point input \\a v to the nearest integer\n+ * according to the scaling factor defined by the number of fractional bits F.\n+ */\n+\n+/**\n+ * \\fn FixedPointQTraits::toFloat(QuantizedType q)\n+ * \\brief Convert a fixed-point integer to a floating-point value\n+ * \\param[in] q The fixed-point integer value to be converted\n+ * \\return The corresponding floating-point value\n+ *\n+ * The conversion sign-extends the integer value if required and divides by the\n+ * scaling factor defined by the number of fractional bits F.\n+ */\n+\n+/**\n+ * \\typedef Q1_7\n+ * \\brief 1.7 signed fixed-point quantizer\n+ *\n+ * A Quantized type using 1 bit for the integer part and 7 bits for the\n+ * fractional part, stored in a signed 8-bit integer (\\c int8_t). Represents\n+ * values approximately in the range [-1.0, 0.992] with a resolution of 1/128.\n+ */\n+\n+/**\n+ * \\typedef UQ1_7\n+ * \\brief 1.7 unsigned fixed-point quantizer\n+ *\n+ * A Quantized type using 1 bit for the integer part and 7 bits for the\n+ * fractional part, stored in an unsigned 8-bit integer (\\c uint8_t). Represents\n+ * values in the range [0.0, 1.992] with a resolution of 1/128.\n+ */\n+\n+/**\n+ * \\typedef Q12_4\n+ * \\brief 12.4 signed fixed-point quantizer\n+ *\n+ * A Quantized type using 12 bits for the integer part and 4 bits for the\n+ * fractional part, stored in a signed 16-bit integer (\\c int16_t). Represents\n+ * values in the range approximately [-2048.0, 2047.9375] with a resolution of\n+ * 1/16.\n+ */\n+\n+/**\n+ * \\typedef UQ12_4\n+ * \\brief 12.4 unsigned fixed-point quantizer\n+ *\n+ * A Quantized type using 12 bits for the integer part and 4 bits for the\n+ * fractional part, stored in an unsigned 16-bit integer (\\c uint16_t).\n+ * Represents values in the range [0.0, 4095.9375] with a resolution of 1/16.\n+ */\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h\nindex 709cf50f0fcd..baf5dbfa6bf8 100644\n--- a/src/ipa/libipa/fixedpoint.h\n+++ b/src/ipa/libipa/fixedpoint.h\n@@ -10,6 +10,8 @@\n #include <cmath>\n #include <type_traits>\n \n+#include \"quantized.h\"\n+\n namespace libcamera {\n \n namespace ipa {\n@@ -60,6 +62,47 @@ constexpr R fixedToFloatingPoint(T number)\n \treturn static_cast<R>(t) / static_cast<R>(1 << F);\n }\n \n+template<unsigned int I, unsigned int F, typename T>\n+struct FixedPointQTraits {\n+\tstatic_assert(std::is_integral_v<T>, \"FixedPointQTraits: T must be integral\");\n+\tusing QuantizedType = T;\n+\n+\tstatic constexpr unsigned int Bits = I + F;\n+\n+\tstatic constexpr T BitMask = (Bits < sizeof(T) * 8)\n+\t\t\t\t   ? (T{1} << Bits) - 1\n+\t\t\t\t   : T{-1};\n+\n+\tstatic constexpr T qmin = std::is_signed_v<T>\n+\t\t\t\t? -(T{1} << (Bits - 1))\n+\t\t\t\t: T{0};\n+\n+\tstatic constexpr T qmax = std::is_signed_v<T>\n+\t\t\t\t? ((T{1} << (Bits - 1)) - 1)\n+\t\t\t\t: ((T{1} << Bits) - 1);\n+\n+\tstatic constexpr float min = fixedToFloatingPoint<I, F, float>(qmin);\n+\tstatic constexpr float max = fixedToFloatingPoint<I, F, float>(qmax);\n+\n+\t/* Conversion functions required by Quantized<Traits> */\n+\tstatic QuantizedType fromFloat(float v)\n+\t{\n+\t\tv = std::clamp(v, min, max);\n+\t\treturn floatingToFixedPoint<I, F, QuantizedType, float>(v);\n+\t}\n+\n+\tstatic float toFloat(QuantizedType q)\n+\t{\n+\t\treturn fixedToFloatingPoint<I, F, float, QuantizedType>(q);\n+\t}\n+};\n+\n+using Q1_7 = Quantized<FixedPointQTraits<1, 7, int8_t>>;\n+using UQ1_7 = Quantized<FixedPointQTraits<1, 7, uint8_t>>;\n+\n+using Q12_4 = Quantized<FixedPointQTraits<12, 4, int16_t>>;\n+using UQ12_4 = Quantized<FixedPointQTraits<12, 4, uint16_t>>;\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\n",
    "prefixes": [
        "v3",
        "03/14"
    ]
}