summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/awb.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-26 02:36:38 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-28 13:47:49 +0300
commitf357b1bf6ea39d8118e90f8a371974d29bd054e3 (patch)
tree2511c1b5e729844680a04239fb0a61df94a31f7f /src/ipa/raspberrypi/controller/rpi/awb.cpp
parent0c84c67e39e40db43605af0ee0a65b91114f6315 (diff)
ipa: raspberrypi: Return an error code from Algorithm::read()
When encountering errors, the Algorithm::read() function either uses LOG(Fatal) or throws exceptions from the boost property_tree functions. To prepare for replacing boost JSON parse with the YamlParser class, give the Algorithm::read() function the ability to return an error code, and propagate it all the way to the IPA module init() function. All algorithm classes return a hardcoded 0 value for now, subsequent commits will change that. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/awb.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/awb.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
index 6c2b627d..cd97d9f4 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
@@ -26,20 +26,21 @@ static constexpr unsigned int AwbStatsSizeY = DEFAULT_AWB_REGIONS_Y;
* elsewhere (ALSC and AGC).
*/
-void AwbMode::read(boost::property_tree::ptree const &params)
+int AwbMode::read(boost::property_tree::ptree const &params)
{
ctLo = params.get<double>("lo");
ctHi = params.get<double>("hi");
+ return 0;
}
-void AwbPrior::read(boost::property_tree::ptree const &params)
+int AwbPrior::read(boost::property_tree::ptree const &params)
{
lux = params.get<double>("lux");
- prior.read(params.get_child("prior"));
+ return prior.read(params.get_child("prior"));
}
-static void readCtCurve(Pwl &ctR, Pwl &ctB,
- boost::property_tree::ptree const &params)
+static int readCtCurve(Pwl &ctR, Pwl &ctB,
+ boost::property_tree::ptree const &params)
{
int num = 0;
for (auto it = params.begin(); it != params.end(); it++) {
@@ -55,21 +56,28 @@ static void readCtCurve(Pwl &ctR, Pwl &ctB,
}
if (num < 2)
LOG(RPiAwb, Fatal) << "AwbConfig: insufficient points in CT curve";
+ return 0;
}
-void AwbConfig::read(boost::property_tree::ptree const &params)
+int AwbConfig::read(boost::property_tree::ptree const &params)
{
+ int ret;
bayes = params.get<int>("bayes", 1);
framePeriod = params.get<uint16_t>("framePeriod", 10);
startupFrames = params.get<uint16_t>("startupFrames", 10);
convergenceFrames = params.get<unsigned int>("convergence_frames", 3);
speed = params.get<double>("speed", 0.05);
- if (params.get_child_optional("ct_curve"))
- readCtCurve(ctR, ctB, params.get_child("ct_curve"));
+ if (params.get_child_optional("ct_curve")) {
+ ret = readCtCurve(ctR, ctB, params.get_child("ct_curve"));
+ if (ret)
+ return ret;
+ }
if (params.get_child_optional("priors")) {
for (auto &p : params.get_child("priors")) {
AwbPrior prior;
- prior.read(p.second);
+ ret = prior.read(p.second);
+ if (ret)
+ return ret;
if (!priors.empty() && prior.lux <= priors.back().lux)
LOG(RPiAwb, Fatal) << "AwbConfig: Prior must be ordered in increasing lux value";
priors.push_back(prior);
@@ -79,7 +87,9 @@ void AwbConfig::read(boost::property_tree::ptree const &params)
}
if (params.get_child_optional("modes")) {
for (auto &p : params.get_child("modes")) {
- modes[p.first].read(p.second);
+ ret = modes[p.first].read(p.second);
+ if (ret)
+ return ret;
if (defaultMode == nullptr)
defaultMode = &modes[p.first];
}
@@ -110,6 +120,7 @@ void AwbConfig::read(boost::property_tree::ptree const &params)
whitepointB = params.get<double>("whitepoint_b", 0.0);
if (bayes == false)
sensitivityR = sensitivityB = 1.0; /* nor do sensitivities make any sense */
+ return 0;
}
Awb::Awb(Controller *controller)
@@ -137,9 +148,9 @@ char const *Awb::name() const
return NAME;
}
-void Awb::read(boost::property_tree::ptree const &params)
+int Awb::read(boost::property_tree::ptree const &params)
{
- config_.read(params);
+ return config_.read(params);
}
void Awb::initialise()