Show a patch.

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

{
    "id": 26212,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26212/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26212/",
    "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": "<20260219-kbingham-quantizers-v8-15-2b6ff68ead26@ideasonboard.com>",
    "date": "2026-02-19T15:05:16",
    "name": "[v8,15/15] ipa: libipa: fixedpoint: Move float conversion inline",
    "commit_ref": "8064c4f33ad0fd47631877d85ea138b556b09424",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "91e70494dc1730fe5da70f6db99c79ae70b627d8",
    "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/26212/mbox/",
    "series": [
        {
            "id": 5802,
            "url": "https://patchwork.libcamera.org/api/1.1/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/26212/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26212/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 11207C32F4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Feb 2026 15:05:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EED00622A2;\n\tThu, 19 Feb 2026 16:05:26 +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 EB3DD62275\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Feb 2026 16:05:12 +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 B9E5B27FE;\n\tThu, 19 Feb 2026 16:04:19 +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=\"LY55XWJa\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771513459;\n\tbh=ZS4mVLpItJiKWId3mQLO8b9HUpOybF6GBGG9uLiV+uw=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=LY55XWJawpY/k0jkdMpi4fX3QTd9BM3UT5m5ziu4AIG9dodSYkUBPrUF3z/bKSdMa\n\tATKUjP41hlz6EzbFRmbHa4YZ4mPFz9gYb7812NpjxxFYheZpZu4gIHqlvpZzOn1gCE\n\tAxDwXFaSWqrbNTLXzqNwWV8Z83JdEdCgT4kZ/dqY=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Date": "Thu, 19 Feb 2026 15:05:16 +0000",
        "Subject": "[PATCH v8 15/15] ipa: libipa: fixedpoint: Move float conversion\n\tinline",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Message-Id": "<20260219-kbingham-quantizers-v8-15-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\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tPaul Elder <paul.elder@ideasonboard.com>",
        "X-Mailer": "b4 0.14.3",
        "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1771513507; l=5788;\n\ti=kieran.bingham@ideasonboard.com; s=20260207;\n\th=from:subject:message-id; \n\tbh=ZS4mVLpItJiKWId3mQLO8b9HUpOybF6GBGG9uLiV+uw=;\n\tb=yYz+JGj+J4LPtbtHlUpILFVPkU7ywdFWBuUlsOfqnRq4E29F0K3xHDHYA3yMm8WwOfXK5/GRt\n\t/JV6cVnrEdoAfya7/h9DRBq1eOdBGeQa5fJGD1iEfoV4+k0qeWaadY+",
        "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": "With all users of the floatingToFixedPoint and fixedToFloatingPoint\ncalls converted to use the FixedPoint Quantized types, remove the calls\nand documentation and move the implementation inline in the\nFixedPointTraits implementation.\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/libipa/fixedpoint.cpp | 22 -------------\n src/ipa/libipa/fixedpoint.h   | 75 +++++++++++++------------------------------\n 2 files changed, 22 insertions(+), 75 deletions(-)",
    "diff": "diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp\nindex b581ca8453ef..b06ad8d26719 100644\n--- a/src/ipa/libipa/fixedpoint.cpp\n+++ b/src/ipa/libipa/fixedpoint.cpp\n@@ -15,28 +15,6 @@ namespace libcamera {\n \n namespace ipa {\n \n-/**\n- * \\fn R floatingToFixedPoint(T number)\n- * \\brief Convert a floating point number to a fixed-point representation\n- * \\tparam I Bit width of the integer part of the fixed-point\n- * \\tparam F Bit width of the fractional part of the fixed-point\n- * \\tparam R Return type of the fixed-point representation\n- * \\tparam T Input type of the floating point representation\n- * \\param number The floating point number to convert to fixed point\n- * \\return The converted value\n- */\n-\n-/**\n- * \\fn R fixedToFloatingPoint(T number)\n- * \\brief Convert a fixed-point number to a floating point representation\n- * \\tparam I Bit width of the integer part of the fixed-point\n- * \\tparam F Bit width of the fractional part of the fixed-point\n- * \\tparam R Return type of the floating point representation\n- * \\tparam T Input type of the fixed-point representation\n- * \\param number The fixed point number to convert to floating point\n- * \\return The converted value\n- */\n-\n /**\n  * \\struct libcamera::ipa::FixedPointQTraits\n  * \\brief Traits type implementing fixed-point quantization conversions\ndiff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h\nindex df685e852bff..ed8aca9f150f 100644\n--- a/src/ipa/libipa/fixedpoint.h\n+++ b/src/ipa/libipa/fixedpoint.h\n@@ -16,55 +16,6 @@ namespace libcamera {\n \n namespace ipa {\n \n-#ifndef __DOXYGEN__\n-template<unsigned int I, unsigned int F, typename R, typename T,\n-\t std::enable_if_t<std::is_integral_v<R> &&\n-\t\t\t  std::is_floating_point_v<T>> * = nullptr>\n-#else\n-template<unsigned int I, unsigned int F, typename R, typename T>\n-#endif\n-constexpr R floatingToFixedPoint(T number)\n-{\n-\tstatic_assert(sizeof(int) >= sizeof(R));\n-\tstatic_assert(I + F <= sizeof(R) * 8);\n-\n-\t/*\n-\t * The intermediate cast to int is needed on arm platforms to properly\n-\t * cast negative values. See\n-\t * https://embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/\n-\t */\n-\tR mask = (1 << (F + I)) - 1;\n-\tR frac = static_cast<R>(static_cast<int>(std::round(number * (1 << F)))) & mask;\n-\n-\treturn frac;\n-}\n-\n-#ifndef __DOXYGEN__\n-template<unsigned int I, unsigned int F, typename R, typename T,\n-\t std::enable_if_t<std::is_floating_point_v<R> &&\n-\t\t\t  std::is_integral_v<T>> * = nullptr>\n-#else\n-template<unsigned int I, unsigned int F, typename R, typename T>\n-#endif\n-constexpr R fixedToFloatingPoint(T number)\n-{\n-\tstatic_assert(sizeof(int) >= sizeof(T));\n-\tstatic_assert(I + F <= sizeof(T) * 8);\n-\n-\tif constexpr (std::is_unsigned_v<T>)\n-\t\treturn static_cast<R>(number) / static_cast<R>(T{ 1 } << F);\n-\n-\t/*\n-\t * Recreate the upper bits in case of a negative number by shifting the sign\n-\t * bit from the fixed point to the first bit of the unsigned and then right shifting\n-\t * by the same amount which keeps the sign bit in place.\n-\t * This can be optimized by the compiler quite well.\n-\t */\n-\tint remaining_bits = sizeof(int) * 8 - (I + F);\n-\tint t = static_cast<int>(static_cast<unsigned>(number) << remaining_bits) >> remaining_bits;\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 private:\n@@ -97,11 +48,23 @@ public:\n \n \tstatic constexpr float toFloat(QuantizedType q)\n \t{\n-\t\treturn fixedToFloatingPoint<I, F, float, T>(q);\n+\t\tif constexpr (std::is_unsigned_v<T>)\n+\t\t\treturn static_cast<float>(q) / static_cast<float>(UT{ 1 } << F);\n+\n+\t\t/*\n+\t\t * Recreate the upper bits in case of a negative number by\n+\t\t * shifting the sign bit from the fixed point to the first bit\n+\t\t * of the unsigned and then right shifting by the same amount\n+\t\t * which keeps the sign bit in place. This can be optimized by\n+\t\t * the compiler quite well.\n+\t\t */\n+\t\tunsigned int remaining_bits = sizeof(UT) * 8 - (I + F);\n+\t\tT t = static_cast<T>(static_cast<UT>(q) << remaining_bits) >> remaining_bits;\n+\t\treturn static_cast<float>(t) / static_cast<float>(UT{ 1 } << F);\n \t}\n \n-\tstatic constexpr float min = fixedToFloatingPoint<I, F, float>(static_cast<T>(qMin));\n-\tstatic constexpr float max = fixedToFloatingPoint<I, F, float>(static_cast<T>(qMax));\n+\tstatic constexpr float min = toFloat(qMin);\n+\tstatic constexpr float max = toFloat(qMax);\n \n \tstatic_assert(min < max, \"FixedPointQTraits: Minimum must be less than maximum\");\n \n@@ -109,7 +72,13 @@ public:\n \tstatic QuantizedType fromFloat(float v)\n \t{\n \t\tv = std::clamp(v, min, max);\n-\t\treturn floatingToFixedPoint<I, F, T, float>(v);\n+\n+\t\t/*\n+\t\t * The intermediate cast to int is needed on arm platforms to\n+\t\t * properly cast negative values. See\n+\t\t * https://embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/\n+\t\t */\n+\t\treturn static_cast<UT>(static_cast<T>(std::round(v * (1 << F)))) & bitMask;\n \t}\n };\n \n",
    "prefixes": [
        "v8",
        "15/15"
    ]
}