From patchwork Tue Nov 16 15:24:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14615 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 00393BDB1C for ; Tue, 16 Nov 2021 15:25:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3192F6038A; Tue, 16 Nov 2021 16:25:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tXXArIXx"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8A8760120 for ; Tue, 16 Nov 2021 16:25:34 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:c966:1d53:a935:70a0]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76C30547; Tue, 16 Nov 2021 16:25:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1637076334; bh=lQrqCCxL7/it11RObVCPaA3ixkWPL/uFWzvHO6vk+iM=; h=From:To:Cc:Subject:Date:From; b=tXXArIXxAICyk2V2Xaq7tiS711GOivBFSvei3xpobxQ0oYFCVQ4iNiUfthZGLHNly IHurw8qwQAuYPG3qm3SuCLZ84tY3klyvZ6RKIWdy2hG0KhajGd4+Zy3F+7dxgVI59X X7Nd9Vv38Id6S7OtDB74uqJnNQeRfSm21ZG4iZD4= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Nov 2021 16:24:44 +0100 Message-Id: <20211116152443.56512-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] ipa: ipu3: agc: Remove the threshold for the histogram calculation 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" Until commit f8f07f9468c6 (ipa: ipu3: agc: Improve gain calculation) the gain to apply on the exposure value was only using the histogram. Now that the global brightness of the frame is estimated too, we don't need to remove part of the saturated pixels from the equation anymore. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham --- v2: - remove the empty histogram test - don't take Kieran's R-B tag as it needs testing again --- src/ipa/ipu3/algorithms/agc.cpp | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 4e424857..bd02c474 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -58,12 +58,6 @@ static constexpr uint32_t knumHistogramBins = 256; /* Target value to reach for the top 2% of the histogram */ static constexpr double kEvGainTarget = 0.5; -/* - * Maximum ratio of saturated pixels in a cell for the cell to be considered - * non-saturated and counted by the AGC algorithm. - */ -static constexpr uint32_t kMinCellsPerZoneRatio = 255 * 20 / 100; - /* Number of frames to wait before calculating stats on minimum exposure */ static constexpr uint32_t kNumStartupFrames = 10; @@ -133,27 +127,19 @@ void Agc::measureBrightness(const ipu3_uapi_stats_3a *stats, &stats->awb_raw_buffer.meta_data[cellPosition] ); - if (cell->sat_ratio <= kMinCellsPerZoneRatio) { - uint8_t gr = cell->Gr_avg; - uint8_t gb = cell->Gb_avg; - /* - * Store the average green value to estimate the - * brightness. Even the overexposed pixels are - * taken into account. - */ - hist[(gr + gb) / 2]++; - } + uint8_t gr = cell->Gr_avg; + uint8_t gb = cell->Gb_avg; + /* + * Store the average green value to estimate the + * brightness. Even the overexposed pixels are + * taken into account. + */ + hist[(gr + gb) / 2]++; } } - Histogram cumulativeHist = Histogram(Span(hist)); /* Estimate the quantile mean of the top 2% of the histogram */ - if (cumulativeHist.total() == 0) { - /* Force the value as histogram is empty */ - iqMean_ = knumHistogramBins - 0.5; - } else { - iqMean_ = cumulativeHist.interQuantileMean(0.98, 1.0); - } + iqMean_ = Histogram(Span(hist)).interQuantileMean(0.98, 1.0); } /**