[{"id":31800,"web_url":"https://patchwork.libcamera.org/comment/31800/","msgid":"<172926410292.532453.11815464444858172054@ping.linuxembedded.co.uk>","date":"2024-10-18T15:08:22","subject":"Re: [PATCH v2 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-18 15:58:36)\n> Sometimes the ISP produces statistics only with a subset of statistic\n> types being valid. It doesn't happen normally, but was observed in the\n> wild. Check for the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid\n> or outdated data. As it doesn't happen regularly add an error message to\n> get notified when it happens.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v2:\n> - Added error message\n> - Made condition more readable\n> - Collected tags\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 10 +++++++---\n>  1 file changed, 7 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 955a9ff4a897..b3c00bef9b7e 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -215,6 +215,12 @@ 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> +               LOG(RkISP1Awb, Error) << \"AWB data is missing in statistics\";\n\nSame here ?\n\nIf we want to treat one as valid and one as erroneous - we might need to\nbreak it into two conditionals, with\n\n\tif (!stats)\n\t\treturn;\n\n\tif (!(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB)) {\n\t\tLOG(RkISP1Awb, Error) << \"AWB data is missing in statistics\";\n\t\treturn;\n\t}\n\nAs one path is an acceptable silent path, but the other is a condition\nwe want to know about.\n\n> +               return;\n> +       }\n>  \n>         if (rgbMode_) {\n>                 greenMean = awb->awb_mean[0].mean_y_or_g;\n> @@ -270,10 +276,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 790B8C32FE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Oct 2024 15:08:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F2166538B;\n\tFri, 18 Oct 2024 17:08:27 +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 11092633C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Oct 2024 17:08:26 +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 165F021C;\n\tFri, 18 Oct 2024 17:06:42 +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=\"GRrBGeZa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729264002;\n\tbh=iHtZDINrBmyYLGMuP77zr+c0pR6Y9wXmmItEF2yQlYg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=GRrBGeZaG+x6mXd54TvBiUON2LBkGIpXyL2lfDtn4acf3xOi0D+Yrdu1IuSyjYYxB\n\t5xZNoO+GzfgNA1WYjTQF89DmKK74tq8Wu/CPAQZ4O5JGU56+vP1x4Ujvjq3k3f8QG7\n\tlaQ9SjEhyKlxntJePXgnk4JwmmmWgHyrbRv+dm7E=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241018145856.914816-3-stefan.klug@ideasonboard.com>","References":"<20241018145856.914816-1-stefan.klug@ideasonboard.com>\n\t<20241018145856.914816-3-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 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>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 18 Oct 2024 16:08:22 +0100","Message-ID":"<172926410292.532453.11815464444858172054@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":31802,"web_url":"https://patchwork.libcamera.org/comment/31802/","msgid":"<4rihj2buuzn62gqu47x4izwwpfmrhz3mqolbrewnn4mi4xtrbo@5cvjb7renwcc>","date":"2024-10-18T15:28:12","subject":"Re: [PATCH v2 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"On Fri, Oct 18, 2024 at 04:08:22PM +0100, Kieran Bingham wrote:\n> Quoting Stefan Klug (2024-10-18 15:58:36)\n> > Sometimes the ISP produces statistics only with a subset of statistic\n> > types being valid. It doesn't happen normally, but was observed in the\n> > wild. Check for the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid\n> > or outdated data. As it doesn't happen regularly add an error message to\n> > get notified when it happens.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > ---\n> > Changes in v2:\n> > - Added error message\n> > - Made condition more readable\n> > - Collected tags\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 10 +++++++---\n> >  1 file changed, 7 insertions(+), 3 deletions(-)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index 955a9ff4a897..b3c00bef9b7e 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -215,6 +215,12 @@ 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> > +               LOG(RkISP1Awb, Error) << \"AWB data is missing in statistics\";\n> \n> Same here ?\n\nNo, because the awb algorithm has supportsRaw_=false. So I would keep\nthat as is.\n\n> \n> If we want to treat one as valid and one as erroneous - we might need to\n> break it into two conditionals, with\n> \n> \tif (!stats)\n> \t\treturn;\n> \n> \tif (!(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB)) {\n> \t\tLOG(RkISP1Awb, Error) << \"AWB data is missing in statistics\";\n> \t\treturn;\n> \t}\n> \n> As one path is an acceptable silent path, but the other is a condition\n> we want to know about.\n\nYes, that will go in v3 (for agc).\n\nThanks.\n\nStefan\n\n> \n> > +               return;\n> > +       }\n> >  \n> >         if (rgbMode_) {\n> >                 greenMean = awb->awb_mean[0].mean_y_or_g;\n> > @@ -270,10 +276,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 4110AC32AF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Oct 2024 15:28:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CCA2C6538C;\n\tFri, 18 Oct 2024 17:28:17 +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 DDD7F633C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Oct 2024 17:28:15 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:77a0:ddb9:22bf:b8d9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 23BE021C;\n\tFri, 18 Oct 2024 17:26:32 +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=\"FKfuaxw4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729265192;\n\tbh=JQBW8WAtquUHagIxSBxJfp1rB81shZ4+MvUNxqJaN6s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FKfuaxw4QHXB2+rG4bCYzRxQqjYgk4RTe7/7dt4VLnDsFu6EeJzEfrUYSrGx6yb2A\n\t2TJgpC4wpgnop688JI9tQqMu5f8cIWCusjFNmEqyi0g/oe2sEBhNGG0UdRBuAk5W3w\n\tyFBmIXtXt5LaJ32g/7dXJy/f2GFofsaEpWnQW5xI=","Date":"Fri, 18 Oct 2024 17:28:12 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v2 2/4] ipa: rkisp1: algorithms: awb: Check for correct\n\tstats type","Message-ID":"<4rihj2buuzn62gqu47x4izwwpfmrhz3mqolbrewnn4mi4xtrbo@5cvjb7renwcc>","References":"<20241018145856.914816-1-stefan.klug@ideasonboard.com>\n\t<20241018145856.914816-3-stefan.klug@ideasonboard.com>\n\t<172926410292.532453.11815464444858172054@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<172926410292.532453.11815464444858172054@ping.linuxembedded.co.uk>","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>"}}]