[{"id":31764,"web_url":"https://patchwork.libcamera.org/comment/31764/","msgid":"<172908826923.877857.2128172487421711723@ping.linuxembedded.co.uk>","date":"2024-10-16T14:17:49","subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-10-15 21:38:13)\n> Sometimes the ISP produces statistics only with a subset of statistic\n> types being valid. It doesn't happen often, but it happens.  Check for\n> the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid or outdated\n> data.\n> \n> For simpler code structure, the ColourTemperature metadata entry gets\n> written unconditionally and overwritten later if needed.\n> \n\nThis makes me wonder if we need to better handle how metadata is filled\nby algorithms too ... but I don't object to this as it stands anyway.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 955a9ff4a897..86bcf20f6527 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -215,6 +215,10 @@ void Awb::process(IPAContext &context,\n>                         static_cast<float>(frameContext.awb.gains.red),\n>                         static_cast<float>(frameContext.awb.gains.blue)\n>                 });\n> +       metadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> +\n> +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AWB))\n> +               return;\n>  \n>         if (rgbMode_) {\n>                 greenMean = awb->awb_mean[0].mean_y_or_g;\n> @@ -270,10 +274,8 @@ void Awb::process(IPAContext &context,\n>          * meaningfully calculate gains. Freeze the algorithm in that case.\n>          */\n>         if (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold &&\n> -           blueMean < kMeanMinThreshold) {\n> -               metadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> +           blueMean < kMeanMinThreshold)\n>                 return;\n> -       }\n>  \n>         activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n>  \n> -- \n> 2.43.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 D5A7AC326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 14:17:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1D2265383;\n\tWed, 16 Oct 2024 16:17:53 +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 120AE6537E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 16:17:52 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 84D08A2F;\n\tWed, 16 Oct 2024 16:16:09 +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=\"JP54AnFV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729088169;\n\tbh=ZXB5Cg6P5FXrHPSMWM9KL+b8XiZkLCnZsNO+yzFRurs=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=JP54AnFVlaLMk/c1gqZD7qPh1Dc0nfxYmccG1MJ8CPwy2uWwjz4xEhQnzaqYUA+PF\n\th/ZGyIMT816ad9wlpc8faFIgOhDgp+/ylh3s81wkTjUvEHWmnQiCxTRoltOni00O6Y\n\t+9fgNt2YgoDLfm8um3eKmpVBBvhxkNRVBWQrfuW0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241015203820.574326-3-stefan.klug@ideasonboard.com>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-3-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 16 Oct 2024 15:17:49 +0100","Message-ID":"<172908826923.877857.2128172487421711723@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":31770,"web_url":"https://patchwork.libcamera.org/comment/31770/","msgid":"<20241016144419.GD30496@pendragon.ideasonboard.com>","date":"2024-10-16T14:44:19","subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Tue, Oct 15, 2024 at 10:38:13PM +0200, Stefan Klug wrote:\n> Sometimes the ISP produces statistics only with a subset of statistic\n> types being valid. It doesn't happen often, but it happens.  Check for\n> the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid or outdated\n> data.\n> \n> For simpler code structure, the ColourTemperature metadata entry gets\n> written unconditionally and overwritten later if needed.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 955a9ff4a897..86bcf20f6527 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -215,6 +215,10 @@ void Awb::process(IPAContext &context,\n>  \t\t\tstatic_cast<float>(frameContext.awb.gains.red),\n>  \t\t\tstatic_cast<float>(frameContext.awb.gains.blue)\n>  \t\t});\n> +\tmetadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> +\n> +\tif (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AWB))\n\nAs in 1/4, I think\n\n\tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB))\n\nis more readable.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\treturn;\n>  \n>  \tif (rgbMode_) {\n>  \t\tgreenMean = awb->awb_mean[0].mean_y_or_g;\n> @@ -270,10 +274,8 @@ void Awb::process(IPAContext &context,\n>  \t * meaningfully calculate gains. Freeze the algorithm in that case.\n>  \t */\n>  \tif (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold &&\n> -\t    blueMean < kMeanMinThreshold) {\n> -\t\tmetadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> +\t    blueMean < kMeanMinThreshold)\n>  \t\treturn;\n> -\t}\n>  \n>  \tactiveState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\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 CE35AC32FA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 14:44:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 66CA865385;\n\tWed, 16 Oct 2024 16:44:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C271F6537F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 16:44:23 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A1F9A2F;\n\tWed, 16 Oct 2024 16:42: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=\"N6CfC6gV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729089761;\n\tbh=41nhxNvYxd9ahFjMc6D2TwQ5O+j91AxP6HJvUH8UCZ0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=N6CfC6gVB1E0xHQz/paYaVmkoESNRGaocjI0hFJTP9uAeedHOYm+nQYJEWpxwNe7y\n\tCIQahM5QEGNpBylHdgruZgC7MlXL73lxYiNkiH5h3EvDGmcXTbh6G5nShrfARGsqKr\n\tWZ1PsZ3mCUXtEgctvIDN/UPHmaMcPBhbtazQyQks=","Date":"Wed, 16 Oct 2024 17:44:19 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","Message-ID":"<20241016144419.GD30496@pendragon.ideasonboard.com>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241015203820.574326-3-stefan.klug@ideasonboard.com>","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>"}},{"id":31778,"web_url":"https://patchwork.libcamera.org/comment/31778/","msgid":"<ZxBo44QnD-eaAQoT@pyrite.rasen.tech>","date":"2024-10-17T01:31:15","subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Wed, Oct 16, 2024 at 05:44:19PM +0300, Laurent Pinchart wrote:\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Tue, Oct 15, 2024 at 10:38:13PM +0200, Stefan Klug wrote:\n> > Sometimes the ISP produces statistics only with a subset of statistic\n> > types being valid. It doesn't happen often, but it happens.  Check for\n> > the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid or outdated\n> > data.\n> > \n> > For simpler code structure, the ColourTemperature metadata entry gets\n> > written unconditionally and overwritten later if needed.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++---\n> >  1 file changed, 5 insertions(+), 3 deletions(-)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index 955a9ff4a897..86bcf20f6527 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -215,6 +215,10 @@ void Awb::process(IPAContext &context,\n> >  \t\t\tstatic_cast<float>(frameContext.awb.gains.red),\n> >  \t\t\tstatic_cast<float>(frameContext.awb.gains.blue)\n> >  \t\t});\n> > +\tmetadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> > +\n> > +\tif (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AWB))\n> \n> As in 1/4, I think\n> \n> \tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB))\n\n+1\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> is more readable.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\t\treturn;\n> >  \n> >  \tif (rgbMode_) {\n> >  \t\tgreenMean = awb->awb_mean[0].mean_y_or_g;\n> > @@ -270,10 +274,8 @@ void Awb::process(IPAContext &context,\n> >  \t * meaningfully calculate gains. Freeze the algorithm in that case.\n> >  \t */\n> >  \tif (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold &&\n> > -\t    blueMean < kMeanMinThreshold) {\n> > -\t\tmetadata.set(controls::ColourTemperature, activeState.awb.temperatureK);\n> > +\t    blueMean < kMeanMinThreshold)\n> >  \t\treturn;\n> > -\t}\n> >  \n> >  \tactiveState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n> >  \n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 6A464C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Oct 2024 01:31:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3795365385;\n\tThu, 17 Oct 2024 03:31:25 +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 A51B1633C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Oct 2024 03:31:23 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:da41:46b1:7eef:1e0d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B3DAA968;\n\tThu, 17 Oct 2024 03:29:39 +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=\"oWyFBYDX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729128580;\n\tbh=98VukYXlfw8bTx27mH91HDaBYSHzQa9IrVwdphFAzm4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=oWyFBYDXllbuFhcDBySMSCArDKyH5emhPQeUVvxqWnswQODCjzIYw8yiIDg2zpf7Z\n\tlIEkaR03KuO5B5PoRTelke/iCSRDnj77KtvnyGeKa0OQpHqeUVQN2pC1SMJSxYZXi1\n\tUG9Oa8mWPa4SYGUBQlCSNY8p/Xo2Cd674QCN+PRo=","Date":"Thu, 17 Oct 2024 10:31:15 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","Message-ID":"<ZxBo44QnD-eaAQoT@pyrite.rasen.tech>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-3-stefan.klug@ideasonboard.com>\n\t<20241016144419.GD30496@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20241016144419.GD30496@pendragon.ideasonboard.com>","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>"}}]