From patchwork Tue Jan 20 08:39:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 25854 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 0076EC3220 for ; Tue, 20 Jan 2026 08:40:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA3DB61FBF; Tue, 20 Jan 2026 09:40:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OKYV0Zee"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 46DBC61F84 for ; Tue, 20 Jan 2026 09:39:59 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D00971733; Tue, 20 Jan 2026 09:39:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768898368; bh=nhBEs/vulo4lXzSxImOJXBozPzzWK9oolqgqUjJbqac=; h=From:To:Cc:Subject:Date:From; b=OKYV0ZeefAPIdtqU0IIwPSW6evxtE2DgKo5kv5G9wiRIrf4+ZMs3InwH6P70kpEDl NHJgsI/7nQjkVdr/Ir09HBd0lxenC9IXg8sTEQNuaIzcPM877Zx+Xrmv7J8hC74it0 donUnadRobvgvjLTDNM8qjERBRbi60EsC/oSXclI= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder Subject: [PATCH] ipa: libipa: fixedpoint: Expand documentation on sign bit Date: Tue, 20 Jan 2026 09:39:49 +0100 Message-ID: <20260120083952.15338-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.52.0 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" Converting numbers with a signed fixed-point representation to the corresponding float value requires to include the sign bit in the width of the fixed-point integral part. Clearly specify it in documentation. Signed-off-by: Jacopo Mondi --- src/ipa/libipa/fixedpoint.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 2.52.0 diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp index 6b698fc5d680..b37cdc43936f 100644 --- a/src/ipa/libipa/fixedpoint.cpp +++ b/src/ipa/libipa/fixedpoint.cpp @@ -29,11 +29,31 @@ namespace ipa { /** * \fn R fixedToFloatingPoint(T number) * \brief Convert a fixed-point number to a floating point representation - * \tparam I Bit width of the integer part of the fixed-point + * \tparam I Bit width of the integer part of the fixed-point including the + * optional sign bit * \tparam F Bit width of the fractional part of the fixed-point * \tparam R Return type of the floating point representation * \tparam T Input type of the fixed-point representation * \param number The fixed point number to convert to floating point + * + * If the fixed-point representation is signed, the sign bit shall be included + * in the \a I template parameter that specifies the number of bits of the + * integral part of the fixed-point representation. + * + * As an example, a value represented as signed fixed-point Q4.8 format can be + * converted to its corresponding floating point representation as: + * + * \code{.cpp} + * double d = fixedToFloatingPoint<5, 8, double, uint16_t>(fixed); + * \endcode + * + * While a value represented as unsigned fixed-point Q4.8 format can be + * converted as: + * + * \code{.cpp} + * double d = fixedToFloatingPoint<4, 8, double, uint16_t>(fixed); + * \endcode + * * \return The converted value */