From patchwork Fri Oct 15 01:58:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14154 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 D7976C323E for ; Fri, 15 Oct 2021 01:58:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2CD3768F51; Fri, 15 Oct 2021 03:58:25 +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="vPlr1sGm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 801B260239 for ; Fri, 15 Oct 2021 03:58:24 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E93BB2E3; Fri, 15 Oct 2021 03:58:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634263104; bh=oS+gY3HueFaTt5SMq6wXV9jkYcj0dkJInj/JhMDChBY=; h=From:To:Cc:Subject:Date:From; b=vPlr1sGml8jylSlcpTOzV4C9Ktp7mDAOZbmbAVQJNTDFS9ISqjTepMuSaWi+29t++ AeCft/MezXZlKRJZ/A0ORG9YS04NaEO+nWM75OnsOapSIrFsb/WqRypaR7+0bDUlCm YeAJ7okjcful4OGyc4u5YjQnMHmn3ca2neWWFkpM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 15 Oct 2021 04:58:03 +0300 Message-Id: <20211015015804.11758-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] ipa: ipu3: awb: Don't pass member variable to member function 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" The Awb::generateZones() member function fills the zones vector passed as an argument, which is actually a member variable. Use it directly in the function. Signed-off-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/ipu3/algorithms/awb.cpp | 12 ++++++++---- src/ipa/ipu3/algorithms/awb.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) base-commit: ccec150589a177654b9039d21163c36ccff85cff diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index e2b18336d582..809de66aa7fa 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -196,8 +196,10 @@ uint32_t Awb::estimateCCT(double red, double green, double blue) } /* Generate an RGB vector with the average values for each zone */ -void Awb::generateZones(std::vector &zones) +void Awb::generateZones() { + zones_.clear(); + for (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) { RGB zone; double counted = awbStats_[i].counted; @@ -206,7 +208,7 @@ void Awb::generateZones(std::vector &zones) if (zone.G >= kMinGreenLevelInZone) { zone.R = awbStats_[i].sum.red / counted; zone.B = awbStats_[i].sum.blue / counted; - zones.push_back(zone); + zones_.push_back(zone); } } } @@ -298,11 +300,13 @@ void Awb::awbGreyWorld() void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats) { ASSERT(stats->stats_3a_status.awb_en); - zones_.clear(); + clearAwbStats(); generateAwbStats(stats); - generateZones(zones_); + generateZones(); + LOG(IPU3Awb, Debug) << "Valid zones: " << zones_.size(); + if (zones_.size() > 10) { awbGreyWorld(); LOG(IPU3Awb, Debug) << "Gain found for red: " << asyncResults_.redGain diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h index 677384eda54a..3b81f600aa02 100644 --- a/src/ipa/ipu3/algorithms/awb.h +++ b/src/ipa/ipu3/algorithms/awb.h @@ -65,7 +65,7 @@ public: private: void calculateWBGains(const ipu3_uapi_stats_3a *stats); - void generateZones(std::vector &zones); + void generateZones(); void generateAwbStats(const ipu3_uapi_stats_3a *stats); void clearAwbStats(); void awbGreyWorld(); From patchwork Fri Oct 15 01:58:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14155 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 0E712C323E for ; Fri, 15 Oct 2021 01:58:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D448268F52; Fri, 15 Oct 2021 03:58:26 +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="S6r3khiY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB27B68F4F for ; Fri, 15 Oct 2021 03:58:24 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 618E8B91; Fri, 15 Oct 2021 03:58:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634263104; bh=7RLfVZI2/69O9jDyHPlWttlJmBIUPK6ylSME+R9PYN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6r3khiY9o7Z+e2b4pFR+aX3D4HuEXiKjaNhiauqREkAuLIlY2dl6p2k8WEEemcz7 VKOvHy6f8ti6PKw+U42oP7VDPxIDTqFa8JQ2f4Pvj3ElPzO0EChUj/E1sJHukuPJ49 oFwvsYKl0L73FknaYdaAs5paVl0en0r8TPvNhl1Q= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 15 Oct 2021 04:58:04 +0300 Message-Id: <20211015015804.11758-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211015015804.11758-1-laurent.pinchart@ideasonboard.com> References: <20211015015804.11758-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] ipa: ipu3: agc: Remove "using" directive from agc.h header 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" "using" directives are harmful in headers, as they propagate the namespace short-circuit to all files that include the header, directly or indirectly. Drop the directive from agc.h, and use utils::Duration explicitly. While at it, shorten the namespace qualifier from libcamera::utils:: to utils:: in agc.cpp for Duration. Signed-off-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/ipu3/algorithms/agc.cpp | 6 +++--- src/ipa/ipu3/algorithms/agc.h | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 5eafe82ca404..970ec42419cc 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -140,20 +140,20 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain) double newGain = kEvGainTarget * knumHistogramBins / iqMean_; /* extracted from Rpi::Agc::computeTargetExposure */ - libcamera::utils::Duration currentShutter = exposure * lineDuration_; + utils::Duration currentShutter = exposure * lineDuration_; currentExposureNoDg_ = currentShutter * gain; LOG(IPU3Agc, Debug) << "Actual total exposure " << currentExposureNoDg_ << " Shutter speed " << currentShutter << " Gain " << gain; currentExposure_ = currentExposureNoDg_ * newGain; - libcamera::utils::Duration maxTotalExposure = maxExposureTime_ * kMaxGain; + utils::Duration maxTotalExposure = maxExposureTime_ * kMaxGain; currentExposure_ = std::min(currentExposure_, maxTotalExposure); LOG(IPU3Agc, Debug) << "Target total exposure " << currentExposure_; /* \todo: estimate if we need to desaturate */ filterExposure(); - libcamera::utils::Duration newExposure = 0.0s; + utils::Duration newExposure = 0.0s; if (currentShutter < maxExposureTime_) { exposure = std::clamp(static_cast(exposure * currentExposure_ / currentExposureNoDg_), kMinExposure, kMaxExposure); newExposure = currentExposure_ / exposure; diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h index 64b71c65ef00..e0c315fc126c 100644 --- a/src/ipa/ipu3/algorithms/agc.h +++ b/src/ipa/ipu3/algorithms/agc.h @@ -21,8 +21,6 @@ struct IPACameraSensorInfo; namespace ipa::ipu3::algorithms { -using utils::Duration; - class Agc : public Algorithm { public: @@ -43,13 +41,13 @@ private: double iqMean_; - Duration lineDuration_; - Duration maxExposureTime_; + utils::Duration lineDuration_; + utils::Duration maxExposureTime_; - Duration prevExposure_; - Duration prevExposureNoDg_; - Duration currentExposure_; - Duration currentExposureNoDg_; + utils::Duration prevExposure_; + utils::Duration prevExposureNoDg_; + utils::Duration currentExposure_; + utils::Duration currentExposureNoDg_; uint32_t stride_; };