{"id":20243,"url":"https://patchwork.libcamera.org/api/patches/20243/?format=json","web_url":"https://patchwork.libcamera.org/patch/20243/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240607100323.3029238-1-paul.elder@ideasonboard.com>","date":"2024-06-07T10:03:23","name":"[v2] test: ipa: rkisp1: utils: Fix floating and fixed point conversion test","commit_ref":"f3caea0ff7e63b529c9464f911162aa457e9b858","pull_url":null,"state":"accepted","archived":false,"hash":"eee99d884f802b7bfeaf23d2341cd5f4d834a9fe","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20243/mbox/","series":[{"id":4376,"url":"https://patchwork.libcamera.org/api/series/4376/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4376","date":"2024-06-07T10:03:23","name":"[v2] test: ipa: rkisp1: utils: Fix floating and fixed point conversion test","version":2,"mbox":"https://patchwork.libcamera.org/series/4376/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20243/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20243/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A9DE6C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Jun 2024 10:03:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CAB31634BA;\n\tFri,  7 Jun 2024 12:03:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0581C633DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Jun 2024 12:03:36 +0200 (CEST)","from neptunite.hamster-moth.ts.net\n\t(h175-177-049-156.catv02.itscom.jp [175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0E38720;\n\tFri,  7 Jun 2024 12:03:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bzayfmq3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717754607;\n\tbh=kBjW03Ih6M4ve93M5apBZ0JSISriOuRf5XCXevzIph4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=bzayfmq3hPnm8v6dV2C5SH9bwgT+4dz/qDD8rjE54g4UMYq0iiAN8nKWZACMDfobC\n\tyNWQojmOL2S54mZNhUZ/9VLryzxKxIV81cP3ygsNDLnDuW8fIH66ZJ8kTzGLKipB/p\n\tHwY5yzpOn+TbP/kPRhiEL2CRuqhlc8LIalhM+tpU=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2] test: ipa: rkisp1: utils: Fix floating and fixed point\n\tconversion test","Date":"Fri,  7 Jun 2024 19:03:23 +0900","Message-Id":"<20240607100323.3029238-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.39.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"There was an issue where using map to store the test cases meant that\nthe test for ignoring unused bits was skipped because of clashing keys.\nFix this by moving the offending test out of the loop.\n\nWhile at it, also change the arbitrary floating comparison precision to\nbe more precise.\n\nAlso fix a missing documentation brief.\n\nFixes: 9d152e9c6 ipa: rkisp1: Add a helper to convert floating-point to\nfixed-point\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\nChanges in v2:\n- remove the added complexity that would've made it clearner to add a\n  larger variety of tests because the variety wasn't there\n---\n test/ipa/rkisp1/rkisp1-utils.cpp | 24 ++++++++++++++++++++++--\n 1 file changed, 22 insertions(+), 2 deletions(-)","diff":"diff --git a/test/ipa/rkisp1/rkisp1-utils.cpp b/test/ipa/rkisp1/rkisp1-utils.cpp\nindex e48f8d362..b1863894c 100644\n--- a/test/ipa/rkisp1/rkisp1-utils.cpp\n+++ b/test/ipa/rkisp1/rkisp1-utils.cpp\n@@ -21,7 +21,23 @@ using namespace ipa::rkisp1;\n class RkISP1UtilsTest : public Test\n {\n protected:\n-\ttemplate<unsigned int IntPrec, unsigned FracPrec, typename T>\n+\t/* R for real, I for integer */\n+\ttemplate<unsigned int IntPrec, unsigned int FracPrec, typename I, typename R>\n+\tint testFixedToFloat(I input, R expected)\n+\t{\n+\t\tR out = utils::fixedToFloatingPoint<IntPrec, FracPrec, R>(input);\n+\t\tR prec = 1.0 / (1 << FracPrec);\n+\t\tif (std::abs(out - expected) > prec) {\n+\t\t\tcerr << \"Reverse conversion expected \" << input\n+\t\t\t     << \" to convert to \" << expected\n+\t\t\t     << \", got \" << out << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\ttemplate<unsigned int IntPrec, unsigned int FracPrec, typename T>\n \tint testSingleFixedPoint(double input, T expected)\n \t{\n \t\tT ret = utils::floatingToFixedPoint<IntPrec, FracPrec, T>(input);\n@@ -54,7 +70,6 @@ protected:\n \t\t */\n \t\tstd::map<double, uint16_t> testCases = {\n \t\t\t{ 7.992, 0x3ff },\n-\t\t\t{ 7.992, 0xbff },\n \t\t\t{   0.2, 0x01a },\n \t\t\t{  -0.2, 0x7e6 },\n \t\t\t{  -0.8, 0x79a },\n@@ -72,6 +87,11 @@ protected:\n \t\t\t\treturn ret;\n \t\t}\n \n+\t\t/* Special case with a superfluous one in the unused bits */\n+\t\tret = testFixedToFloat<4, 7, uint16_t, double>(0xbff, 7.992);\n+\t\tif (ret != TestPass)\n+\t\t\treturn ret;\n+\n \t\treturn TestPass;\n \t}\n \n","prefixes":["v2"]}