From patchwork Fri Nov 14 00:54:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25038 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 BDA62C3317 for ; Fri, 14 Nov 2025 00:55:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7860B60AA8; Fri, 14 Nov 2025 01:54:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="plz86knk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5D3F60AA7 for ; Fri, 14 Nov 2025 01:54:50 +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 369218FA; 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=6G2ZcQHiEZLvQTYgB1pu+nA9XQdJ0oX8jEE+U0kKygw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plz86knkwgkbusvEZlxhOYWOiRqFQNiW4Vf1w0gly/8WYEpojQJuPJFWxOF6TksKT M36gXSqvG8NKRROZVeytjNKgAzwz5zkEwClI2WikTqqDRYr+8/O6woLVs3PVJ9Gbos zShopYWrAeaeJmK7s/EjOFLro2QgHJL4hYa+7xwQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v4 08/21] ipa: libipa: Provide Q5.8 FixedPoint support Date: Fri, 14 Nov 2025 00:54:12 +0000 Message-ID: <20251114005428.90024-9-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 Q5.8 format representing values in the range [0 .. 31.9961] with a resolution of 1/256. Signed-off-by: Kieran Bingham --- This type is used by the Mali-C55 Digital Gain component. src/ipa/libipa/fixedpoint.cpp | 9 +++++++++ src/ipa/libipa/fixedpoint.h | 1 + test/ipa/libipa/fixedpoint.cpp | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp index 967b00bcd7c2..a6f8ef351c32 100644 --- a/src/ipa/libipa/fixedpoint.cpp +++ b/src/ipa/libipa/fixedpoint.cpp @@ -148,6 +148,15 @@ namespace ipa { * values in the range [-16.0, 15.9375] with a resolution of 1/16. */ +/** + * \typedef UQ5_8 + * \brief 5.8 unsigned fixed-point quantizer + * + * A Quantized type using 5 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, 31.9961] with a resolution of 1/256. + */ + /** * \typedef Q12_4 * \brief 12.4 signed fixed-point quantizer diff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h index ce621cb01a5a..8f095210a918 100644 --- a/src/ipa/libipa/fixedpoint.h +++ b/src/ipa/libipa/fixedpoint.h @@ -106,6 +106,7 @@ using Q1_7 = Quantized>; using UQ1_7 = Quantized>; using Q5_4 = Quantized>; +using UQ5_8 = Quantized>; using Q12_4 = Quantized>; using UQ12_4 = Quantized>; diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp index 1d018c0128df..c830b5f05a19 100644 --- a/test/ipa/libipa/fixedpoint.cpp +++ b/test/ipa/libipa/fixedpoint.cpp @@ -195,6 +195,11 @@ protected: fails += quantizedCheck(-16.00f, 0b10000'0000, -16.00f); fails += quantizedCheck( 15.94f, 0b01111'1111, 15.9375f); + /* UQ5_8(0 .. 31.9961) Min: [0x0000:0] -- Max: [0x1fff:31.9961] Step:0.00390625 */ + introduce("UQ5_8"); + fails += quantizedCheck( 0.00f, 0b00000'00000000, 0.00f); + fails += quantizedCheck(32.00f, 0b11111'11111111, 31.9961f); + /* Q12.4(-2048 .. 2047.94) Min: [0x8000:-2048] -- Max: [0x7fff:2047.94] Step:0.0625 */ introduce("Q12_4"); fails += quantizedCheck(0.0f, 0b000000000000'0000, 0.0f);