From patchwork Thu May 22 14:29:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 23429 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 10BF2C31E9 for ; Thu, 22 May 2025 14:29:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A0B768D96; Thu, 22 May 2025 16:29:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PPttrOPx"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A47D668D8B for ; Thu, 22 May 2025 16:29:25 +0200 (CEST) Received: from pb-laptop.local (185.221.141.78.nat.pool.zt.hu [185.221.141.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 487909E5 for ; Thu, 22 May 2025 16:29:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1747924143; bh=6E8HDznP4qRKQxUubZqKv3+y8WQn9ICAsXBW+xDx9ro=; h=From:To:Subject:Date:From; b=PPttrOPxLHgbD6AUU3jo94awyEDkh2I2pHfrPnlcpKpfx4txPPLSU2tW6EdFhpzr6 9tLOzHxaE1BsGInbazyoXY3MBdCYzlhlkGB6hB0mvoDAfLtXh3u1B0kLwuvuL+JMWp hpPgKyKFdVBS94lXMfm+6WyaFbfCXhUKbQSIZLnM= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] treewide: Do not use `*NameValueMap` for known values Date: Thu, 22 May 2025 16:29:21 +0200 Message-ID: <20250522142921.1378425-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.0 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" When the value is known, do not look it up via the control's `NameValueMap`, instead, just refer to the value directly. Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder --- src/ipa/libipa/agc_mean_luminance.cpp | 5 ++--- src/ipa/rkisp1/algorithms/agc.cpp | 3 +-- .../pipeline/virtual/config_parser.cpp | 20 +++++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index f617fde81..d37a9b661 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -218,8 +218,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData) constraintModes_[controls::ConstraintNormal].insert( constraintModes_[controls::ConstraintNormal].begin(), constraint); - availableConstraintModes.push_back( - AeConstraintModeNameValueMap.at("ConstraintNormal")); + availableConstraintModes.push_back(controls::ConstraintNormal); } controls_[&controls::AeConstraintMode] = ControlInfo(availableConstraintModes); @@ -287,7 +286,7 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData) * possible before touching gain. */ if (availableExposureModes.empty()) { - int32_t exposureModeId = AeExposureModeNameValueMap.at("ExposureNormal"); + int32_t exposureModeId = controls::ExposureNormal; std::vector> stages = { }; std::shared_ptr helper = diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index b3ac9400b..137a07500 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -68,10 +68,9 @@ int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData) if (meteringModes_.empty()) { LOG(RkISP1Agc, Warning) << "No metering modes read from tuning file; defaulting to matrix"; - int32_t meteringModeId = controls::AeMeteringModeNameValueMap.at("MeteringMatrix"); std::vector weights(context.hw->numHistogramWeights, 1); - meteringModes_[meteringModeId] = weights; + meteringModes_[controls::MeteringMatrix] = weights; } std::vector meteringModes; diff --git a/src/libcamera/pipeline/virtual/config_parser.cpp b/src/libcamera/pipeline/virtual/config_parser.cpp index d9900add6..1d3d9ba87 100644 --- a/src/libcamera/pipeline/virtual/config_parser.cpp +++ b/src/libcamera/pipeline/virtual/config_parser.cpp @@ -233,17 +233,21 @@ int ConfigParser::parseFrameGenerator(const YamlObject &cameraConfigData, Virtua int ConfigParser::parseLocation(const YamlObject &cameraConfigData, VirtualCameraData *data) { - std::string location = cameraConfigData["location"].get("CameraLocationFront"); - /* Default value is properties::CameraLocationFront */ - auto it = properties::LocationNameValueMap.find(location); - if (it == properties::LocationNameValueMap.end()) { - LOG(Virtual, Error) - << "location: " << location << " is not supported"; - return -EINVAL; + int32_t location = properties::CameraLocationFront; + + if (auto l = cameraConfigData["location"].get()) { + auto it = properties::LocationNameValueMap.find(*l); + if (it == properties::LocationNameValueMap.end()) { + LOG(Virtual, Error) + << "location: " << *l << " is not supported"; + return -EINVAL; + } + + location = it->second; } - data->properties_.set(properties::Location, it->second); + data->properties_.set(properties::Location, location); return 0; }