From patchwork Fri Mar 22 13:14:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 19794 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 AF684C32C5 for ; Fri, 22 Mar 2024 13:15:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF3FF63362; Fri, 22 Mar 2024 14:15:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WcjB1xek"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B16286307E for ; Fri, 22 Mar 2024 14:15:10 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C5FE18CC; Fri, 22 Mar 2024 14:14:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1711113282; bh=hHcYPOoPDFIRKQJ+tlevepPv4PcfaBaUHMkH9zmq1+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WcjB1xekyu/8sv/+W7ZoKz9DQQmFXOBdO2KHzyhZ1ubFntn2Pgp4IBjc7WTXF/M6e Bk2waAo1hVt2WXm+0l/V8nbDdPxGnWRVTjCAvqLH3wS7yyxiglK61/AkYdkPtoT5EP 3pfetoF76sesBg2P6JzSav2gvnIux/vLsnar8l2A= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally Subject: [PATCH 08/10] ipa: rkisp1: Add parseStatistics() to Agc Date: Fri, 22 Mar 2024 13:14:49 +0000 Message-Id: <20240322131451.3092931-9-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240322131451.3092931-1-dan.scally@ideasonboard.com> References: <20240322131451.3092931-1-dan.scally@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" In preparation for switching the RkISP1 Agc to a derivation of MeanLuminanceAgc, add a function that parses the statistics and stores the values for easy retrieval later. Signed-off-by: Daniel Scally --- src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++ src/ipa/rkisp1/algorithms/agc.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 47a6f7b2..d380194d 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -373,6 +373,16 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext, metadata.set(controls::FrameDuration, frameDuration.get()); } +void Agc::parseStatistics(const rkisp1_stat_buffer *stats, + IPAContext &context) +{ + const rkisp1_cif_isp_stat *params = &stats->params; + + expMeans_ = { params->ae.exp_mean, context.hw->numAeCells }; + hist_ = Histogram(Span(params->hist.hist_bins, + context.hw->numHistogramBins)); +} + /** * \brief Process RkISP1 statistics, and run AGC operations * \param[in] context The shared IPA context diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index fb82a33f..b0de4898 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -14,6 +14,8 @@ #include +#include "libipa/histogram.h" + #include "algorithm.h" namespace libcamera { @@ -47,10 +49,15 @@ private: double measureBrightness(Span hist) const; void fillMetadata(IPAContext &context, IPAFrameContext &frameContext, ControlList &metadata); + void parseStatistics(const rkisp1_stat_buffer *stats, + IPAContext &context); uint64_t frameCount_; utils::Duration filteredExposure_; + + Histogram hist_; + Span expMeans_; }; } /* namespace ipa::rkisp1::algorithms */