[{"id":27951,"web_url":"https://patchwork.libcamera.org/comment/27951/","msgid":"<23nmh3rhclpvuacqqigeal6iuzpm7jvqg7bqzlwtniobcraucu@hxlqdmmf4vzd>","date":"2023-10-12T09:34:53","subject":"Re: [libcamera-devel] [PATCH 10/20] ipa: rpi: Prepare AWB for PiSP\n\tsupport","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Fri, Oct 06, 2023 at 02:19:50PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Prepare the AWB algorithm to support the PiSP hardware. The key change\n> is to factor in the LS correction in the AWB zone statistics. This is\n> different from VC4 where the LS correction happens before statistics\n> gathering.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/ipa/rpi/controller/rpi/awb.cpp | 29 ++++++++++++++++++++---------\n>  1 file changed, 20 insertions(+), 9 deletions(-)\n>\n> diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> index ef3435d66106..5ae0c2fad6e9 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -12,6 +12,7 @@\n>\n>  #include \"../lux_status.h\"\n>\n> +#include \"alsc_status.h\"\n>  #include \"awb.h\"\n>\n>  using namespace RPiController;\n> @@ -398,18 +399,28 @@ void Awb::asyncFunc()\n>  }\n>\n>  static void generateStats(std::vector<Awb::RGB> &zones,\n> -\t\t\t  RgbyRegions &stats, double minPixels,\n> -\t\t\t  double minG)\n> +\t\t\t  StatisticsPtr &stats, double minPixels,\n> +\t\t\t  double minG, Metadata &globalMetadata)\n>  {\n> -\tfor (auto const &region : stats) {\n> +\tstd::scoped_lock<RPiController::Metadata> l(globalMetadata);\n> +\n> +\tfor (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {\n>  \t\tAwb::RGB zone;\n> +\t\tauto &region = stats->awbRegions.get(i);\n>  \t\tif (region.counted >= minPixels) {\n>  \t\t\tzone.G = region.val.gSum / region.counted;\n> -\t\t\tif (zone.G >= minG) {\n> -\t\t\t\tzone.R = region.val.rSum / region.counted;\n> -\t\t\t\tzone.B = region.val.bSum / region.counted;\n> -\t\t\t\tzones.push_back(zone);\n> +\t\t\tif (zone.G < minG)\n> +\t\t\t\tcontinue;\n> +\t\t\tzone.R = region.val.rSum / region.counted;\n> +\t\t\tzone.B = region.val.bSum / region.counted;\n> +\t\t\t/* Factor in the ALSC applied colour shading correction if required. */\n> +\t\t\tconst AlscStatus *alscStatus = globalMetadata.getLocked<AlscStatus>(\"alsc.status\");\n> +\t\t\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PreLsc && alscStatus) {\n> +\t\t\t\tzone.R *= alscStatus->r[i];\n> +\t\t\t\tzone.G *= alscStatus->g[i];\n> +\t\t\t\tzone.B *= alscStatus->b[i];\n>  \t\t\t}\n> +\t\t\tzones.push_back(zone);\n>  \t\t}\n>  \t}\n>  }\n> @@ -421,8 +432,8 @@ void Awb::prepareStats()\n>  \t * LSC has already been applied to the stats in this pipeline, so stop\n>  \t * any LSC compensation.  We also ignore config_.fast in this version.\n>  \t */\n> -\tgenerateStats(zones_, statistics_->awbRegions, config_.minPixels,\n> -\t\t      config_.minG);\n> +\tgenerateStats(zones_, statistics_, config_.minPixels,\n> +\t\t      config_.minG, getGlobalMetadata());\n>  \t/*\n>  \t * apply sensitivities, so values appear to come from our \"canonical\"\n>  \t * sensor.\n> --\n> 2.34.1\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 14A6FC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Oct 2023 09:34:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 680576297B;\n\tThu, 12 Oct 2023 11:34:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3879262962\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Oct 2023 11:34:57 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E336D8C2;\n\tThu, 12 Oct 2023 11:34:53 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697103298;\n\tbh=Z3Pq7/05fdJj7CRJAoQZL6GH275a7IibSw/3tfuLYZA=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ssPhG9odi6ajg4d+rHdWQ32nKY4WmQp97AH0+LlIGLiDfIyb8EMZho0Z3N67vb70o\n\tF8kOC5ESpPDxe8caaAYha3bLzh/+If6YeBTtIixGcYynaY5huRwYy3c+qVz8pidG60\n\tDkgepOClWkv3qImPPpZ6oxXOUuQregrNWKro5WQghTtoKoHU9ueh9tmDH2l9b9Cv9B\n\t2KUH1mJbfZWKoN+jBfsOSDpVlLW4AG4ogd/baEYrU1RYMJH7QLW3ykkbI0WC+KKkVT\n\tPG2LmmBnj7rUjzo3Olbz/akw86cET6kioYuQKF4YHZE+x3g3RJJc1DJHxBatYgJ8yx\n\tAULcvgXbDRX0w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1697103294;\n\tbh=Z3Pq7/05fdJj7CRJAoQZL6GH275a7IibSw/3tfuLYZA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gcMuX1lvo4qxP8Uejy7wY4nK1njOAFKTfVQOxRFUi3xHumLv7/XFUaS7sICkD7FwP\n\tgQQUywXvYSn9TXxCHi4hJ9zVH2Amq9crBAzFWftQ4/WztI+x1ziyTUXZ1Ex7gk6jzs\n\t3mI9MHRsWYxFzMveLxx0jrPqmvusUsa+VvLZCkMk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gcMuX1lv\"; dkim-atps=neutral","Date":"Thu, 12 Oct 2023 11:34:53 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<23nmh3rhclpvuacqqigeal6iuzpm7jvqg7bqzlwtniobcraucu@hxlqdmmf4vzd>","References":"<20231006132000.23504-1-naush@raspberrypi.com>\n\t<20231006132000.23504-11-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231006132000.23504-11-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 10/20] ipa: rpi: Prepare AWB for PiSP\n\tsupport","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]