[{"id":34152,"web_url":"https://patchwork.libcamera.org/comment/34152/","msgid":"<aBuYnk2eV48mw-lQ@pyrite.rasen.tech>","date":"2025-05-07T17:30:06","subject":"Re: [PATCH v3 14/16] ipa: rkisp1: Damp color temperature regulation","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Thu, Apr 03, 2025 at 05:49:19PM +0200, Stefan Klug wrote:\n> Damp the regulation of the color temperature with the same factor as the\n> gains.  Not damping the color temperature leads to visible flicker, as\n> the CCM changes too much.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v2:\n> - Collected tags\n> \n> Changes in v3:\n> - Dropped incorrect call to estimateCCT()\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 5 +++--\n>  src/ipa/rkisp1/algorithms/ccm.cpp | 4 ----\n>  2 files changed, 3 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index f5415a0bb99d..47b29725af51 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -317,8 +317,6 @@ void Awb::process(IPAContext &context,\n>  \tRkISP1AwbStats awbStats{ rgbMeans };\n>  \tAwbResult awbResult = awbAlgo_->calculateAwb(awbStats, frameContext.lux.lux);\n>  \n> -\tactiveState.awb.automatic.temperatureK = awbResult.colourTemperature;\n> -\n>  \t/*\n>  \t * Clamp the gain values to the hardware, which expresses gains as Q2.8\n>  \t * unsigned integer values. Set the minimum just above zero to avoid\n> @@ -329,9 +327,12 @@ void Awb::process(IPAContext &context,\n>  \n>  \t/* Filter the values to avoid oscillations. */\n>  \tdouble speed = 0.2;\n> +\tdouble ct = awbResult.colourTemperature;\n> +\tct = ct * speed + activeState.awb.automatic.temperatureK * (1 - speed);\n>  \tawbResult.gains = awbResult.gains * speed +\n>  \t\t\t  activeState.awb.automatic.gains * (1 - speed);\n>  \n> +\tactiveState.awb.automatic.temperatureK = static_cast<unsigned int>(ct);\n>  \tactiveState.awb.automatic.gains = awbResult.gains;\n>  \n>  \tLOG(RkISP1Awb, Debug)\n> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> index 3a96a5427bc6..de2b6fe775aa 100644\n> --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> @@ -142,10 +142,6 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>  \t}\n>  \n>  \tuint32_t ct = frameContext.awb.temperatureK;\n> -\t/*\n> -\t * \\todo The colour temperature will likely be noisy, add filtering to\n> -\t * avoid updating the CCM matrix all the time.\n> -\t */\n>  \tif (frame > 0 && ct == ct_) {\n>  \t\tframeContext.ccm.ccm = context.activeState.ccm.automatic;\n>  \t\treturn;\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 F3233C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 May 2025 17:30:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9980A68B32;\n\tWed,  7 May 2025 19:30:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F3C468B2F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 May 2025 19:30:10 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2001:861:3a80:3300:4f2f:8c2c:b3ef:17d4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BD5FCE92;\n\tWed,  7 May 2025 19:29:58 +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=\"RjAuEwq/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1746638998;\n\tbh=2xI5SkfF8FbTIfqhS41rpp3L5EU1KqAfj8Gq4SbC8GA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RjAuEwq/nMqnKMkh+0H6Whd+4jZ6OUo0B5dDbrCl+9tNyD9MUlDQ4BX7+GaehqVOJ\n\tbtqvAJfAXJmbWCcIyAQPi0C3u58MRGsec5nmMxlMYw2uBjLUT8zXIeessin59A6e7Y\n\tcYRHzmiOsaC1WZNO2SC0G15ASyF13Ol4UljegSYA=","Date":"Wed, 7 May 2025 19:30:06 +0200","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v3 14/16] ipa: rkisp1: Damp color temperature regulation","Message-ID":"<aBuYnk2eV48mw-lQ@pyrite.rasen.tech>","References":"<20250403154925.382973-1-stefan.klug@ideasonboard.com>\n\t<20250403154925.382973-15-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20250403154925.382973-15-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>"}}]