Show a patch.

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

{
    "id": 25040,
    "url": "https://patchwork.libcamera.org/api/patches/25040/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25040/",
    "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": "<20251114005428.90024-11-kieran.bingham@ideasonboard.com>",
    "date": "2025-11-14T00:54:14",
    "name": "[v4,10/21] ipa: libipa: fixedpoint: Provide a ScaledFixedPoint type",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "992fd5b731929d64595478750d96b9cded713187",
    "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/25040/mbox/",
    "series": [
        {
            "id": 5589,
            "url": "https://patchwork.libcamera.org/api/series/5589/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5589",
            "date": "2025-11-14T00:54:04",
            "name": "libipa: Introduce a Quantized type",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5589/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25040/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25040/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 A7318C3331\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 00:55:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45C9A60B33;\n\tFri, 14 Nov 2025 01:55: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 61AA860AAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 01:54:51 +0100 (CET)",
            "from charm.hippo-penny.ts.net\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 D22031D1C;\n\tFri, 14 Nov 2025 01:52:50 +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=\"tRemIF5s\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763081571;\n\tbh=DUlrlB6Trv3GWQH/Kyuo8tA9uj00B6YqWBYvIM2LaE4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=tRemIF5sfHlhePWHVJr41J0kZYUZJCU3z+D5+udrkvfWet325JjmE/ZxwS4kDkDw5\n\two6OjrFCd6oWqbsl8Hk6ojWcYWLsaNHv3AbnGmVVIKQuji5cDWKKor6BmWJ4Izt4p+\n\tclBQmS+g5YANd4ProMUZGMlnf9fdC+jsacoV1NrY=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v4 10/21] ipa: libipa: fixedpoint: Provide a ScaledFixedPoint\n\ttype",
        "Date": "Fri, 14 Nov 2025 00:54:14 +0000",
        "Message-ID": "<20251114005428.90024-11-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.51.1",
        "In-Reply-To": "<20251114005428.90024-1-kieran.bingham@ideasonboard.com>",
        "References": "<20251114005428.90024-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 FixedPoint capabilities with a ScaledFixedPointQTraits\nwhich takes an existing Quantized type and scales the conversion by the\ngiven Scale template parameter.\n\nThis can be useful to represent fixed point values which represent\na linear range with a different scale to the underlying float\nor integral type.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\n\nv3:\n- Rename quantized_type to QuantizedType\n\nv4:\n- Fix copydoc for ScaledFixedPointQTraits::toFloat\n\n src/ipa/libipa/fixedpoint.cpp | 59 +++++++++++++++++++++++++++++++++++\n src/ipa/libipa/fixedpoint.h   | 24 ++++++++++++++\n 2 files changed, 83 insertions(+)",
    "diff": "diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp\nindex 03053668ed79..97cdd9b3f7aa 100644\n--- a/src/ipa/libipa/fixedpoint.cpp\n+++ b/src/ipa/libipa/fixedpoint.cpp\n@@ -185,6 +185,65 @@ namespace ipa {\n  * Represents values in the range [0.0, 4095.9375] with a resolution of 1/16.\n  */\n \n+/**\n+ * \\struct ScaledFixedPointQTraits\n+ * \\brief Wrap a FixedPointQTraits with a linear scaling factor\n+ *\n+ * This trait extends an existing fixed-point quantisation policy\n+ * by applying an additional multiplicative scale between the\n+ * floating-point and quantised domains.\n+ *\n+ * \\tparam Q The base fixed-point traits type\n+ * \\tparam Scale The scale factor applied to the floating-point domain\n+ */\n+\n+/**\n+ * \\typedef ScaledFixedPointQTraits::QuantizedType\n+ * \\copydoc FixedPointQTraits::QuantizedType\n+ */\n+\n+/**\n+ * \\var ScaledFixedPointQTraits::scale\n+ * \\brief The constant scaling factor applied to the floating-point domain\n+ *\n+ * Floating-point inputs are divided by this factor before quantisation,\n+ * and multiplied by it after dequantisation.\n+ */\n+\n+/**\n+ * \\var ScaledFixedPointQTraits::qmin\n+ * \\copydoc FixedPointQTraits::qmin\n+ */\n+\n+/**\n+ * \\var ScaledFixedPointQTraits::qmax\n+ * \\copydoc FixedPointQTraits::qmax\n+ */\n+\n+/**\n+ * \\var ScaledFixedPointQTraits::min\n+ * \\copydoc FixedPointQTraits::min\n+ */\n+\n+/**\n+ * \\var ScaledFixedPointQTraits::max\n+ * \\copydoc FixedPointQTraits::max\n+ */\n+\n+/**\n+ * \\fn ScaledFixedPointQTraits::fromFloat(float v)\n+ * \\copydoc FixedPointQTraits::fromFloat(float v)\n+ *\n+ * The input value \\a v is divided by the scaling factor before conversion.\n+ */\n+\n+/**\n+ * \\fn ScaledFixedPointQTraits::toFloat(QuantizedType q)\n+ * \\copydoc FixedPointQTraits::toFloat()\n+ *\n+ * The output value is multiplied by the scaling factor after conversion.\n+ */\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h\nindex 05dd97e64f40..1e984350111c 100644\n--- a/src/ipa/libipa/fixedpoint.h\n+++ b/src/ipa/libipa/fixedpoint.h\n@@ -113,6 +113,30 @@ using UQ5_8 = Quantized<FixedPointQTraits<5, 8, uint16_t>>;\n using Q12_4 = Quantized<FixedPointQTraits<12, 4, int16_t>>;\n using UQ12_4 = Quantized<FixedPointQTraits<12, 4, uint16_t>>;\n \n+template<typename Q, int Scale>\n+struct ScaledFixedPointQTraits {\n+\tusing QuantizedType = typename Q::QuantizedType;\n+\n+\tstatic constexpr float scale = static_cast<float>(Scale);\n+\n+\t/* Re-expose base limits, adjusted by the scaling factor */\n+\tstatic constexpr QuantizedType qmin = Q::qmin;\n+\tstatic constexpr QuantizedType qmax = Q::qmax;\n+\tstatic constexpr float min = Q::min * scale;\n+\tstatic constexpr float max = Q::max * scale;\n+\n+\tstatic QuantizedType fromFloat(float v)\n+\t{\n+\t\tv = std::clamp(v, min, max);\n+\t\treturn Q::fromFloat(v / scale);\n+\t}\n+\n+\tstatic float toFloat(QuantizedType q)\n+\t{\n+\t\treturn Q::toFloat(q) * scale;\n+\t}\n+};\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\n",
    "prefixes": [
        "v4",
        "10/21"
    ]
}