[{"id":25038,"web_url":"https://patchwork.libcamera.org/comment/25038/","msgid":"<166371595979.18961.4124055703674811444@Monstersaurus>","date":"2022-09-20T23:19:19","subject":"Re: [libcamera-devel] [PATCH v4 25/32] ipa: rkisp1: awb: Use frame\n\tcontext to fix gains calculations","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart via libcamera-devel (2022-09-08 02:41:53)\n> The AWB statistics are computed after the ISP applies the colour gains.\n> This means that the red, green and blue means do not match the data\n> coming directly from the sensor, but are multiplied by the colour gains\n> that were used for the frame on which the statistics have been computed.\n> The AWB algorithm needs to take this into account when calculating the\n> colour gains for the next frame. Do so by dividing the means by the\n> gains that were applied to the frame, retrieved from the frame context.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++++\n>  1 file changed, 9 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index bb0f6c27fc7d..b711e93b73ba 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -207,6 +207,15 @@ void Awb::process(IPAContext &context,\n>         double greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;\n>         double blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;\n>  \n> +       /*\n> +        * The ISP computes the AWB means after applying the colour gains,\n> +        * divide by the gains that were used to get the raw means from the\n> +        * sensor.\n> +        */\n> +       redMean /= frameContext.awb.gains.red;\n> +       greenMean /= frameContext.awb.gains.green;\n> +       blueMean /= frameContext.awb.gains.blue;\n> +\n\nSounds so easy now I see it in code.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>         frameContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n>  \n>         /* Estimate the red and blue gains to apply in a grey world. */\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 EDA50C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Sep 2022 23:19:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C258621D2;\n\tWed, 21 Sep 2022 01:19:24 +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 C564061F7D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Sep 2022 01:19:22 +0200 (CEST)","from pendragon.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 493E4415;\n\tWed, 21 Sep 2022 01:19:22 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1663715964;\n\tbh=iR5ciV7PrhnW99Y9CeMjj6hBlYx0bz8wScCyVb3kbuw=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Q37qE/I8QQ+tnOeLJP/Rr7PgwpdGKOuc8tFABWWIig+FclQtGfjUVP8uqCK3UDGgE\n\tNqr3Lc511bZWFg4iQHN2rOlMMENn6bpI9zQkTWflxId4UbbHyWwsBAHYZOYomTuZZt\n\tJIQ2y6A7u7VjIgiqGsZSJ8Z2dQrcX0+dFM2/P7BMthb1jMe6V/efBWq4bF7YuHJ201\n\tpH0PS9e+ExJH8oQRCdhZF/fSC03zI1+ar5BdAyyr6ZtNklrqK6jh0kgsMujO7fXTry\n\tMw5DRnixwb7BWfZodJ7/3K2AmNuCnE20drCdcX/v6X/9OLDK4Y7BlDm/gVO2IyCCeA\n\te4CB2ZnI/BlbQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1663715962;\n\tbh=iR5ciV7PrhnW99Y9CeMjj6hBlYx0bz8wScCyVb3kbuw=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=sYihUEsNL7M0nc+7OA0/wXK0fD5xXPnUa4wqc5a1d1GpSz5iSVUpcBFsYjK2886X0\n\ttLEAkpdTwdzdR5Wl3dcY1xaUiVTG0L/6oTzOZ3FxseaYiCdu8gCunBPjwG++7W44I1\n\t9H5kns+PRWBItoayR7llpfRDSNO7gE14OM5KDUp4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"sYihUEsN\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220908014200.28728-26-laurent.pinchart@ideasonboard.com>","References":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>\n\t<20220908014200.28728-26-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 21 Sep 2022 00:19:19 +0100","Message-ID":"<166371595979.18961.4124055703674811444@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 25/32] ipa: rkisp1: awb: Use frame\n\tcontext to fix gains calculations","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25075,"web_url":"https://patchwork.libcamera.org/comment/25075/","msgid":"<20220922102527.j4xrcag2syqxr2jf@uno.localdomain>","date":"2022-09-22T10:25:27","subject":"Re: [libcamera-devel] [PATCH v4 25/32] ipa: rkisp1: awb: Use frame\n\tcontext to fix gains calculations","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Thu, Sep 08, 2022 at 04:41:53AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> The AWB statistics are computed after the ISP applies the colour gains.\n> This means that the red, green and blue means do not match the data\n> coming directly from the sensor, but are multiplied by the colour gains\n> that were used for the frame on which the statistics have been computed.\n> The AWB algorithm needs to take this into account when calculating the\n> colour gains for the next frame. Do so by dividing the means by the\n> gains that were applied to the frame, retrieved from the frame context.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nGood catch!\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++++\n>  1 file changed, 9 insertions(+)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index bb0f6c27fc7d..b711e93b73ba 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -207,6 +207,15 @@ void Awb::process(IPAContext &context,\n>  \tdouble greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;\n>  \tdouble blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;\n>\n> +\t/*\n> +\t * The ISP computes the AWB means after applying the colour gains,\n> +\t * divide by the gains that were used to get the raw means from the\n> +\t * sensor.\n> +\t */\n> +\tredMean /= frameContext.awb.gains.red;\n> +\tgreenMean /= frameContext.awb.gains.green;\n> +\tblueMean /= frameContext.awb.gains.blue;\n> +\n>  \tframeContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n>\n>  \t/* Estimate the red and blue gains to apply in a grey world. */\n> --\n> Regards,\n>\n> Laurent Pinchart\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 38BC2C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Sep 2022 10:25:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D92962202;\n\tThu, 22 Sep 2022 12:25:31 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::223])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F37F6219A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Sep 2022 12:25:30 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 2C1CB6000F;\n\tThu, 22 Sep 2022 10:25:28 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1663842331;\n\tbh=f8AEeZsH3TCfqzd9yOIJc3XUqJtikRKHX1JJTjTqhi8=;\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=YM3ZC5JGSaWDNC0vWp0rPt3FTOo+UhbDCJ6UOyP5EmWLenvaJ9M+LiSaXmzWz0Ouh\n\t1rW0+oUhrpt3HmPZhvs7EoSAwtAXk3oI+cw/WjNihjUHp3dtOCiQk+0i7v+Uw6pC4A\n\tg4v6PHFmdkAd5fNT89ixIxZe53MLq+MUGvznOu5Ktuyh2kWaDG+RM2enYEmcYqmHzq\n\t6e+FPXyfyZMqjTQ3ga/dYZpPFk4SCim1l/r+zu3r5WiJqy8TXWoIXGP54knylx5YT6\n\t4fN3Nf0nKPOZvQDuN2UHZX1+iF1jf8mNrybwQs5ndindwBLycvw4VH9kOa8Cq19Ewd\n\tUFcVDhErR9ijw==","Date":"Thu, 22 Sep 2022 12:25:27 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220922102527.j4xrcag2syqxr2jf@uno.localdomain>","References":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>\n\t<20220908014200.28728-26-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220908014200.28728-26-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 25/32] ipa: rkisp1: awb: Use frame\n\tcontext to fix gains calculations","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@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]