[{"id":29794,"web_url":"https://patchwork.libcamera.org/comment/29794/","msgid":"<171801361779.666557.9515458227468939746@ping.linuxembedded.co.uk>","date":"2024-06-10T10:00:17","subject":"Re: [PATCH v2] test: ipa: rkisp1: utils: Fix floating and fixed\n\tpoint conversion test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2024-06-07 11:03:23)\n> There was an issue where using map to store the test cases meant that\n> the test for ignoring unused bits was skipped because of clashing keys.\n> Fix this by moving the offending test out of the loop.\n> \n> While at it, also change the arbitrary floating comparison precision to\n> be more precise.\n> \n> Also fix a missing documentation brief.\n> \n> Fixes: 9d152e9c6 ipa: rkisp1: Add a helper to convert floating-point to\n> fixed-point\n\nI think it's better to keep trailier lines on a single line even if it\nextends beyond 72/80 chars.\n\nI think the title is normally in brackets and quotes too?\n\nFixes: 9d152e9c6 (\"ipa: rkisp1: Add a helper to convert floating-point to fixed-point\")\n\nBut just trivial nits. That doesn't seem to be enforced by checkstyle\npresently.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> Changes 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(-)\n> \n> diff --git a/test/ipa/rkisp1/rkisp1-utils.cpp b/test/ipa/rkisp1/rkisp1-utils.cpp\n> index 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> -       template<unsigned int IntPrec, unsigned FracPrec, typename T>\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 = utils::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 = utils::floatingToFixedPoint<IntPrec, FracPrec, T>(input);\n> @@ -54,7 +70,6 @@ protected:\n>                  */\n>                 std::map<double, uint16_t> testCases = {\n>                         { 7.992, 0x3ff },\n> -                       { 7.992, 0xbff },\n>                         {   0.2, 0x01a },\n>                         {  -0.2, 0x7e6 },\n>                         {  -0.8, 0x79a },\n> @@ -72,6 +87,11 @@ protected:\n>                                 return ret;\n>                 }\n>  \n> +               /* Special case with a superfluous one in the unused bits */\n> +               ret = testFixedToFloat<4, 7, uint16_t, double>(0xbff, 7.992);\n> +               if (ret != TestPass)\n> +                       return ret;\n> +\n>                 return TestPass;\n>         }\n>  \n> -- \n> 2.39.2\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 980A6BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jun 2024 10:00:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1AA076545E;\n\tMon, 10 Jun 2024 12:00:23 +0200 (CEST)","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 79DA065446\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jun 2024 12:00:21 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B09839F;\n\tMon, 10 Jun 2024 12:00:09 +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=\"SGAIMQEa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1718013609;\n\tbh=Sdk2ZnPQSyDC5ZjKM/dP+xJ8v7YHrpCMS3OlzM0ff4M=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=SGAIMQEaYZPBrJDW4vs/ajFO75HBi/6zHltmYtuFeAmcDoI+f9GRlo/tK+Kfwwt0l\n\t6fWvOzpuz0nB/RgMQle7e/Of1IU0iH2rUzfrM/t7INckgbnuiLeVKxqmIAez7xhtNF\n\tmdzTAjoGcIfomti19cLGFPcLpLUGnX31cmfl9YlQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240607100323.3029238-1-paul.elder@ideasonboard.com>","References":"<20240607100323.3029238-1-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v2] test: ipa: rkisp1: utils: Fix floating and fixed\n\tpoint conversion test","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 10 Jun 2024 11:00:17 +0100","Message-ID":"<171801361779.666557.9515458227468939746@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":29809,"web_url":"https://patchwork.libcamera.org/comment/29809/","msgid":"<171802513475.1489778.2467473232364802193@ping.linuxembedded.co.uk>","date":"2024-06-10T13:12:14","subject":"Re: [PATCH v2] test: ipa: rkisp1: utils: Fix floating and fixed\n\tpoint conversion test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Kieran Bingham (2024-06-10 11:00:17)\n> Quoting Paul Elder (2024-06-07 11:03:23)\n> > There was an issue where using map to store the test cases meant that\n> > the test for ignoring unused bits was skipped because of clashing keys.\n> > Fix this by moving the offending test out of the loop.\n> > \n> > While at it, also change the arbitrary floating comparison precision to\n> > be more precise.\n> > \n> > Also fix a missing documentation brief.\n> > \n> > Fixes: 9d152e9c6 ipa: rkisp1: Add a helper to convert floating-point to\n> > fixed-point\n> \n> I think it's better to keep trailier lines on a single line even if it\n> extends beyond 72/80 chars.\n> \n> I think the title is normally in brackets and quotes too?\n> \n> Fixes: 9d152e9c6 (\"ipa: rkisp1: Add a helper to convert floating-point to fixed-point\")\n> \n> But just trivial nits. That doesn't seem to be enforced by checkstyle\n> presently.\n\nHrm ... I take that back - checkstyle certainly does have a rule for\nthis:\n\n\n\ncommit_regex = re.compile(r'[0-9a-f]{12}[0-9a-f]* \\(\".*\"\\)')\n\n    known_trailers = {\n    \t...\n        'Fixes': commit_regex,\n\t...\n    }\n\nSo - it should be enforced to be:\n\nFixes: 9d152e9c66c1 (\"ipa: rkisp1: Add a helper to convert floating-point to fixed-point\")\n\n--\nKieran\n\n\n> \n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > \n> > ---\n> > Changes 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(-)\n> > \n> > diff --git a/test/ipa/rkisp1/rkisp1-utils.cpp b/test/ipa/rkisp1/rkisp1-utils.cpp\n> > index 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> > -       template<unsigned int IntPrec, unsigned FracPrec, typename T>\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 = utils::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 = utils::floatingToFixedPoint<IntPrec, FracPrec, T>(input);\n> > @@ -54,7 +70,6 @@ protected:\n> >                  */\n> >                 std::map<double, uint16_t> testCases = {\n> >                         { 7.992, 0x3ff },\n> > -                       { 7.992, 0xbff },\n> >                         {   0.2, 0x01a },\n> >                         {  -0.2, 0x7e6 },\n> >                         {  -0.8, 0x79a },\n> > @@ -72,6 +87,11 @@ protected:\n> >                                 return ret;\n> >                 }\n> >  \n> > +               /* Special case with a superfluous one in the unused bits */\n> > +               ret = testFixedToFloat<4, 7, uint16_t, double>(0xbff, 7.992);\n> > +               if (ret != TestPass)\n> > +                       return ret;\n> > +\n> >                 return TestPass;\n> >         }\n> >  \n> > -- \n> > 2.39.2\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 532B9BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jun 2024 13:12:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 738096545E;\n\tMon, 10 Jun 2024 15:12:19 +0200 (CEST)","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 D7403634D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jun 2024 15:12:17 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CC4A6397;\n\tMon, 10 Jun 2024 15:12:05 +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=\"eNY1llc3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1718025125;\n\tbh=Gt1P+77hsJjoNrcVLXiTInrdnZsMwet66n5SglIin0I=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=eNY1llc3CLmgkmPnbNzRJhUd4wVHR6rWaJ/2SuCxJvDCcfnYCLoKUOEFHnV0GZFma\n\tIvmdl+rC5fNVSp7rpOZ6skrK6Fdr3YDHGNDI5drvrCDOYcV3+lZRmR1TPJm9d7Sdg2\n\tA0k/o8Jg1Mei0AcktYLm62iV5jXnt9VrIjVszPyI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<171801361779.666557.9515458227468939746@ping.linuxembedded.co.uk>","References":"<20240607100323.3029238-1-paul.elder@ideasonboard.com>\n\t<171801361779.666557.9515458227468939746@ping.linuxembedded.co.uk>","Subject":"Re: [PATCH v2] test: ipa: rkisp1: utils: Fix floating and fixed\n\tpoint conversion test","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 10 Jun 2024 14:12:14 +0100","Message-ID":"<171802513475.1489778.2467473232364802193@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]