From patchwork Fri Nov 14 00:54:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25036 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 C4FDBC32DC for ; Fri, 14 Nov 2025 00:55:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 598BF60B0B; Fri, 14 Nov 2025 01:54:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rsCgRSrH"; 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 1C33160A9D 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 886A51ADF; 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=1763081569; bh=S7W+F4U77Cj+CteLPKx3s8t6Hevdo98NcKTO5qf8Ql8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rsCgRSrH4l1zNa51u6dmve+8UMohJ9VN7mOFFJhSm6YnZ8xRDwR8FqB/GLk2+Ikuo 22Bq7s+bNMNq3peqzSWATW8emj4MX/292t1ftq19hpmwAVeOdRXaao2ZbVp2UPPRzQ GEkVLu4s7H6LcDLsdSpbzjxVyTv4/1bJrFqLcGcY= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v4 06/21] test: libipa: Add Q4.7 type and tests to match existing use case tests Date: Fri, 14 Nov 2025 00:54:10 +0000 Message-ID: <20251114005428.90024-7-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" The existing fixed point test cases utilise a signed Q4.7 format. Add matching tests covering the same values and extend to validate the full type. Signed-off-by: Kieran Bingham --- v4: - Remove redundant "No Sign Extension" comment test/ipa/libipa/fixedpoint.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp index 3f2d9ac97fe5..338571e38f68 100644 --- a/test/ipa/libipa/fixedpoint.cpp +++ b/test/ipa/libipa/fixedpoint.cpp @@ -20,6 +20,9 @@ using namespace std; using namespace libcamera; using namespace ipa; +/* Q4_7(-8 .. 7.99219) Min: [0x0400:-8] -- Max: [0x03ff:7.99219] Step:0.0078125 */ +using Q4_7 = Quantized>; + class FixedPointUtilsTest : public Test { protected: @@ -172,6 +175,21 @@ protected: fails += quantizedCheck(1.0f, 0b1'0000000, 1.0f); /* Mid */ fails += quantizedCheck(1.992f, 0b1'1111111, 1.99219f); /* Max */ + /* Q4_7(-8 .. 7.99219) Min: [0x0400:-8] -- Max: [0x03ff:7.99219] Step:0.0078125 */ + introduce("Q4_7"); + fails += quantizedCheck(-8.0f, 0b1000'0000000, -8.0f); /* Min */ + fails += quantizedCheck(-0.008f, 0b1111'1111111, -0.0078125); /* -1 step */ + fails += quantizedCheck( 0.0f, 0b0000'0000000, 0.0f); /* Zero */ + fails += quantizedCheck( 0.008f, 0b0000'0000001, 0.0078125f); /* +1 step */ + fails += quantizedCheck( 7.992f, 0b0111'1111111, 7.99219f); /* Max */ + + /* Retain additional tests from original testFixedPoint() */ + fails += quantizedCheck( 0.2f, 0b0000'0011010, 0.203125f); /* 0x01a */ + fails += quantizedCheck(-0.2f, 0b1111'1100110, -0.203125f); /* 0x7e6 */ + fails += quantizedCheck(-0.8f, 0b1111'0011010, -0.796875f); /* 0x79a */ + fails += quantizedCheck(-0.4f, 0b1111'1001101, -0.398438f); /* 0x7cd */ + fails += quantizedCheck(-1.4f, 0b1110'1001101, -1.39844f); /* 0x74d */ + /* 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);