From c1597f989654618f782012104f547b367082fa3e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 18 Jul 2022 09:15:58 +0100 Subject: 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 Tested-by: Naushir Patuck Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 47 +++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'src/ipa/raspberrypi/controller/rpi/ccm.cpp') 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 ¶ms) +int Matrix::read(const libcamera::YamlObject ¶ms) { 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(); - } - 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 ¶m : params.asList()) { + auto value = param.get(); + 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 ¶ms) +int Ccm::read(const libcamera::YamlObject ¶ms) { 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(); + if (!value) + return -EINVAL; + CtCcm ctCcm; - ctCcm.ct = p.second.get("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)); } -- cgit v1.2.1