{"id":19853,"url":"https://patchwork.libcamera.org/api/patches/19853/?format=json","web_url":"https://patchwork.libcamera.org/patch/19853/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240405144729.2992219-4-paul.elder@ideasonboard.com>","date":"2024-04-05T14:47:27","name":"[3/5] fixup: ipa: rkisp1: Remove bespoke Agc functions","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"878bb587e2c76db255ae8a1bf7b49ca256340035","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19853/mbox/","series":[{"id":4251,"url":"https://patchwork.libcamera.org/api/series/4251/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4251","date":"2024-04-05T14:47:24","name":"ipa: rkisp1: Improve AGC (plumbing)","version":1,"mbox":"https://patchwork.libcamera.org/series/4251/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19853/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19853/checks/","tags":{},"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 9BE92C32CA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  5 Apr 2024 14:47:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA34263340;\n\tFri,  5 Apr 2024 16:47:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A816761C2F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Apr 2024 16:47:50 +0200 (CEST)","from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CC44BC8A;\n\tFri,  5 Apr 2024 16:47:10 +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=\"o4ueVyPc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1712328432;\n\tbh=pTkClS0JmEycEN34D5sgrJilJ2D7GpzSxDz1Nu0sgIA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=o4ueVyPcQVxGipSfsfCE7zHnpf2Fr0YxitqfpJ5MAZ43GkYaYMXXEDQQfWt2pDToU\n\tTAxa69JOBHQB5O/+Or5cH6UugjwOLOy4HMcfxlPF0xzCJaJ5IYYVjBP5auCDTVIm1S\n\txu65AWJ2ImNfjJrtWAthV/nsWHdRpLrgkVFCrdBg=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Paul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH 3/5] fixup: ipa: rkisp1: Remove bespoke Agc functions","Date":"Fri,  5 Apr 2024 23:47:27 +0900","Message-Id":"<20240405144729.2992219-4-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.39.2","In-Reply-To":"<20240405144729.2992219-1-paul.elder@ideasonboard.com>","References":"<20240405144729.2992219-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Remove some constants that should have been removed, and restore a\nfairly informative comment that got removed.\n\nAlthough the removal of one of the constants also removes a todo\ncomment, this will be addressed imminently so it should be fine.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 32 +++++++++++++++++++++++++------\n 1 file changed, 26 insertions(+), 6 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 7220f00a..1dfc4aaa 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -39,12 +39,6 @@ namespace ipa::rkisp1::algorithms {\n \n LOG_DEFINE_CATEGORY(RkISP1Agc)\n \n-/* Minimum limit for analogue gain value */\n-static constexpr double kMinAnalogueGain = 1.0;\n-\n-/* \\todo Honour the FrameDurationLimits control instead of hardcoding a limit */\n-static constexpr utils::Duration kMaxShutterSpeed = 60ms;\n-\n int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData,\n \t\t\t    const char *prop)\n {\n@@ -315,6 +309,32 @@ void Agc::parseStatistics(const rkisp1_stat_buffer *stats,\n \t\t\t\t\t       context.hw->numHistogramBins), 4);\n }\n \n+/**\n+ * \\brief Estimate the relative luminance of the frame with a given gain\n+ * \\param[in] expMeans The mean luminance values, from the RkISP1 statistics\n+ * \\param[in] gain The gain to apply to the frame\n+ *\n+ * This function estimates the average relative luminance of the frame that\n+ * would be output by the sensor if an additional \\a gain was applied.\n+ *\n+ * The estimation is based on the AE statistics for the current frame. Y\n+ * averages for all cells are first multiplied by the gain, and then saturated\n+ * to approximate the sensor behaviour at high brightness values. The\n+ * approximation is quite rough, as it doesn't take into account non-linearities\n+ * when approaching saturation. In this case, saturating after the conversion to\n+ * YUV doesn't take into account the fact that the R, G and B components\n+ * contribute differently to the relative luminance.\n+ *\n+ * \\todo Have a dedicated YUV algorithm ?\n+ *\n+ * The values are normalized to the [0.0, 1.0] range, where 1.0 corresponds to a\n+ * theoretical perfect reflector of 100% reference white.\n+ *\n+ * More detailed information can be found in:\n+ * https://en.wikipedia.org/wiki/Relative_luminance\n+ *\n+ * \\return The relative luminance\n+ */\n double Agc::estimateLuminance(double gain)\n {\n \tdouble ySum = 0.0;\n","prefixes":["3/5"]}