[{"id":19609,"web_url":"https://patchwork.libcamera.org/comment/19609/","msgid":"<YTt3dwwzXpIydBEx@pendragon.ideasonboard.com>","date":"2021-09-10T15:19:19","subject":"Re: [libcamera-devel] [PATCH v6 3/5] ipa: ipu3: Change Accumulator\n\tstructure layout","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Thu, Sep 09, 2021 at 03:54:47PM +0200, Jean-Michel Hautbois wrote:\n> The pixel component sums for the Accumulator are inconsistent with other\n> similar structures such as the IPAFrameContext::awb::gains. Group the\n> red, green, and blue sums together in a struct and store them as\n> uint64_t to reduce potential architectural differences.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/ipu3/algorithms/awb.cpp | 24 ++++++++++++------------\n>  src/ipa/ipu3/algorithms/awb.h   |  8 +++++---\n>  2 files changed, 17 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index 9b22c783..6bf114ac 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -77,13 +77,13 @@ static constexpr uint32_t kMinGreenLevelInZone = 32;\n>   * \\var Accumulator::counted\n>   * \\brief Number of unsaturated cells used to calculate the sums\n>   *\n> - * \\var Accumulator::rSum\n> + * \\var Accumulator::sum::red\n>   * \\brief Sum of the average red values of each cell in the zone\n>   *\n> - * \\var Accumulator::gSum\n> + * \\var Accumulator::sum::green\n>   * \\brief Sum of the average green values of each cell in the zone\n>   *\n> - * \\var Accumulator::bSum\n> + * \\var Accumulator::sum::blue\n>   * \\brief Sum of the average blue values of each cell in the zone\n>   */\n>  \n> @@ -208,10 +208,10 @@ void Awb::generateZones(std::vector<RGB> &zones)\n>  \t\tRGB zone;\n>  \t\tdouble counted = awbStats_[i].counted;\n>  \t\tif (counted >= kMinZonesCounted) {\n> -\t\t\tzone.G = awbStats_[i].gSum / counted;\n> +\t\t\tzone.G = awbStats_[i].sum.green / counted;\n>  \t\t\tif (zone.G >= kMinGreenLevelInZone) {\n> -\t\t\t\tzone.R = awbStats_[i].rSum / counted;\n> -\t\t\t\tzone.B = awbStats_[i].bSum / counted;\n> +\t\t\t\tzone.R = awbStats_[i].sum.red / counted;\n> +\t\t\t\tzone.B = awbStats_[i].sum.blue / counted;\n>  \t\t\t\tzones.push_back(zone);\n>  \t\t\t}\n>  \t\t}\n> @@ -244,9 +244,9 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n>  \t\t\t\t/* The cell is not saturated, use the current cell */\n>  \t\t\t\tawbStats_[awbRegionPosition].counted++;\n>  \t\t\t\tuint32_t greenValue = currentCell->greenRedAvg + currentCell->greenBlueAvg;\n> -\t\t\t\tawbStats_[awbRegionPosition].gSum += greenValue / 2;\n> -\t\t\t\tawbStats_[awbRegionPosition].rSum += currentCell->redAvg;\n> -\t\t\t\tawbStats_[awbRegionPosition].bSum += currentCell->blueAvg;\n> +\t\t\t\tawbStats_[awbRegionPosition].sum.green += greenValue / 2;\n> +\t\t\t\tawbStats_[awbRegionPosition].sum.red += currentCell->redAvg;\n> +\t\t\t\tawbStats_[awbRegionPosition].sum.blue += currentCell->blueAvg;\n>  \t\t\t}\n>  \t\t}\n>  \t}\n> @@ -255,9 +255,9 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n>  void Awb::clearAwbStats()\n>  {\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n> -\t\tawbStats_[i].bSum = 0;\n> -\t\tawbStats_[i].rSum = 0;\n> -\t\tawbStats_[i].gSum = 0;\n> +\t\tawbStats_[i].sum.blue = 0;\n> +\t\tawbStats_[i].sum.red = 0;\n> +\t\tawbStats_[i].sum.green = 0;\n>  \t\tawbStats_[i].counted = 0;\n>  \t}\n>  }\n> diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\n> index ac8ccc84..3385ebe7 100644\n> --- a/src/ipa/ipu3/algorithms/awb.h\n> +++ b/src/ipa/ipu3/algorithms/awb.h\n> @@ -35,9 +35,11 @@ struct Ipu3AwbCell {\n>  \n>  struct Accumulator {\n>  \tunsigned int counted;\n> -\tunsigned long long rSum;\n> -\tunsigned long long gSum;\n> -\tunsigned long long bSum;\n> +\tstruct {\n> +\t\tuint64_t red;\n> +\t\tuint64_t green;\n> +\t\tuint64_t blue;\n> +\t} sum;\n>  };\n>  \n>  class Awb : public Algorithm","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 C94F2BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Sep 2021 15:19:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A06F6917C;\n\tFri, 10 Sep 2021 17:19:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A2D436916A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Sep 2021 17:19:41 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C0F624F;\n\tFri, 10 Sep 2021 17:19:41 +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=\"mbnRCTeA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631287181;\n\tbh=gSVhSTOL3ArVB5X4qgg0R7U940ZLRigtMGIYJGS0FuA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mbnRCTeABgbBv/wsr0WEvsncI0wFkU4g5Z4NE+dWLFnZqwkQTfxwZpsy1irueqmZ8\n\tk9cqFWs8YaZYJr7rb20Qcb7+fqcZtG+qICQ0Hfv3CFaEgGFti+WSnBb/pRkEQNkPyT\n\tIoDoFIYF22kdnK2EPF6lBULg4upvh13pc4S3dP+o=","Date":"Fri, 10 Sep 2021 18:19:19 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YTt3dwwzXpIydBEx@pendragon.ideasonboard.com>","References":"<20210909135449.68017-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210909135449.68017-4-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210909135449.68017-4-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v6 3/5] ipa: ipu3: Change Accumulator\n\tstructure layout","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]