[{"id":27950,"web_url":"https://patchwork.libcamera.org/comment/27950/","msgid":"<tib5wyyueupfic4v3te5hgqwbfxn4sbavj6rhvsikqgsjkzfr4@sgnsn7h765ss>","date":"2023-10-12T08:54:39","subject":"Re: [libcamera-devel] [PATCH 09/20] ipa: rpi: Prepare ALSC 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:49PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Prepare the ALSC algorithm to support the PiSP hardware. The key change\n> is to avoid factoring out the WB correction in the AWB zone statistics.\n>\n> Add the ALSC correction to the global metadata so that AWB can use it to\n> factor the gains back in for the AWB calculations.\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/alsc.cpp | 16 ++++++++++++----\n>  1 file changed, 12 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp\n> index 3a2e8fe00ca6..f1ccef87c70c 100644\n> --- a/src/ipa/rpi/controller/rpi/alsc.cpp\n> +++ b/src/ipa/rpi/controller/rpi/alsc.cpp\n> @@ -348,9 +348,11 @@ static void copyStats(RgbyRegions &regions, StatisticsPtr &stats,\n>  \tconst std::vector<double> &bTable = status.b;\n>  \tfor (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {\n>  \t\tauto r = stats->awbRegions.get(i);\n> -\t\tr.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);\n> -\t\tr.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);\n> -\t\tr.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);\n> +\t\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc) {\n> +\t\t\tr.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);\n> +\t\t\tr.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);\n> +\t\t\tr.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);\n> +\t\t}\n>  \t\tregions.set(i, r);\n>  \t}\n>  }\n> @@ -368,7 +370,8 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata)\n>  \t * the LSC table that the pipeline applied to them.\n>  \t */\n>  \tAlscStatus alscStatus;\n> -\tif (imageMetadata->get(\"alsc.status\", alscStatus) != 0) {\n> +\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc &&\n> +\t    imageMetadata->get(\"alsc.status\", alscStatus) != 0) {\n>  \t\tLOG(RPiAlsc, Warning)\n>  \t\t\t<< \"No ALSC status found for applied gains!\";\n>  \t\talscStatus.r.resize(config_.tableSize.width * config_.tableSize.height, 1.0);\n> @@ -414,6 +417,11 @@ void Alsc::prepare(Metadata *imageMetadata)\n>  \tstatus.g = prevSyncResults_[1].data();\n>  \tstatus.b = prevSyncResults_[2].data();\n>  \timageMetadata->set(\"alsc.status\", status);\n> +\t/*\n> +\t * Put the results in the global metadata as well. This will be used by\n> +\t * AWB to factor in the colour shading correction.\n> +\t */\n> +\tgetGlobalMetadata().set(\"alsc.status\", status);\n>  }\n>\n>  void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata)\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 66E3BBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Oct 2023 08:54:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AB70762980;\n\tThu, 12 Oct 2023 10:54:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 19F8162962\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Oct 2023 10:54:43 +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 DCC527FC;\n\tThu, 12 Oct 2023 10:54:39 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697100884;\n\tbh=kJoYmduKJLT8i6ewSbqsZlGHp5dzOstSnt7PqSPgiQ8=;\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=Wdo5rRxalxkAQ3fxxptCJKnemXG3OKw1wAPYU1jLh0ssFRBKp9q9/p6xo40+00mV+\n\tuhyGKNvEB6fSHbEv4kQD1t5a7MHmRRfutiPKw1kpJ4YmRX23kPehlCFWqWLDLCEI9i\n\twH1wqN8RP93eqCD1VDZIiHAOtwxlB7zZB2dxtWL0FopiJ6ZxqU6k6ZomGNPNZpRxDu\n\tExmzcl8Xi4cKsKPzfXmjrR6qfMFwBCb295VSxkfTg2CRk3F57vLKvZPf1FYx1xJGKu\n\tavSkxv1PZw2ikVKD1F+5gUpe/jpuiDgs5lw6jQs7h7U0epilXeH892TM+hT82Hh90Y\n\tW/r4ZVp4GAK5w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1697100880;\n\tbh=kJoYmduKJLT8i6ewSbqsZlGHp5dzOstSnt7PqSPgiQ8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Do3wGp7jofIPZIiyvoC1/mgdUMgyHotJTQGmFRTupVnjWDgxHvT3TX6JTwLIKHRRK\n\tAuduVrsiec9h3JE6aH9hwAYlAaXiFn1/veBhemZTKvsdTy8yvz1cSFRByKqXQ28GdQ\n\tNUKIvBpkpoXJBp9de5qWs6RmA6IxTHkfSl9ixZek="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Do3wGp7j\"; dkim-atps=neutral","Date":"Thu, 12 Oct 2023 10:54:39 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<tib5wyyueupfic4v3te5hgqwbfxn4sbavj6rhvsikqgsjkzfr4@sgnsn7h765ss>","References":"<20231006132000.23504-1-naush@raspberrypi.com>\n\t<20231006132000.23504-10-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231006132000.23504-10-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 09/20] ipa: rpi: Prepare ALSC 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>"}}]