From patchwork Fri Nov 14 00:54:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25039 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C455AC3263 for ; Fri, 14 Nov 2025 00:55:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3087E60A9D; Fri, 14 Nov 2025 01:55:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="o/vHTcWa"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1026560AAD for ; Fri, 14 Nov 2025 01:54:51 +0100 (CET) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 827C61AED; Fri, 14 Nov 2025 01:52:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763081570; bh=N9XX3MGD8XPi40ZBAJ/UtIUyiZ3FR/uTa+qPdmjcRvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/vHTcWa4a5+62OQHOVeCC6/nulVJCI+8yWbjXQ/9zcE3Gl6f4pP6I9Ta6D7fWUfh RWBS3ZakmWPLHPv0keYvNLyCf9l8lOcAAoNQ749OJAoVn1wAHcOl6fiO/BgZZM+ugs pd/k1cLzC8jE04l96R4qsnlt4gbHkm3zfCClX7Ps= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v4 09/21] ipa: libipa: Provide Q4.8 FixedPoint support Date: Fri, 14 Nov 2025 00:54:13 +0000 Message-ID: <20251114005428.90024-10-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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide a FixedPoint Quantized type to support the Q4.8 format representing values in the range [0 .. 15.9961] with a resolution of 1/256. Signed-off-by: Kieran Bingham --- This type is used by the Mali-C55 AWB Gains src/ipa/libipa/fixedpoint.cpp | 9 +++++++++ src/ipa/libipa/fixedpoint.h | 2 ++ test/ipa/libipa/fixedpoint.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp index a6f8ef351c32..03053668ed79 100644 --- a/src/ipa/libipa/fixedpoint.cpp +++ b/src/ipa/libipa/fixedpoint.cpp @@ -139,6 +139,15 @@ namespace ipa { * values in the range [0.0, 1.992] with a resolution of 1/128. */ +/** + * \typedef UQ4_8 + * \brief 4.8 unsigned fixed-point quantizer + * + * A Quantized type using 4 bits for the integer part and 8 bits for the + * fractional part, stored in an unsigned 16-bit integer (\c uint16_t). Represents + * values in the range [0.0, 15.9961] with a resolution of 1/256. + */ + /** * \typedef Q5_4 * \brief 5.4 signed fixed-point quantizer diff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h index 8f095210a918..05dd97e64f40 100644 --- a/src/ipa/libipa/fixedpoint.h +++ b/src/ipa/libipa/fixedpoint.h @@ -105,6 +105,8 @@ struct FixedPointQTraits { using Q1_7 = Quantized>; using UQ1_7 = Quantized>; +using UQ4_8 = Quantized>; + using Q5_4 = Quantized>; using UQ5_8 = Quantized>; diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp index c830b5f05a19..f3773dfe6ad4 100644 --- a/test/ipa/libipa/fixedpoint.cpp +++ b/test/ipa/libipa/fixedpoint.cpp @@ -190,6 +190,11 @@ protected: fails += quantizedCheck(-0.4f, 0b1111'1001101, -0.398438f); /* 0x7cd */ fails += quantizedCheck(-1.4f, 0b1110'1001101, -1.39844f); /* 0x74d */ + /* UQ4_8(0 .. 15.9961) Min: [0x0000:0] -- Max: [0x0fff:15.9961] Step:0.00390625 */ + introduce("UQ4_8"); + fails += quantizedCheck( 0.0f, 0b0000'00000000, 0.00f); + fails += quantizedCheck(16.0f, 0b1111'11111111, 15.9961f); + /* Q5_4(-16 .. 15.9375) Min: [0x0100:-16] -- Max: [0x00ff:15.9375] Step:0.0625 */ introduce("Q5_4"); fails += quantizedCheck(-16.00f, 0b10000'0000, -16.00f);