From patchwork Thu Nov 13 12:24:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25021 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 DB0A8C3263 for ; Thu, 13 Nov 2025 12:25:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5852760AB0; Thu, 13 Nov 2025 13:25:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="E4smjz04"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECD4360AA3 for ; Thu, 13 Nov 2025 13:24:55 +0100 (CET) Received: from Monstersaurus.infra.iob (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D466C6AF; Thu, 13 Nov 2025 13:22:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763036575; bh=sS7N//jLH2aaFP3AtzN6ndBh0IKnG/x3f3ZkQR1Tzw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4smjz04fgm2JA9StsvMx8tM6xOwGszuobDA8fpAZ+Qn0XSt7cE6ZCI9CNMpIbgF/ CTeipHi9i/0UzK5Ul9RDBPWMowy1S2r7JhHqAp/d5HKtvC/Tivb6pOm+wH2iXbRAeB LhRMLG05apA9yyJLK5DPN/DOKkylssebV1PEtfEA= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v3 07/14] ipa: libipa: Provide Q5.4 FixedPoint support Date: Thu, 13 Nov 2025 12:24:42 +0000 Message-ID: <20251113122450.287633-8-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 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.4 format representing values in the range [-16.0, 15.9375] with a resolution of 1/16. Signed-off-by: Kieran Bingham --- This format is used by the RKISP1/i.MX8MP for Chromatic Abberation Correction handling 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 5b5d3721bf85..5c7e05f99076 100644 --- a/src/ipa/libipa/fixedpoint.cpp +++ b/src/ipa/libipa/fixedpoint.cpp @@ -132,6 +132,15 @@ namespace ipa { * values in the range [0.0, 1.992] with a resolution of 1/128. */ +/** + * \typedef Q5_4 + * \brief 5.4 signed fixed-point quantizer + * + * A Quantized type using 5 bit for the integer part and 4 bits for the + * fractional part, stored in an signed 16-bit integer (\c int16_t). Represents + * values in the range [-16.0, 15.9375] with a resolution of 1/16. + */ + /** * \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 c3ee6b2ed69f..39d03632cb24 100644 --- a/src/ipa/libipa/fixedpoint.h +++ b/src/ipa/libipa/fixedpoint.h @@ -103,6 +103,8 @@ struct FixedPointQTraits { using Q1_7 = Quantized>; using UQ1_7 = Quantized>; +using Q5_4 = Quantized>; + using Q12_4 = Quantized>; using UQ12_4 = Quantized>; diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp index a806aa1e0ef6..61ad487fd950 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 */ + /* 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); + fails += quantizedCheck( 15.94f, 0b01111'1111, 15.9375f); + /* 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);