From patchwork Wed Oct 29 17:24:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24895 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 BC86BC32D4 for ; Wed, 29 Oct 2025 17:25:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9A460875; Wed, 29 Oct 2025 18:25:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vadAB4Wx"; 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 D12D360869 for ; Wed, 29 Oct 2025 18:24:47 +0100 (CET) Received: from Monstersaurus.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 78CFD11DD; Wed, 29 Oct 2025 18:22:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761758578; bh=SZQYT53r5Ox7Ud7HzN///PZjUGCxZfuCQ4pvDrFIiCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vadAB4WxqivO+MqbfKTro5xMTFx+o4m8+aA02iopJyhfHAAKlTSUrOIC/hjqTcjYW mUO1jUlSLaFfMdrh2xMd93cFIQ/JL8QXiQ5MmXNndGq/9mYI8N7mGf4yAYx9k0x0Zq PbfYNN+EmeYNWSdqRJiy2sLIwBylCzsfzptX7x9A= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v2 06/13] test: libipa: Add Q4.7 type and tests to match existing use case tests Date: Wed, 29 Oct 2025 17:24:31 +0000 Message-ID: <20251029172439.1513907-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029172439.1513907-1-kieran.bingham@ideasonboard.com> References: <20251029172439.1513907-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 6f6ef4ce258e..4bffd40f5a63 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: Q:0x0400 V:-8 -- Max: Q:0x03ff V:7.99219 Step:0.0078125 */ +using Q4_7 = Quantized>; + class FixedPointUtilsTest : public Test { protected: @@ -171,6 +174,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: Q:0x0400 F:-8 -- Max: Q:0x03FF V: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 */ + /* Test Q12.4 */ introduce("Q12.4");