From patchwork Fri Apr 5 14:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 19853 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9BE92C32CA for ; Fri, 5 Apr 2024 14:47:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA34263340; Fri, 5 Apr 2024 16:47:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="o4ueVyPc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A816761C2F for ; Fri, 5 Apr 2024 16:47:50 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp [175.177.49.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC44BC8A; Fri, 5 Apr 2024 16:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712328432; bh=pTkClS0JmEycEN34D5sgrJilJ2D7GpzSxDz1Nu0sgIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4ueVyPcQVxGipSfsfCE7zHnpf2Fr0YxitqfpJ5MAZ43GkYaYMXXEDQQfWt2pDToU TAxa69JOBHQB5O/+Or5cH6UugjwOLOy4HMcfxlPF0xzCJaJ5IYYVjBP5auCDTVIm1S xu65AWJ2ImNfjJrtWAthV/nsWHdRpLrgkVFCrdBg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Remove some constants that should have been removed, and restore a fairly informative comment that got removed. Although the removal of one of the constants also removes a todo comment, this will be addressed imminently so it should be fine. Signed-off-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 32 +++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 7220f00a..1dfc4aaa 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -39,12 +39,6 @@ namespace ipa::rkisp1::algorithms { LOG_DEFINE_CATEGORY(RkISP1Agc) -/* Minimum limit for analogue gain value */ -static constexpr double kMinAnalogueGain = 1.0; - -/* \todo Honour the FrameDurationLimits control instead of hardcoding a limit */ -static constexpr utils::Duration kMaxShutterSpeed = 60ms; - int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData, const char *prop) { @@ -315,6 +309,32 @@ void Agc::parseStatistics(const rkisp1_stat_buffer *stats, context.hw->numHistogramBins), 4); } +/** + * \brief Estimate the relative luminance of the frame with a given gain + * \param[in] expMeans The mean luminance values, from the RkISP1 statistics + * \param[in] gain The gain to apply to the frame + * + * This function estimates the average relative luminance of the frame that + * would be output by the sensor if an additional \a gain was applied. + * + * The estimation is based on the AE statistics for the current frame. Y + * averages for all cells are first multiplied by the gain, and then saturated + * to approximate the sensor behaviour at high brightness values. The + * approximation is quite rough, as it doesn't take into account non-linearities + * when approaching saturation. In this case, saturating after the conversion to + * YUV doesn't take into account the fact that the R, G and B components + * contribute differently to the relative luminance. + * + * \todo Have a dedicated YUV algorithm ? + * + * The values are normalized to the [0.0, 1.0] range, where 1.0 corresponds to a + * theoretical perfect reflector of 100% reference white. + * + * More detailed information can be found in: + * https://en.wikipedia.org/wiki/Relative_luminance + * + * \return The relative luminance + */ double Agc::estimateLuminance(double gain) { double ySum = 0.0;