[{"id":38232,"web_url":"https://patchwork.libcamera.org/comment/38232/","msgid":"<177149196239.607498.12797376953581181949@neptunite.rasen.tech>","date":"2026-02-19T09:06:02","subject":"Re: [PATCH v7 14/15] test: libipa: Remove legacy fixed point\n\tconversion test","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Kieran Bingham (2026-02-14 01:57:53)\n> Now that the fixed point conversions are equally covered by the new Q types,\n> the legacy tests for fixedToFloatingPoint and floatingToFixedPoint are\n> redundant.\n> \n> Remove them, and replace the existing test cases with equivalant tests\n> using the new Q4.7 type directly to maintain identical test coverage.\n> \n> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> v4:\n> - Remove redundant \"No Sign Extension\" comment\n> \n> v5:\n> - Simplify to new Q<4, 7>\n> - Squash two patches together\n>   - test: libipa: Remove legacy fixed point conversion test\n>   - test: libipa: Add Q4.7 type and tests to match existing use case tests\n> ---\n>  test/ipa/libipa/fixedpoint.cpp | 93 +++++++-----------------------------------\n>  1 file changed, 15 insertions(+), 78 deletions(-)\n> \n> diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp\n> index 2907426b7a69..316d9f8f1b7d 100644\n> --- a/test/ipa/libipa/fixedpoint.cpp\n> +++ b/test/ipa/libipa/fixedpoint.cpp\n> @@ -23,80 +23,6 @@ using namespace ipa;\n>  class FixedPointUtilsTest : public Test\n>  {\n>  protected:\n> -       /* R for real, I for integer */\n> -       template<unsigned int IntPrec, unsigned int FracPrec, typename I, typename R>\n> -       int testFixedToFloat(I input, R expected)\n> -       {\n> -               R out = fixedToFloatingPoint<IntPrec, FracPrec, R>(input);\n> -               R prec = 1.0 / (1 << FracPrec);\n> -               if (std::abs(out - expected) > prec) {\n> -                       cerr << \"Reverse conversion expected \" << input\n> -                            << \" to convert to \" << expected\n> -                            << \", got \" << out << std::endl;\n> -                       return TestFail;\n> -               }\n> -\n> -               return TestPass;\n> -       }\n> -\n> -       template<unsigned int IntPrec, unsigned int FracPrec, typename T>\n> -       int testSingleFixedPoint(double input, T expected)\n> -       {\n> -               T ret = floatingToFixedPoint<IntPrec, FracPrec, T>(input);\n> -               if (ret != expected) {\n> -                       cerr << \"Expected \" << input << \" to convert to \"\n> -                            << expected << \", got \" << ret << std::endl;\n> -                       return TestFail;\n> -               }\n> -\n> -               /*\n> -                * The precision check is fairly arbitrary but is based on what\n> -                * the rkisp1 is capable of in the crosstalk module.\n> -                */\n> -               double f = fixedToFloatingPoint<IntPrec, FracPrec, double>(ret);\n> -               if (std::abs(f - input) > 0.005) {\n> -                       cerr << \"Reverse conversion expected \" << ret\n> -                            << \" to convert to \" << input\n> -                            << \", got \" << f << std::endl;\n> -                       return TestFail;\n> -               }\n> -\n> -               return TestPass;\n> -       }\n> -\n> -       int testFixedPoint()\n> -       {\n> -               /*\n> -                * The second 7.992 test is to test that unused bits don't\n> -                * affect the result.\n> -                */\n> -               std::map<double, int16_t> testCases = {\n> -                       { 7.992, 0x3ff },\n> -                       {   0.2, 0x01a },\n> -                       {  -0.2, 0x7e6 },\n> -                       {  -0.8, 0x79a },\n> -                       {  -0.4, 0x7cd },\n> -                       {  -1.4, 0x74d },\n> -                       {    -8, 0x400 },\n> -                       {     0, 0 },\n> -               };\n> -\n> -               int ret;\n> -               for (const auto &testCase : testCases) {\n> -                       ret = testSingleFixedPoint<4, 7, int16_t>(testCase.first,\n> -                                                                  testCase.second);\n> -                       if (ret != TestPass)\n> -                               return ret;\n> -               }\n> -\n> -               /* Special case with a superfluous one in the unused bits */\n> -               ret = testFixedToFloat<4, 7, int16_t, double>(0xbff, 7.992);\n> -               if (ret != TestPass)\n> -                       return ret;\n> -\n> -               return TestPass;\n> -       }\n> -\n>         template<typename Q>\n>         int quantizedCheck(float input, typename Q::QuantizedType expected, float value)\n>         {\n> @@ -219,6 +145,21 @@ protected:\n>                 fails += quantizedCheck<UQ<1, 7>>( 1.992f, 0b1'1111111, 1.99219f);      /* Max */\n>                 fails += quantizedCheck<UQ<1, 7>>( 2.000f, 0b1'1111111, 1.99219f);      /* Clamped to Max */\n>  \n> +               /* Q4.7(-8 .. 7.99219)  Min: [0x0400:-8] -- Max: [0x03ff:7.99219] Step:0.0078125 */\n> +               introduce<Q<4, 7>>(\"Q4.7\");\n> +               fails += quantizedCheck<Q<4, 7>>(-8.0f,   0b1000'0000000, -8.0f);       /* Min */\n> +               fails += quantizedCheck<Q<4, 7>>(-0.008f, 0b1111'1111111, -0.0078125);  /* -1 step */\n> +               fails += quantizedCheck<Q<4, 7>>( 0.0f,   0b0000'0000000,  0.0f);       /* Zero */\n> +               fails += quantizedCheck<Q<4, 7>>( 0.008f, 0b0000'0000001,  0.0078125f); /* +1 step */\n> +               fails += quantizedCheck<Q<4, 7>>( 7.992f, 0b0111'1111111,  7.99219f);   /* Max */\n> +\n> +               /* Retain additional tests from original testFixedPoint() */\n> +               fails += quantizedCheck<Q<4, 7>>( 0.2f, 0b0000'0011010,  0.203125f);    /* 0x01a */\n> +               fails += quantizedCheck<Q<4, 7>>(-0.2f, 0b1111'1100110, -0.203125f);    /* 0x7e6 */\n> +               fails += quantizedCheck<Q<4, 7>>(-0.8f, 0b1111'0011010, -0.796875f);    /* 0x79a */\n> +               fails += quantizedCheck<Q<4, 7>>(-0.4f, 0b1111'1001101, -0.398438f);    /* 0x7cd */\n> +               fails += quantizedCheck<Q<4, 7>>(-1.4f, 0b1110'1001101, -1.39844f);     /* 0x74d */\n> +\n>                 /* UQ4.8(0 .. 15.9961)  Min: [0x0000:0] -- Max: [0x0fff:15.9961] Step:0.00390625 */\n>                 introduce<UQ<4, 8>>(\"UQ4.8\");\n>                 fails += quantizedCheck<UQ<4, 8>>( 0.0f, 0b0000'00000000,  0.00f);\n> @@ -295,10 +236,6 @@ protected:\n>         {\n>                 unsigned int fails = 0;\n>  \n> -               /* fixed point conversion test */\n> -               if (testFixedPoint() != TestPass)\n> -                       fails++;\n> -\n>                 if (testFixedPointQuantizers() != TestPass)\n>                         fails++;\n>  \n> \n> -- \n> 2.52.0\n>","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 663F9C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Feb 2026 09:06:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B1F362239;\n\tThu, 19 Feb 2026 10:06:09 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13CDF62010\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Feb 2026 10:06:08 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:3150:3f17:6415:4c60])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 832AF673;\n\tThu, 19 Feb 2026 10:05:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tbsuuH7G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771491915;\n\tbh=ipzmvGKb3HWG0/AbhdV1DAKWIIlS7EHW+f8hHpUqUqY=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=tbsuuH7GpkizWlR/ZpvGru41VjKT7e/CvpKC6HxHtyegoYJ/tpZjTIZWykQxd246d\n\thA1YL5IP0zSLYlmVIAGgJwDjp75/Q4YG2kGWB2w3K3fxshWPzveMg18L2r0uHWvv+c\n\t2XPgPXqbEZik6S7+wXNrPzzh5aM+pbon4hGKqMGY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260213-kbingham-quantizers-v7-14-1626b9aaabf1@ideasonboard.com>","References":"<20260213-kbingham-quantizers-v7-0-1626b9aaabf1@ideasonboard.com>\n\t<20260213-kbingham-quantizers-v7-14-1626b9aaabf1@ideasonboard.com>","Subject":"Re: [PATCH v7 14/15] test: libipa: Remove legacy fixed point\n\tconversion test","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tIsaac Scott <isaac.scott@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 19 Feb 2026 18:06:02 +0900","Message-ID":"<177149196239.607498.12797376953581181949@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]