From patchwork Thu Aug 12 16:52:41 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: 13336 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 951F8BD87D for ; Thu, 12 Aug 2021 16:52:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4699F6888F; Thu, 12 Aug 2021 18:52:56 +0200 (CEST) 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="kFoiCMJy"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F8AE68894 for ; Thu, 12 Aug 2021 18:52:48 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:3d6d:7284:3c48:5edc]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0884149A; Thu, 12 Aug 2021 18:52:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628787168; bh=55jw/y2mhxYMAJL6uHbuv9dgarSKY+SQjqqYtIFCRxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kFoiCMJyMuiI2ctq6IC6hppfYOzeG88HwNRo/KEUszHT4bdQJUVhaqXX00cEpyvEb I72B0zbHhkEzLQyBbrv5nD2d9FB/n9RvoBaIVem3nfOyBWYCZoJdjnVQ+873oXhciV iBHzVRP87ivlAwS46pgfL5kCpPSZuak1zF+lYEyU= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 18:52:41 +0200 Message-Id: <20210812165243.276977-9-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812165243.276977-1-jeanmichel.hautbois@ideasonboard.com> References: <20210812165243.276977-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 08/10] ipa: ipu3: Remove unneeded function calls in AGC 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" We never use converged_ so remove its declaration. The controls may not need to be updated at each call, but it should be decided on the context side and not by a specific call. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipu3.cpp | 6 ++---- src/ipa/ipu3/ipu3_agc.cpp | 10 ++-------- src/ipa/ipu3/ipu3_agc.h | 5 ----- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 2a8225a0..27765aa6 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -309,8 +309,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) for (auto const &algo : algorithms_) algo->prepare(context_, params_); - if (agcAlgo_->updateControls()) - awbAlgo_->prepare(context_, params_); + awbAlgo_->prepare(context_, params_); *params = params_; @@ -338,8 +337,7 @@ void IPAIPU3::parseStatistics(unsigned int frame, awbAlgo_->process(context_, stats); - if (agcAlgo_->updateControls()) - setControls(frame); + setControls(frame); /* \todo Use VBlank value calculated from each frame exposure. */ int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) / diff --git a/src/ipa/ipu3/ipu3_agc.cpp b/src/ipa/ipu3/ipu3_agc.cpp index 0cc35b9f..0d0584a8 100644 --- a/src/ipa/ipu3/ipu3_agc.cpp +++ b/src/ipa/ipu3/ipu3_agc.cpp @@ -51,9 +51,8 @@ static constexpr double kEvGainTarget = 0.5; static constexpr uint8_t kCellSize = 8; IPU3Agc::IPU3Agc() - : frameCount_(0), lastFrame_(0), converged_(false), - updateControls_(false), iqMean_(0.0), - lineDuration_(0s), maxExposureTime_(0s), + : frameCount_(0), lastFrame_(0), + iqMean_(0.0), lineDuration_(0s), maxExposureTime_(0s), prevExposure_(0s), prevExposureNoDg_(0s), currentExposure_(0s), currentExposureNoDg_(0s) { @@ -146,8 +145,6 @@ void IPU3Agc::filterExposure() void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain) { - updateControls_ = false; - /* Algorithm initialization should wait for first valid frames */ /* \todo - have a number of frames given by DelayedControls ? * - implement a function for IIR */ @@ -157,7 +154,6 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain) /* Are we correctly exposed ? */ if (std::abs(iqMean_ - kEvGainTarget * knumHistogramBins) <= 1) { LOG(IPU3Agc, Debug) << "!!! Good exposure with iqMean = " << iqMean_; - converged_ = true; } else { double newGain = kEvGainTarget * knumHistogramBins / iqMean_; @@ -180,12 +176,10 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain) exposure = std::clamp(static_cast(exposure * currentExposure_ / currentExposureNoDg_), kMinExposure, kMaxExposure); newExposure = currentExposure_ / exposure; gain = std::clamp(static_cast(gain * currentExposure_ / newExposure), kMinGain, kMaxGain); - updateControls_ = true; } else if (currentShutter >= maxExposureTime_) { gain = std::clamp(static_cast(gain * currentExposure_ / currentExposureNoDg_), kMinGain, kMaxGain); newExposure = currentExposure_ / gain; exposure = std::clamp(static_cast(exposure * currentExposure_ / newExposure), kMinExposure, kMaxExposure); - updateControls_ = true; } LOG(IPU3Agc, Debug) << "Adjust exposure " << exposure * lineDuration_ << " and gain " << gain; } diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h index e096648b..0e922664 100644 --- a/src/ipa/ipu3/ipu3_agc.h +++ b/src/ipa/ipu3/ipu3_agc.h @@ -31,8 +31,6 @@ public: int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override; - bool converged() { return converged_; } - bool updateControls() { return updateControls_; } private: void processBrightness(const ipu3_uapi_stats_3a *stats); @@ -44,9 +42,6 @@ private: uint64_t frameCount_; uint64_t lastFrame_; - bool converged_; - bool updateControls_; - double iqMean_; Duration lineDuration_;