summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/ccm.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-18 09:15:58 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-28 13:47:50 +0300
commitc1597f989654618f782012104f547b367082fa3e (patch)
tree7cbf0a2ff11609d0dbe60d145711f67a0f606ff6 /src/ipa/raspberrypi/controller/rpi/ccm.cpp
parent735f0ffeaac736f91c35774e575b1280ba868d69 (diff)
ipa: raspberrypi: Use YamlParser to replace dependency on boost
The Raspberry Pi IPA module depends on boost only to parse the JSON tuning data files. As libcamera depends on libyaml, use the YamlParser class to parse those files and drop the dependency on boost. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/ccm.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/ccm.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp
index 9588e94a..2e2e6664 100644
--- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp
@@ -39,21 +39,22 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5,
m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4,
m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8;
}
-int Matrix::read(boost::property_tree::ptree const &params)
+int Matrix::read(const libcamera::YamlObject &params)
{
double *ptr = (double *)m;
- int n = 0;
- for (auto it = params.begin(); it != params.end(); it++) {
- if (n++ == 9) {
- LOG(RPiCcm, Error) << "Too many values in CCM";
- return -EINVAL;
- }
- *ptr++ = it->second.get_value<double>();
- }
- if (n < 9) {
- LOG(RPiCcm, Error) << "Too few values in CCM";
+
+ if (params.size() != 9) {
+ LOG(RPiCcm, Error) << "Wrong number of values in CCM";
return -EINVAL;
}
+
+ for (const auto &param : params.asList()) {
+ auto value = param.get<double>();
+ if (!value)
+ return -EINVAL;
+ *ptr++ = *value;
+ }
+
return 0;
}
@@ -65,27 +66,33 @@ char const *Ccm::name() const
return NAME;
}
-int Ccm::read(boost::property_tree::ptree const &params)
+int Ccm::read(const libcamera::YamlObject &params)
{
int ret;
- if (params.get_child_optional("saturation")) {
- ret = config_.saturation.read(params.get_child("saturation"));
+ if (params.contains("saturation")) {
+ ret = config_.saturation.read(params["saturation"]);
if (ret)
return ret;
}
- for (auto &p : params.get_child("ccms")) {
+ for (auto &p : params["ccms"].asList()) {
+ auto value = p["ct"].get<double>();
+ if (!value)
+ return -EINVAL;
+
CtCcm ctCcm;
- ctCcm.ct = p.second.get<double>("ct");
- ret = ctCcm.ccm.read(p.second.get_child("ccm"));
+ ctCcm.ct = *value;
+ ret = ctCcm.ccm.read(p["ccm"]);
if (ret)
return ret;
- if (!config_.ccms.empty() &&
- ctCcm.ct <= config_.ccms.back().ct) {
- LOG(RPiCcm, Error) << "CCM not in increasing colour temperature order";
+
+ if (!config_.ccms.empty() && ctCcm.ct <= config_.ccms.back().ct) {
+ LOG(RPiCcm, Error)
+ << "CCM not in increasing colour temperature order";
return -EINVAL;
}
+
config_.ccms.push_back(std::move(ctCcm));
}