[{"id":35323,"web_url":"https://patchwork.libcamera.org/comment/35323/","msgid":"<175476132530.2727593.10983565746107195934@ping.linuxembedded.co.uk>","date":"2025-08-09T17:42:05","subject":"Re: [PATCH v2 13/16] ipa: rkisp1: Switch histogram to RGB combined\n\tmode","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-08-08 15:12:51)\n> The Y mode of the histogram gets captured at the ISP output, before the\n> output formatter.  This has the side effect that the first and the last\n> bins are empty in case of limited YUV range.  Another side effect is\n> that gamma and GWDR processing is included in the histogram which makes\n\nThis patch doesn't modify  anything in regards to gamma adaptations.\nDoes that mean we currently mis-handle gamma in the statistics? or that\nthis patch 'fixes' the handling?\n\n> algorithm development very difficult. In RGB mode the histogram is taken\n> after xtalk (CCM) and is therefore independent of gamma and WDR. The\n> limited range issue also does not apply. In the ISP reference it is\n\nSo it sounds like this is a good fix all round ...\n\n> however stated that \"it is not possible to calculate a luminance or\n> grayscale histogram from an RGB histogram since the position information\n> is lost during its generation\".\n> \n> During testing the RGB histogram provided good data and better\n> algorithmic stability at a possible (but not measured) inaccuracy.\n> \n> Another option would be to pass the color space information into the IPA\n> and strip the histogram accordingly. For ease of implementation switch to\n> the RGB mode.\n\nI feel like some of this needs to be captured in a comment in the code\nfor future reference. Perhaps even just taking a summary of the above\nissues in a block comment above the mode setting?\n\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index d34c041f9fe1..8227d60213c2 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -396,7 +396,7 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n>         hstConfig.setEnabled(true);\n>  \n>         hstConfig->meas_window = context.configuration.agc.measureWindow;\n> -       hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;\n> +       hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED;\n>  \n>         Span<uint8_t> weights{\n>                 hstConfig->hist_weight,\n> -- \n> 2.48.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 6D59DBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  9 Aug 2025 17:42:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 92A476921B;\n\tSat,  9 Aug 2025 19:42:10 +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 AD2136921A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  9 Aug 2025 19:42:08 +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 B9224C6E;\n\tSat,  9 Aug 2025 19:41:17 +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=\"QF+9algq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754761277;\n\tbh=gda3VaT/X5SrrG6vnlu2jJ3SYXug3HM5up04MO0H7Fg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QF+9algqPsNPuC7fvGA/DtLIqekiVVBDBtpZPhjdew2tyS3+duIxD51s4jYJoZq6W\n\tCpyBYfjCjXy6MGKKz+A43KvkOBMyztpyrQDV0U0IxhAkhCwBmyFwC1R5z9cWgpf++N\n\tDHV41Q74CWO8E46ImpeiB3LYZiZK6WCuOUO/AY+0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250808141315.413839-14-stefan.klug@ideasonboard.com>","References":"<20250808141315.413839-1-stefan.klug@ideasonboard.com>\n\t<20250808141315.413839-14-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 13/16] ipa: rkisp1: Switch histogram to RGB combined\n\tmode","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sat, 09 Aug 2025 18:42:05 +0100","Message-ID":"<175476132530.2727593.10983565746107195934@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]