From patchwork Fri Nov 14 00:54:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25037 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 AF4B1C32DB for ; Fri, 14 Nov 2025 00:55:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AC58760AA3; Fri, 14 Nov 2025 01:54:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Sl4pNZCQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6710960A9E 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 D812C1306; Fri, 14 Nov 2025 01:52:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763081570; bh=WkCHl7q7EkW2IT3c4qk5dJwd7TPeEcVjNIGVOdput9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sl4pNZCQIyHzVOdJctHiSZD7nAMJ5I7udhqDIiYN9ss+TxwwvxmEAqJZsfd6/xHeK C3HwSPahD60YcrbGTXHAjCcC0SDUXI+vZftoyNfceXHqOc5nTmnGkgv9nEGy50zfUU xtYTWkfEQ31hhRMwJx7IWzSOUmHgaaR581Je+aks= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v4 07/21] ipa: libipa: Provide Q5.4 FixedPoint support Date: Fri, 14 Nov 2025 00:54:11 +0000 Message-ID: <20251114005428.90024-8-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.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 for Chromatic Abberation Correction handling v4: - Fix grammar in type documentation 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 4c3ea33497bf..967b00bcd7c2 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 Q5_4 + * \brief 5.4 signed fixed-point quantizer + * + * A Quantized type using 5 bits for the integer part and 4 bits for the + * fractional part, stored in a 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 d97e6d6135ad..ce621cb01a5a 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 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 338571e38f68..1d018c0128df 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);