From patchwork Thu Nov 13 12:24:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25020 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 3D33FC3331 for ; Thu, 13 Nov 2025 12:25:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C63E60AAB; Thu, 13 Nov 2025 13:25:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jw66ge7c"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B051D60AA2 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 9868F165B; 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=COMbT/x7y8SpTaTx7SqymdMaFbqDsG+zHks9cAuTjuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jw66ge7cO75A92JIkL1kvSqMl9hSBh50KKebk7hbO2LbA6pOi6D0sGNs2ObXYHNsn EyJWMrml1gRi+DbSr8SmhAXx7XWJF/en66+qr4gnQSTwQdsKBL/hFDXEG4cGu3RYSB OaWvIa5a7V0oR5mGBu7vc5ztEfxCjXvSH235xXHM= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v3 06/14] test: libipa: Add Q4.7 type and tests to match existing use case tests Date: Thu, 13 Nov 2025 12:24:41 +0000 Message-ID: <20251113122450.287633-7-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" 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 --- 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..a806aa1e0ef6 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"); /* No Sign Extension */ + 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);