[{"id":39677,"web_url":"https://patchwork.libcamera.org/comment/39677/","msgid":"<178395144160.3603632.299608963068446202@localhost>","date":"2026-07-13T14:04:01","subject":"Re: [PATCH v5 14/36] ipa: libipa: lsc_polynomial: Do not inline\n\tfunctions","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Jacopo,\n\nQuoting Jacopo Mondi (2026-07-08 17:50:56)\n> There is no reason to inline the Polynomial class implementation.\n> \n\nFor small classes like this I actually prefer having everything right\nthere on one screen page. But that is a very personal view. Our style\nguide proposes a limit of max 10 lines for header functions. So that\nwould only fit by squeezing a bit :-)\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nRegards,\nStefan\n\n> Move functions implementation to the corresponding .cpp file.\n> \n> While at it remove a rougue empty line between class members\n> definitions.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/libipa/lsc_polynomial.cpp | 34 +++++++++++++++++++++++++++++++---\n>  src/ipa/libipa/lsc_polynomial.h   | 36 +++---------------------------------\n>  2 files changed, 34 insertions(+), 36 deletions(-)\n> \n> diff --git a/src/ipa/libipa/lsc_polynomial.cpp b/src/ipa/libipa/lsc_polynomial.cpp\n> index b93063bf8bc7..fb6f959e5a09 100644\n> --- a/src/ipa/libipa/lsc_polynomial.cpp\n> +++ b/src/ipa/libipa/lsc_polynomial.cpp\n> @@ -47,7 +47,6 @@ namespace lsc {\n>   */\n>  \n>  /**\n> - * \\fn Polynomial::sampleAtNormalizedPixelPos(double x, double y)\n>   * \\brief Sample the polynomial at the given normalized pixel position\n>   *\n>   * This functions samples the polynomial at the given pixel position divided by\n> @@ -57,9 +56,20 @@ namespace lsc {\n>   * \\param y y position in normalized coordinates\n>   * \\return The sampled value\n>   */\n> +double Polynomial::sampleAtNormalizedPixelPos(double x, double y) const\n> +{\n> +       double dx = x - cnx_;\n> +       double dy = y - cny_;\n> +       double r = sqrt(dx * dx + dy * dy);\n> +       double res = 1.0;\n> +\n> +       for (unsigned int i = 0; i < coefficients_.size(); i++)\n> +               res += coefficients_[i] * std::pow(r, (i + 1) * 2);\n> +\n> +       return res;\n> +}\n>  \n>  /**\n> - * \\fn Polynomial::getM()\n>   * \\brief Get the value m as described in the dng specification\n>   *\n>   * Returns m according to dng spec. m represents the Euclidean distance\n> @@ -68,9 +78,17 @@ namespace lsc {\n>   *\n>   * \\return The sampled value\n>   */\n> +double Polynomial::getM() const\n> +{\n> +       double cpx = imageSize_.width * cx_;\n> +       double cpy = imageSize_.height * cy_;\n> +       double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));\n> +       double my = std::max(cpy, std::fabs(imageSize_.height - cpy));\n> +\n> +       return sqrt(mx * mx + my * my);\n> +}\n>  \n>  /**\n> - * \\fn Polynomial::setReferenceImageSize(const Size &size)\n>   * \\brief Set the reference image size\n>   *\n>   * Set the reference image size that is used for subsequent calls to getM() and\n> @@ -78,6 +96,16 @@ namespace lsc {\n>   *\n>   * \\param size The size of the reference image\n>   */\n> +void Polynomial::setReferenceImageSize(const Size &size)\n> +{\n> +       assert(!size.isNull());\n> +       imageSize_ = size;\n> +\n> +       /* Calculate normalized centers */\n> +       double m = getM();\n> +       cnx_ = (size.width * cx_) / m;\n> +       cny_ = (size.height * cy_) / m;\n> +}\n>  \n>  } /* namespace lsc */\n>  \n> diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h\n> index 3be33edfe7d8..2caf46d2d759 100644\n> --- a/src/ipa/libipa/lsc_polynomial.h\n> +++ b/src/ipa/libipa/lsc_polynomial.h\n> @@ -37,38 +37,9 @@ public:\n>         {\n>         }\n>  \n> -       double sampleAtNormalizedPixelPos(double x, double y) const\n> -       {\n> -               double dx = x - cnx_;\n> -               double dy = y - cny_;\n> -               double r = sqrt(dx * dx + dy * dy);\n> -               double res = 1.0;\n> -               for (unsigned int i = 0; i < coefficients_.size(); i++) {\n> -                       res += coefficients_[i] * std::pow(r, (i + 1) * 2);\n> -               }\n> -               return res;\n> -       }\n> -\n> -       double getM() const\n> -       {\n> -               double cpx = imageSize_.width * cx_;\n> -               double cpy = imageSize_.height * cy_;\n> -               double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));\n> -               double my = std::max(cpy, std::fabs(imageSize_.height - cpy));\n> -\n> -               return sqrt(mx * mx + my * my);\n> -       }\n> -\n> -       void setReferenceImageSize(const Size &size)\n> -       {\n> -               assert(!size.isNull());\n> -               imageSize_ = size;\n> -\n> -               /* Calculate normalized centers */\n> -               double m = getM();\n> -               cnx_ = (size.width * cx_) / m;\n> -               cny_ = (size.height * cy_) / m;\n> -       }\n> +       double sampleAtNormalizedPixelPos(double x, double y) const;\n> +       double getM() const;\n> +       void setReferenceImageSize(const Size &size);\n>  \n>  private:\n>         double cx_;\n> @@ -76,7 +47,6 @@ private:\n>         double cnx_;\n>         double cny_;\n>         std::array<double, 5> coefficients_;\n> -\n>         Size imageSize_;\n>  };\n>  \n> \n> -- \n> 2.54.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 7DD9EC32CE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jul 2026 14:04:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C1546611B;\n\tMon, 13 Jul 2026 16:04:07 +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 EDCA86604D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jul 2026 16:04:04 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:6c1f:355d:1c19:aba6])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 632341049;\n\tMon, 13 Jul 2026 16:03:11 +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=\"VYet/j57\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783951391;\n\tbh=MJYVqp5I3IicXIMA+XmuBE8jMAPMZjn8nzip07DHsRo=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=VYet/j57CG5aFWVLI38jTZROWwgI+B5dZpDUm4KjxTeckxtqXF1Rw4rPV6GWPU9TY\n\tJC1JKXkauahnHOc8C7rgIGodwErWSv1DaBLt54Mj9hThb8JZrrau6/KuwgQWBMr5Am\n\tIJx0Ymcw8Z/QWINg/tjIvBbtTpso7B/DnVGM1Wc0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260708-libipa-algorithms-v5-14-0759d0359f52@ideasonboard.com>","References":"<20260708-libipa-algorithms-v5-0-0759d0359f52@ideasonboard.com>\n\t<20260708-libipa-algorithms-v5-14-0759d0359f52@ideasonboard.com>","Subject":"Re: [PATCH v5 14/36] ipa: libipa: lsc_polynomial: Do not inline\n\tfunctions","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 13 Jul 2026 16:04:01 +0200","Message-ID":"<178395144160.3603632.299608963068446202@localhost>","User-Agent":"alot/0.12.dev43+g2cacc0d03","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>"}}]