[{"id":19928,"web_url":"https://patchwork.libcamera.org/comment/19928/","msgid":"<20210928141020.dy4b7bc4v3dd6a55@ideasonboard.com>","date":"2021-09-28T14:10:20","subject":"Re: [libcamera-devel] [PATCH 04/12] ipa: ipu3: awb: Make the naming\n\tconsistent","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On Thu, Sep 23, 2021 at 10:16:17AM +0200, Jean-Michel Hautbois wrote:\n> The variables mix the terms cell, region and zone. It can confuse the\n> reader, and make the algorithm more difficult to follow. Rename the\n> local variables consistent with their definitions:\n\ns/variables consistent/variables to be consistent/\n\n> - Cells are defined in Pixels\n> - Zones are defined in Cells\n> There is no \"region\" as such, so replace it with the correct term.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/ipa/ipu3/algorithms/awb.cpp | 31 +++++++++++++++++--------------\n>  1 file changed, 17 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index d78ae4f4..51a38d05 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -220,31 +220,34 @@ void Awb::generateZones(std::vector<RGB> &zones)\n>  void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n>  \t\t\t   const ipu3_uapi_grid_config &grid)\n>  {\n> -\tuint32_t regionWidth = round(grid.width / static_cast<double>(kAwbStatsSizeX));\n> -\tuint32_t regionHeight = round(grid.height / static_cast<double>(kAwbStatsSizeY));\n> +\tuint32_t cellsPerZoneX = round(grid.width / static_cast<double>(kAwbStatsSizeX));\n> +\tuint32_t cellsPerZoneY = round(grid.height / static_cast<double>(kAwbStatsSizeY));\n>  \n>  \t/*\n>  \t * Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is\n>  \t * (grid.width x grid.height).\n>  \t */\n> -\tfor (unsigned int j = 0; j < kAwbStatsSizeY * regionHeight; j++) {\n> -\t\tfor (unsigned int i = 0; i < kAwbStatsSizeX * regionWidth; i++) {\n> -\t\t\tuint32_t cellPosition = j * grid.width + i;\n> -\t\t\tuint32_t cellX = (cellPosition / regionWidth) % kAwbStatsSizeX;\n> -\t\t\tuint32_t cellY = ((cellPosition / grid.width) / regionHeight) % kAwbStatsSizeY;\n> +\tfor (unsigned int cellY = 0; cellY < kAwbStatsSizeY * cellsPerZoneY; cellY++) {\n> +\t\tfor (unsigned int cellX = 0; cellX < kAwbStatsSizeX * cellsPerZoneX; cellX++) {\n> +\t\t\tuint32_t cellPosition = (cellY * grid.width + cellX)\n> +\t\t\t\t\t      * sizeof(Ipu3AwbCell);\n> +\t\t\tuint32_t zoneX = cellX / cellsPerZoneX;\n> +\t\t\tuint32_t zoneY = cellY / cellsPerZoneY;\n>  \n> -\t\t\tuint32_t awbRegionPosition = cellY * kAwbStatsSizeX + cellX;\n> -\t\t\tcellPosition *= 8;\n> +\t\t\tuint32_t awbZonePosition = zoneY * kAwbStatsSizeX + zoneX;\n>  \n>  \t\t\t/* Cast the initial IPU3 structure to simplify the reading */\n> -\t\t\tIpu3AwbCell *currentCell = reinterpret_cast<Ipu3AwbCell *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[cellPosition]));\n> +\t\t\tconst Ipu3AwbCell *currentCell =\n> +\t\t\t\treinterpret_cast<const Ipu3AwbCell *>(\n> +\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]\n> +\t\t\t\t);\n>  \t\t\tif (currentCell->satRatio == 0) {\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\tawbStats_[awbZonePosition].counted++;\n>  \t\t\t\tuint32_t greenValue = currentCell->greenRedAvg + currentCell->greenBlueAvg;\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\tawbStats_[awbZonePosition].sum.green += greenValue / 2;\n> +\t\t\t\tawbStats_[awbZonePosition].sum.red += currentCell->redAvg;\n> +\t\t\t\tawbStats_[awbZonePosition].sum.blue += currentCell->blueAvg;\n>  \t\t\t}\n>  \t\t}\n>  \t}\n> -- \n> 2.30.2\n> \n\n--\nKieran","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 C8064C3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Sep 2021 14:10:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2352F6918C;\n\tTue, 28 Sep 2021 16:10:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0696269185\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Sep 2021 16:10:22 +0200 (CEST)","from ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 98B6B3F1;\n\tTue, 28 Sep 2021 16:10:21 +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=\"WV59LUn5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632838221;\n\tbh=dpj/c6v1un8DtmbZwpvvD489ch2KX+DfEKGqHAkUpy4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=WV59LUn5Q8+9ALmi4oaMqH+xWJqF7NUEovjzCc0HpHd6HsvvzkDUyPQJAVGnEYpYv\n\tO0i5/SIiW1rETmwaBO4mBkjQl8e610+WtOZ163ADaVRt8watXq9bFZdMpG87D4vOSL\n\teheQcBKW+U72IurvTm9gtsEk8BafnZRH2GAcOBW0=","Date":"Tue, 28 Sep 2021 15:10:20 +0100","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<20210928141020.dy4b7bc4v3dd6a55@ideasonboard.com>","References":"<20210923081625.60276-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210923081625.60276-5-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210923081625.60276-5-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 04/12] ipa: ipu3: awb: Make the naming\n\tconsistent","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>"}},{"id":19987,"web_url":"https://patchwork.libcamera.org/comment/19987/","msgid":"<YVRQxYG6aKkMdisp@pendragon.ideasonboard.com>","date":"2021-09-29T11:40:53","subject":"Re: [libcamera-devel] [PATCH 04/12] ipa: ipu3: awb: Make the naming\n\tconsistent","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Sep 28, 2021 at 03:10:20PM +0100, Kieran Bingham wrote:\n> On Thu, Sep 23, 2021 at 10:16:17AM +0200, Jean-Michel Hautbois wrote:\n> > The variables mix the terms cell, region and zone. It can confuse the\n> > reader, and make the algorithm more difficult to follow. Rename the\n> > local variables consistent with their definitions:\n> \n> s/variables consistent/variables to be consistent/\n> \n> > - Cells are defined in Pixels\n> > - Zones are defined in Cells\n> > There is no \"region\" as such, so replace it with the correct term.\n> > \n> > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> \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 | 31 +++++++++++++++++--------------\n> >  1 file changed, 17 insertions(+), 14 deletions(-)\n> > \n> > diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> > index d78ae4f4..51a38d05 100644\n> > --- a/src/ipa/ipu3/algorithms/awb.cpp\n> > +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> > @@ -220,31 +220,34 @@ void Awb::generateZones(std::vector<RGB> &zones)\n> >  void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n> >  \t\t\t   const ipu3_uapi_grid_config &grid)\n> >  {\n> > -\tuint32_t regionWidth = round(grid.width / static_cast<double>(kAwbStatsSizeX));\n> > -\tuint32_t regionHeight = round(grid.height / static_cast<double>(kAwbStatsSizeY));\n> > +\tuint32_t cellsPerZoneX = round(grid.width / static_cast<double>(kAwbStatsSizeX));\n> > +\tuint32_t cellsPerZoneY = round(grid.height / static_cast<double>(kAwbStatsSizeY));\n> >  \n> >  \t/*\n> >  \t * Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is\n> >  \t * (grid.width x grid.height).\n> >  \t */\n> > -\tfor (unsigned int j = 0; j < kAwbStatsSizeY * regionHeight; j++) {\n> > -\t\tfor (unsigned int i = 0; i < kAwbStatsSizeX * regionWidth; i++) {\n> > -\t\t\tuint32_t cellPosition = j * grid.width + i;\n> > -\t\t\tuint32_t cellX = (cellPosition / regionWidth) % kAwbStatsSizeX;\n> > -\t\t\tuint32_t cellY = ((cellPosition / grid.width) / regionHeight) % kAwbStatsSizeY;\n> > +\tfor (unsigned int cellY = 0; cellY < kAwbStatsSizeY * cellsPerZoneY; cellY++) {\n> > +\t\tfor (unsigned int cellX = 0; cellX < kAwbStatsSizeX * cellsPerZoneX; cellX++) {\n> > +\t\t\tuint32_t cellPosition = (cellY * grid.width + cellX)\n> > +\t\t\t\t\t      * sizeof(Ipu3AwbCell);\n> > +\t\t\tuint32_t zoneX = cellX / cellsPerZoneX;\n> > +\t\t\tuint32_t zoneY = cellY / cellsPerZoneY;\n> >  \n> > -\t\t\tuint32_t awbRegionPosition = cellY * kAwbStatsSizeX + cellX;\n> > -\t\t\tcellPosition *= 8;\n> > +\t\t\tuint32_t awbZonePosition = zoneY * kAwbStatsSizeX + zoneX;\n> >  \n> >  \t\t\t/* Cast the initial IPU3 structure to simplify the reading */\n> > -\t\t\tIpu3AwbCell *currentCell = reinterpret_cast<Ipu3AwbCell *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[cellPosition]));\n> > +\t\t\tconst Ipu3AwbCell *currentCell =\n> > +\t\t\t\treinterpret_cast<const Ipu3AwbCell *>(\n> > +\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]\n> > +\t\t\t\t);\n> >  \t\t\tif (currentCell->satRatio == 0) {\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\tawbStats_[awbZonePosition].counted++;\n> >  \t\t\t\tuint32_t greenValue = currentCell->greenRedAvg + currentCell->greenBlueAvg;\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\tawbStats_[awbZonePosition].sum.green += greenValue / 2;\n> > +\t\t\t\tawbStats_[awbZonePosition].sum.red += currentCell->redAvg;\n> > +\t\t\t\tawbStats_[awbZonePosition].sum.blue += currentCell->blueAvg;\n> >  \t\t\t}\n> >  \t\t}\n> >  \t}","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 3C562BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Sep 2021 11:40:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6E376691AA;\n\tWed, 29 Sep 2021 13:40:57 +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 1FE3F69185\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Sep 2021 13:40:56 +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 83BF83F0;\n\tWed, 29 Sep 2021 13:40:55 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BObVb1lH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632915655;\n\tbh=Y9LMhRluB/MpYSzbyW9IrI9hrYwp2NYHfnqhh/7M0XA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BObVb1lH9uILdIFPFQQOe4+dqLNtaOcvrTW4tR5mSKhPb9HKHkGVGxJjhVFqhlPh6\n\t+pHmnemoN1sMgT5Fof88E8E9fOC1LRpXIB9Iy+8BB44vRhGIplvZeEfmJTVEFzFyiK\n\t7g+fQBmHkeFzIOJr8n88/s0nlQ3ZPsutCyguxt/4=","Date":"Wed, 29 Sep 2021 14:40:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YVRQxYG6aKkMdisp@pendragon.ideasonboard.com>","References":"<20210923081625.60276-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210923081625.60276-5-jeanmichel.hautbois@ideasonboard.com>\n\t<20210928141020.dy4b7bc4v3dd6a55@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210928141020.dy4b7bc4v3dd6a55@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 04/12] ipa: ipu3: awb: Make the naming\n\tconsistent","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>"}}]