diff options
author | Barnabás Pőcze <barnabas.pocze@ideasonboard.com> | 2025-05-21 12:25:32 +0200 |
---|---|---|
committer | Barnabás Pőcze <barnabas.pocze@ideasonboard.com> | 2025-05-27 09:42:46 +0200 |
commit | eecb270085e6a96ba0c7786410877c732d3381e1 (patch) | |
tree | cc2318c8b15ba507a23e9bc59739b61bcb88da97 | |
parent | aca8b701ac5645aaf13e2334c4c9e7610d4128a2 (diff) |
treewide: Do not use `*NameValueMap` for known values
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 <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | src/ipa/libipa/agc_mean_luminance.cpp | 5 | ||||
-rw-r--r-- | src/ipa/rkisp1/algorithms/agc.cpp | 3 | ||||
-rw-r--r-- | src/libcamera/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 f617fde8..d37a9b66 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<std::pair<utils::Duration, double>> stages = { }; std::shared_ptr<ExposureModeHelper> helper = diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index b3ac9400..137a0750 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<uint8_t> weights(context.hw->numHistogramWeights, 1); - meteringModes_[meteringModeId] = weights; + meteringModes_[controls::MeteringMatrix] = weights; } std::vector<ControlValue> meteringModes; diff --git a/src/libcamera/pipeline/virtual/config_parser.cpp b/src/libcamera/pipeline/virtual/config_parser.cpp index d9900add..1d3d9ba8 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<std::string>("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<std::string>()) { + 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; } |