From patchwork Thu Dec 2 18:04:06 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: 14996 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 78267C3250 for ; Thu, 2 Dec 2021 18:04:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A77196082A; Thu, 2 Dec 2021 19:04:20 +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="nuJ4kmLG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB10A605B8 for ; Thu, 2 Dec 2021 19:04:15 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:7fc3:78ca:aeee:c4f2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A7971D8B; Thu, 2 Dec 2021 19:04:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638468255; bh=8CcndOuDFTUXh7bslJGTOs8AaAYoZQ2ALtVSt+Hbsy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nuJ4kmLGnkbjAYfShfv9tjTu6wV7WNlimDYAMn+T4mUiAsfP/KrJkESkp6dr6vi6E J5szczCMt3+WjNUITYuHFdcb6gpbwrAiQWw71b3U7LCEd+QkGQrgFtDU2nR1fELS8+ AJFZzbZrmYOZGvTFiWjkc/lQ7rMGQzwLPRCBSsIc= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Dec 2021 19:04:06 +0100 Message-Id: <20211202180410.518232-3-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211202180410.518232-1-jeanmichel.hautbois@ideasonboard.com> References: <20211202180410.518232-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/6] ipa: rkisp1: Use frame index 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" Instead of incrementing the frameCount manually, use the frame index on the EventStatReay event and store it in a new IPAFrameContext variable named frameId. Signed-off-by: Jean-Michel Hautbois --- src/ipa/rkisp1/algorithms/agc.cpp | 5 ++--- src/ipa/rkisp1/ipa_context.cpp | 5 +++++ src/ipa/rkisp1/ipa_context.h | 2 ++ src/ipa/rkisp1/rkisp1.cpp | 11 +++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index d6abdc310..f95ecfde5 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -81,8 +81,6 @@ int Agc::configure(IPAContext &context, else numCells_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V12; - /* \todo Use actual frame index by populating it in the frameContext. */ - frameCount_ = 0; return 0; } @@ -254,6 +252,8 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats) const rkisp1_cif_isp_ae_stat *ae = ¶ms->ae; + frameCount_ = context.frameContext.frameId; + /* * Estimate the gain needed to achieve a relative luminance target. To * account for non-linearity caused by saturation, the value needs to be @@ -277,7 +277,6 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats) } computeExposure(context, yGain); - frameCount_++; } void Agc::prepare([[maybe_unused]] IPAContext &context, diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9cb2a9fda..992c92256 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -113,4 +113,9 @@ namespace libcamera::ipa::rkisp1 { * \brief Analogue gain multiplier */ +/** + * \var IPAFrameContext::frameId + * \brief Frame number for this frame context + */ + } /* namespace libcamera::ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b94ade0c5..c447369f3 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -43,6 +43,8 @@ struct IPAFrameContext { uint32_t exposure; double gain; } sensor; + + unsigned int frameId; }; struct IPAContext { diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 07f1f1c87..cd425a2e1 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -57,8 +57,7 @@ public: private: void queueRequest(unsigned int frame, rkisp1_params_cfg *params, const ControlList &controls); - void updateStatistics(unsigned int frame, - const rkisp1_stat_buffer *stats); + void updateStatistics(const rkisp1_stat_buffer *stats); void setControls(unsigned int frame); void metadataReady(unsigned int frame, unsigned int aeState); @@ -241,7 +240,6 @@ void IPARkISP1::processEvent(const RkISP1Event &event) { switch (event.op) { case EventSignalStatBuffer: { - unsigned int frame = event.frame; unsigned int bufferId = event.bufferId; const rkisp1_stat_buffer *stats = @@ -252,8 +250,9 @@ void IPARkISP1::processEvent(const RkISP1Event &event) event.sensorControls.get(V4L2_CID_EXPOSURE).get(); context_.frameContext.sensor.gain = camHelper_->gain(event.sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); + context_.frameContext.frameId = event.frame; - updateStatistics(frame, stats); + updateStatistics(stats); break; } case EventQueueRequest: { @@ -288,10 +287,10 @@ void IPARkISP1::queueRequest(unsigned int frame, rkisp1_params_cfg *params, queueFrameAction.emit(frame, op); } -void IPARkISP1::updateStatistics(unsigned int frame, - const rkisp1_stat_buffer *stats) +void IPARkISP1::updateStatistics(const rkisp1_stat_buffer *stats) { unsigned int aeState = 0; + unsigned int frame = context_.frameContext.frameId; for (auto const &algo : algorithms_) algo->process(context_, stats);