Patch Detail
Show a patch.
GET /api/1.1/patches/22185/?format=api
{ "id": 22185, "url": "https://patchwork.libcamera.org/api/1.1/patches/22185/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22185/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241205163411.1160094-2-pobrn@protonmail.com>", "date": "2024-12-05T16:34:19", "name": "[v1,2/3] treewide: Use `YamlObject::find()`", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "afa5f6acc253d2cf15d77e492d6fce9c3ecacd13", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/1.1/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22185/mbox/", "series": [ { "id": 4852, "url": "https://patchwork.libcamera.org/api/1.1/series/4852/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4852", "date": "2024-12-05T16:34:14", "name": "[v1,1/3] libcamera: yaml_parser: Add `YamlObject::find(key)`", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4852/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22185/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22185/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A20A7C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 5 Dec 2024 16:37:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5DD0C66110;\n\tThu, 5 Dec 2024 17:37:52 +0100 (CET)", "from mail-10629.protonmail.ch (mail-10629.protonmail.ch\n\t[79.135.106.29])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C6F166109\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 5 Dec 2024 17:37:50 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"vy4QpQ2+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1733416669; x=1733675869;\n\tbh=k41wX0pTfTUz24Gge5OtHTMRJHSakj/sYzQQhfk2IAs=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=vy4QpQ2+rAoqF8wL2H05bgWFX2muq/8E2V3gfGgpPgHtTA9kXZvpbasQ0isQ1lkKs\n\t13PfHU5YoqTmnoSSFGlEd3Z66UrF8ZRBMtaevQC/aBwBZ7rUmeX7rcWKzUw3ucyJXF\n\tiJka772NLKhaEhgUWY4vKapVUf+WsNYPoXzRvq05lE4+e9Ak25Hd2VeuExadDhv1OW\n\t8qGoz+95plYZ2Ya5PVGdvViyhltH6uKuZ94LQNK/jybZgmBfjAb0A7PiktWcqdYMZv\n\tEcbLoAb3pfNw546JoLSzB16FpRNVApkOaK9t0+JlcnmEu9KHNYTw2Ad5XFPelE4iG/\n\tcRhnN8Jv8LmsA==", "Date": "Thu, 05 Dec 2024 16:34:19 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Subject": "[PATCH v1 2/3] treewide: Use `YamlObject::find()`", "Message-ID": "<20241205163411.1160094-2-pobrn@protonmail.com>", "In-Reply-To": "<20241205163411.1160094-1-pobrn@protonmail.com>", "References": "<20241205163411.1160094-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "2257a0d355a1be23ed45d4d0179ecd3ff5dd8f7a", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Replace some uses of `contains()` + `operator[]` with `find()`.\nUsing `find()` avoids the double lookup, as well as does away with\nthe need for specifying the key twice.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/android/camera_hal_config.cpp | 19 ++++----\n src/ipa/ipu3/ipu3.cpp | 5 +-\n src/ipa/rkisp1/algorithms/dpcc.cpp | 56 +++++++++++-----------\n src/ipa/rkisp1/rkisp1.cpp | 5 +-\n src/ipa/rpi/controller/controller.cpp | 5 +-\n src/ipa/rpi/controller/rpi/af.cpp | 32 ++++++-------\n src/ipa/rpi/controller/rpi/agc.cpp | 8 ++--\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 4 +-\n src/ipa/rpi/controller/rpi/alsc.cpp | 10 ++--\n src/ipa/rpi/controller/rpi/awb.cpp | 12 ++---\n src/ipa/rpi/controller/rpi/ccm.cpp | 4 +-\n src/ipa/rpi/controller/rpi/geq.cpp | 4 +-\n src/ipa/rpi/controller/rpi/hdr.cpp | 27 ++++++-----\n src/ipa/simple/soft_simple.cpp | 5 +-\n 14 files changed, 99 insertions(+), 97 deletions(-)", "diff": "diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp\nindex 7ef451ef..6fde953d 100644\n--- a/src/android/camera_hal_config.cpp\n+++ b/src/android/camera_hal_config.cpp\n@@ -73,15 +73,14 @@ int CameraHalConfig::Private::parseConfigFile(File &file,\n \t\treturn -EINVAL;\n \n \t/* Parse property \"cameras\" */\n-\tif (!root->contains(\"cameras\"))\n+\tauto *yamlObjectCameras = root->find(\"cameras\");\n+\tif (!yamlObjectCameras)\n \t\treturn -EINVAL;\n \n-\tconst YamlObject &yamlObjectCameras = (*root)[\"cameras\"];\n-\n-\tif (!yamlObjectCameras.isDictionary())\n+\tif (!yamlObjectCameras->isDictionary())\n \t\treturn -EINVAL;\n \n-\tfor (const auto &[cameraId, configData] : yamlObjectCameras.asDict()) {\n+\tfor (const auto &[cameraId, configData] : yamlObjectCameras->asDict()) {\n \t\tif (parseCameraConfigData(cameraId, configData))\n \t\t\treturn -EINVAL;\n \t}\n@@ -112,10 +111,11 @@ int CameraHalConfig::Private::parseCameraConfigData(const std::string &cameraId,\n int CameraHalConfig::Private::parseLocation(const YamlObject &cameraObject,\n \t\t\t\t\t CameraConfigData &cameraConfigData)\n {\n-\tif (!cameraObject.contains(\"location\"))\n+\tauto *loc = cameraObject.find(\"location\");\n+\tif (!loc)\n \t\treturn -EINVAL;\n \n-\tstd::string location = cameraObject[\"location\"].get<std::string>(\"\");\n+\tstd::string location = loc->get<std::string>(\"\");\n \n \tif (location == \"front\")\n \t\tcameraConfigData.facing = CAMERA_FACING_FRONT;\n@@ -130,10 +130,11 @@ int CameraHalConfig::Private::parseLocation(const YamlObject &cameraObject,\n int CameraHalConfig::Private::parseRotation(const YamlObject &cameraObject,\n \t\t\t\t\t CameraConfigData &cameraConfigData)\n {\n-\tif (!cameraObject.contains(\"rotation\"))\n+\tauto *rot = cameraObject.find(\"rotation\");\n+\tif (!rot)\n \t\treturn -EINVAL;\n \n-\tint32_t rotation = cameraObject[\"rotation\"].get<int32_t>(-1);\n+\tint32_t rotation = rot->get<int32_t>(-1);\n \n \tif (rotation < 0 || rotation >= 360) {\n \t\tLOG(HALConfig, Error)\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 44c98cbf..88b1bb81 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -335,13 +335,14 @@ int IPAIPU3::init(const IPASettings &settings,\n \t\treturn -EINVAL;\n \t}\n \n-\tif (!data->contains(\"algorithms\")) {\n+\tauto *algos = data->find(\"algorithms\");\n+\tif (!algos) {\n \t\tLOG(IPAIPU3, Error)\n \t\t\t<< \"Tuning file doesn't contain any algorithm\";\n \t\treturn -EINVAL;\n \t}\n \n-\tint ret = createAlgorithms(context_, (*data)[\"algorithms\"]);\n+\tint ret = createAlgorithms(context_, *algos);\n \tif (ret)\n \t\treturn ret;\n \ndiff --git a/src/ipa/rkisp1/algorithms/dpcc.cpp b/src/ipa/rkisp1/algorithms/dpcc.cpp\nindex 78946281..8946c1a7 100644\n--- a/src/ipa/rkisp1/algorithms/dpcc.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpcc.cpp\n@@ -80,39 +80,39 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,\n \t\t/* PG Method */\n \t\tconst YamlObject &pgObject = set[\"pg-factor\"];\n \n-\t\tif (pgObject.contains(\"green\")) {\n+\t\tif (auto *green = pgObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE;\n \n-\t\t\tvalue = pgObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tmethod.pg_fac |= RKISP1_CIF_ISP_DPCC_PG_FAC_G(value);\n \t\t}\n \n-\t\tif (pgObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = pgObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = pgObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tmethod.pg_fac |= RKISP1_CIF_ISP_DPCC_PG_FAC_RB(value);\n \t\t}\n \n \t\t/* RO Method */\n \t\tconst YamlObject &roObject = set[\"ro-limits\"];\n \n-\t\tif (roObject.contains(\"green\")) {\n+\t\tif (auto *green = roObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE;\n \n-\t\t\tvalue = roObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tconfig_.ro_limits |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(i, value);\n \t\t}\n \n-\t\tif (roObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = roObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = roObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tconfig_.ro_limits |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(i, value);\n \t\t}\n@@ -121,39 +121,39 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,\n \t\tconst YamlObject &rgObject = set[\"rg-factor\"];\n \t\tmethod.rg_fac = 0;\n \n-\t\tif (rgObject.contains(\"green\")) {\n+\t\tif (auto *green = rgObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE;\n \n-\t\t\tvalue = rgObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tmethod.rg_fac |= RKISP1_CIF_ISP_DPCC_RG_FAC_G(value);\n \t\t}\n \n-\t\tif (rgObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = rgObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = rgObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tmethod.rg_fac |= RKISP1_CIF_ISP_DPCC_RG_FAC_RB(value);\n \t\t}\n \n \t\t/* RND Method */\n \t\tconst YamlObject &rndOffsetsObject = set[\"rnd-offsets\"];\n \n-\t\tif (rndOffsetsObject.contains(\"green\")) {\n+\t\tif (auto *green = rndOffsetsObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE;\n \n-\t\t\tvalue = rndOffsetsObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tconfig_.rnd_offs |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(i, value);\n \t\t}\n \n-\t\tif (rndOffsetsObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = rndOffsetsObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = rndOffsetsObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tconfig_.rnd_offs |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(i, value);\n \t\t}\n@@ -161,20 +161,20 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,\n \t\tconst YamlObject &rndThresholdObject = set[\"rnd-threshold\"];\n \t\tmethod.rnd_thresh = 0;\n \n-\t\tif (rndThresholdObject.contains(\"green\")) {\n+\t\tif (auto *green = rndThresholdObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE;\n \n-\t\t\tvalue = rndThresholdObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tmethod.rnd_thresh |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RND_THRESH_G(value);\n \t\t}\n \n-\t\tif (rndThresholdObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = rndThresholdObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = rndThresholdObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tmethod.rnd_thresh |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_RND_THRESH_RB(value);\n \t\t}\n@@ -183,20 +183,20 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,\n \t\tconst YamlObject &lcThresholdObject = set[\"line-threshold\"];\n \t\tmethod.line_thresh = 0;\n \n-\t\tif (lcThresholdObject.contains(\"green\")) {\n+\t\tif (auto *green = lcThresholdObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE;\n \n-\t\t\tvalue = lcThresholdObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tmethod.line_thresh |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_LINE_THRESH_G(value);\n \t\t}\n \n-\t\tif (lcThresholdObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = lcThresholdObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = lcThresholdObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tmethod.line_thresh |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(value);\n \t\t}\n@@ -204,20 +204,20 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,\n \t\tconst YamlObject &lcTMadFactorObject = set[\"line-mad-factor\"];\n \t\tmethod.line_mad_fac = 0;\n \n-\t\tif (lcTMadFactorObject.contains(\"green\")) {\n+\t\tif (auto *green = lcTMadFactorObject.find(\"green\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE;\n \n-\t\t\tvalue = lcTMadFactorObject[\"green\"].get<uint16_t>(0);\n+\t\t\tvalue = green->get<uint16_t>(0);\n \t\t\tmethod.line_mad_fac |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(value);\n \t\t}\n \n-\t\tif (lcTMadFactorObject.contains(\"red-blue\")) {\n+\t\tif (auto *redBlue = lcTMadFactorObject.find(\"red-blue\")) {\n \t\t\tmethod.method |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE;\n \n-\t\t\tvalue = lcTMadFactorObject[\"red-blue\"].get<uint16_t>(0);\n+\t\t\tvalue = redBlue->get<uint16_t>(0);\n \t\t\tmethod.line_mad_fac |=\n \t\t\t\tRKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(value);\n \t\t}\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 2ffdd99b..202b53b7 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -193,13 +193,14 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t\treturn -EINVAL;\n \t}\n \n-\tif (!data->contains(\"algorithms\")) {\n+\tauto *algos = data->find(\"algorithms\");\n+\tif (!algos) {\n \t\tLOG(IPARkISP1, Error)\n \t\t\t<< \"Tuning file doesn't contain any algorithm\";\n \t\treturn -EINVAL;\n \t}\n \n-\tint ret = createAlgorithms(context_, (*data)[\"algorithms\"]);\n+\tint ret = createAlgorithms(context_, *algos);\n \tif (ret)\n \t\treturn ret;\n \ndiff --git a/src/ipa/rpi/controller/controller.cpp b/src/ipa/rpi/controller/controller.cpp\nindex e0131018..fbf31f23 100644\n--- a/src/ipa/rpi/controller/controller.cpp\n+++ b/src/ipa/rpi/controller/controller.cpp\n@@ -109,14 +109,15 @@ int Controller::read(char const *filename)\n \t\t\t\treturn ret;\n \t\t}\n \t} else if (version < 3.0) {\n-\t\tif (!root->contains(\"algorithms\")) {\n+\t\tauto *algos = root->find(\"algorithms\");\n+\t\tif (!algos) {\n \t\t\tLOG(RPiController, Error)\n \t\t\t\t<< \"Tuning file \" << filename\n \t\t\t\t<< \" does not have an \\\"algorithms\\\" list!\";\n \t\t\treturn -EINVAL;\n \t\t}\n \n-\t\tfor (auto const &rootAlgo : (*root)[\"algorithms\"].asList())\n+\t\tfor (auto const &rootAlgo : algos->asList())\n \t\t\tfor (auto const &[key, value] : rootAlgo.asDict()) {\n \t\t\t\tint ret = createAlgorithm(key, value);\n \t\t\t\tif (ret)\ndiff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp\nindex 2157eb94..c29bbaeb 100644\n--- a/src/ipa/rpi/controller/rpi/af.cpp\n+++ b/src/ipa/rpi/controller/rpi/af.cpp\n@@ -97,39 +97,35 @@ void Af::SpeedDependentParams::read(const libcamera::YamlObject ¶ms)\n \n int Af::CfgParams::read(const libcamera::YamlObject ¶ms)\n {\n-\tif (params.contains(\"ranges\")) {\n-\t\tauto &rr = params[\"ranges\"];\n-\n-\t\tif (rr.contains(\"normal\"))\n-\t\t\tranges[AfRangeNormal].read(rr[\"normal\"]);\n+\tif (auto *rs = params.find(\"ranges\")) {\n+\t\tif (auto *normal = rs->find(\"normal\"))\n+\t\t\tranges[AfRangeNormal].read(*normal);\n \t\telse\n \t\t\tLOG(RPiAf, Warning) << \"Missing range \\\"normal\\\"\";\n \n \t\tranges[AfRangeMacro] = ranges[AfRangeNormal];\n-\t\tif (rr.contains(\"macro\"))\n-\t\t\tranges[AfRangeMacro].read(rr[\"macro\"]);\n+\t\tif (auto *macro = rs->find(\"macro\"))\n+\t\t\tranges[AfRangeMacro].read(*macro);\n \n \t\tranges[AfRangeFull].focusMin = std::min(ranges[AfRangeNormal].focusMin,\n \t\t\t\t\t\t\tranges[AfRangeMacro].focusMin);\n \t\tranges[AfRangeFull].focusMax = std::max(ranges[AfRangeNormal].focusMax,\n \t\t\t\t\t\t\tranges[AfRangeMacro].focusMax);\n \t\tranges[AfRangeFull].focusDefault = ranges[AfRangeNormal].focusDefault;\n-\t\tif (rr.contains(\"full\"))\n-\t\t\tranges[AfRangeFull].read(rr[\"full\"]);\n+\t\tif (auto *full = rs->find(\"full\"))\n+\t\t\tranges[AfRangeFull].read(*full);\n \t} else\n \t\tLOG(RPiAf, Warning) << \"No ranges defined\";\n \n-\tif (params.contains(\"speeds\")) {\n-\t\tauto &ss = params[\"speeds\"];\n-\n-\t\tif (ss.contains(\"normal\"))\n-\t\t\tspeeds[AfSpeedNormal].read(ss[\"normal\"]);\n+\tif (auto *ss = params.find(\"speeds\")) {\n+\t\tif (auto *normal = ss->find(\"normal\"))\n+\t\t\tspeeds[AfSpeedNormal].read(*normal);\n \t\telse\n \t\t\tLOG(RPiAf, Warning) << \"Missing speed \\\"normal\\\"\";\n \n \t\tspeeds[AfSpeedFast] = speeds[AfSpeedNormal];\n-\t\tif (ss.contains(\"fast\"))\n-\t\t\tspeeds[AfSpeedFast].read(ss[\"fast\"]);\n+\t\tif (auto *fast = ss->find(\"fast\"))\n+\t\t\tspeeds[AfSpeedFast].read(*fast);\n \t} else\n \t\tLOG(RPiAf, Warning) << \"No speeds defined\";\n \n@@ -138,8 +134,8 @@ int Af::CfgParams::read(const libcamera::YamlObject ¶ms)\n \treadNumber<uint32_t>(confClip, params, \"conf_clip\");\n \treadNumber<uint32_t>(skipFrames, params, \"skip_frames\");\n \n-\tif (params.contains(\"map\"))\n-\t\tmap = params[\"map\"].get<ipa::Pwl>(ipa::Pwl{});\n+\tif (auto *m = params.find(\"map\"))\n+\t\tmap = m->get<ipa::Pwl>(ipa::Pwl{});\n \telse\n \t\tLOG(RPiAf, Warning) << \"No map defined\";\n \ndiff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp\nindex c48fdf15..5d924ebf 100644\n--- a/src/ipa/rpi/controller/rpi/agc.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc.cpp\n@@ -37,18 +37,18 @@ int Agc::read(const libcamera::YamlObject ¶ms)\n \t * When there is only a single channel we can read the old style syntax.\n \t * Otherwise we expect a \"channels\" keyword followed by a list of configurations.\n \t */\n-\tif (!params.contains(\"channels\")) {\n+\tauto *channels = params.find(\"channels\");\n+\tif (!channels) {\n \t\tLOG(RPiAgc, Debug) << \"Single channel only\";\n \t\tchannelTotalExposures_.resize(1, 0s);\n \t\tchannelData_.emplace_back();\n \t\treturn channelData_.back().channel.read(params, getHardwareConfig());\n \t}\n \n-\tconst auto &channels = params[\"channels\"].asList();\n-\tfor (auto ch = channels.begin(); ch != channels.end(); ch++) {\n+\tfor (const auto &ch : channels->asList()) {\n \t\tLOG(RPiAgc, Debug) << \"Read AGC channel\";\n \t\tchannelData_.emplace_back();\n-\t\tint ret = channelData_.back().channel.read(*ch, getHardwareConfig());\n+\t\tint ret = channelData_.back().channel.read(ch, getHardwareConfig());\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex 79c45973..50b9efd2 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -235,8 +235,8 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms)\n \tif (ret)\n \t\treturn ret;\n \n-\tif (params.contains(\"channel_constraints\")) {\n-\t\tret = readChannelConstraints(channelConstraints, params[\"channel_constraints\"]);\n+\tif (auto *cc = params.find(\"channel_constraints\")) {\n+\t\tret = readChannelConstraints(channelConstraints, *cc);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\ndiff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp\nindex 21edb819..5a1a702b 100644\n--- a/src/ipa/rpi/controller/rpi/alsc.cpp\n+++ b/src/ipa/rpi/controller/rpi/alsc.cpp\n@@ -104,9 +104,9 @@ static int readCalibrations(std::vector<AlscCalibration> &calibrations,\n \t\t\t const libcamera::YamlObject ¶ms,\n \t\t\t std::string const &name, const Size &size)\n {\n-\tif (params.contains(name)) {\n+\tif (auto *param = params.find(name)) {\n \t\tdouble lastCt = 0;\n-\t\tfor (const auto &p : params[name].asList()) {\n+\t\tfor (const auto &p : param->asList()) {\n \t\t\tauto value = p[\"ct\"].get<double>();\n \t\t\tif (!value)\n \t\t\t\treturn -EINVAL;\n@@ -163,10 +163,10 @@ int Alsc::read(const libcamera::YamlObject ¶ms)\n \tconfig_.luminanceLut.resize(config_.tableSize, 1.0);\n \tint ret = 0;\n \n-\tif (params.contains(\"corner_strength\"))\n+\tif (params.find(\"corner_strength\"))\n \t\tret = generateLut(config_.luminanceLut, params);\n-\telse if (params.contains(\"luminance_lut\"))\n-\t\tret = readLut(config_.luminanceLut, params[\"luminance_lut\"]);\n+\telse if (auto *ll = params.find(\"luminance_lut\"))\n+\t\tret = readLut(config_.luminanceLut, *ll);\n \telse\n \t\tLOG(RPiAlsc, Warning)\n \t\t\t<< \"no luminance table - assume unity everywhere\";\ndiff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\nindex c277a176..2e6e295c 100644\n--- a/src/ipa/rpi/controller/rpi/awb.cpp\n+++ b/src/ipa/rpi/controller/rpi/awb.cpp\n@@ -102,8 +102,8 @@ int AwbConfig::read(const libcamera::YamlObject ¶ms)\n \tconvergenceFrames = params[\"convergence_frames\"].get<unsigned int>(3);\n \tspeed = params[\"speed\"].get<double>(0.05);\n \n-\tif (params.contains(\"ct_curve\")) {\n-\t\tret = readCtCurve(ctR, ctB, params[\"ct_curve\"]);\n+\tif (auto *ct_curve = params.find(\"ct_curve\")) {\n+\t\tret = readCtCurve(ctR, ctB, *ct_curve);\n \t\tif (ret)\n \t\t\treturn ret;\n \t\t/* We will want the inverse functions of these too. */\n@@ -111,8 +111,8 @@ int AwbConfig::read(const libcamera::YamlObject ¶ms)\n \t\tctBInverse = ctB.inverse().first;\n \t}\n \n-\tif (params.contains(\"priors\")) {\n-\t\tfor (const auto &p : params[\"priors\"].asList()) {\n+\tif (auto *ps = params.find(\"priors\")) {\n+\t\tfor (const auto &p : ps->asList()) {\n \t\t\tAwbPrior prior;\n \t\t\tret = prior.read(p);\n \t\t\tif (ret)\n@@ -128,8 +128,8 @@ int AwbConfig::read(const libcamera::YamlObject ¶ms)\n \t\t\treturn -EINVAL;\n \t\t}\n \t}\n-\tif (params.contains(\"modes\")) {\n-\t\tfor (const auto &[key, value] : params[\"modes\"].asDict()) {\n+\tif (auto *ms = params.find(\"modes\")) {\n+\t\tfor (const auto &[key, value] : ms->asDict()) {\n \t\t\tret = modes[key].read(value);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\ndiff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp\nindex 8607f152..5616e5f4 100644\n--- a/src/ipa/rpi/controller/rpi/ccm.cpp\n+++ b/src/ipa/rpi/controller/rpi/ccm.cpp\n@@ -41,8 +41,8 @@ char const *Ccm::name() const\n \n int Ccm::read(const libcamera::YamlObject ¶ms)\n {\n-\tif (params.contains(\"saturation\")) {\n-\t\tconfig_.saturation = params[\"saturation\"].get<ipa::Pwl>(ipa::Pwl{});\n+\tif (auto *s = params.find(\"saturation\")) {\n+\t\tconfig_.saturation = s->get<ipa::Pwl>(ipa::Pwl{});\n \t\tif (config_.saturation.empty())\n \t\t\treturn -EINVAL;\n \t}\ndiff --git a/src/ipa/rpi/controller/rpi/geq.cpp b/src/ipa/rpi/controller/rpi/geq.cpp\nindex 40e7191b..6935f726 100644\n--- a/src/ipa/rpi/controller/rpi/geq.cpp\n+++ b/src/ipa/rpi/controller/rpi/geq.cpp\n@@ -43,8 +43,8 @@ int Geq::read(const libcamera::YamlObject ¶ms)\n \t\treturn -EINVAL;\n \t}\n \n-\tif (params.contains(\"strength\")) {\n-\t\tconfig_.strength = params[\"strength\"].get<ipa::Pwl>(ipa::Pwl{});\n+\tif (auto *strength = params.find(\"strength\")) {\n+\t\tconfig_.strength = strength->get<ipa::Pwl>(ipa::Pwl{});\n \t\tif (config_.strength.empty())\n \t\t\treturn -EINVAL;\n \t}\ndiff --git a/src/ipa/rpi/controller/rpi/hdr.cpp b/src/ipa/rpi/controller/rpi/hdr.cpp\nindex f3da8291..20b1ff4b 100644\n--- a/src/ipa/rpi/controller/rpi/hdr.cpp\n+++ b/src/ipa/rpi/controller/rpi/hdr.cpp\n@@ -27,9 +27,10 @@ void HdrConfig::read(const libcamera::YamlObject ¶ms, const std::string &mod\n {\n \tname = modeName;\n \n-\tif (!params.contains(\"cadence\"))\n+\tauto *c = params.find(\"cadence\");\n+\tif (!c)\n \t\tLOG(RPiHdr, Fatal) << \"No cadence for HDR mode \" << name;\n-\tcadence = params[\"cadence\"].getList<unsigned int>().value();\n+\tcadence = c->getList<unsigned int>().value();\n \tif (cadence.empty())\n \t\tLOG(RPiHdr, Fatal) << \"Empty cadence in HDR mode \" << name;\n \n@@ -41,10 +42,10 @@ void HdrConfig::read(const libcamera::YamlObject ¶ms, const std::string &mod\n \t\tchannelMap[v.get<unsigned int>().value()] = k;\n \n \t/* Lens shading related parameters. */\n-\tif (params.contains(\"spatial_gain_curve\")) {\n-\t\tspatialGainCurve = params[\"spatial_gain_curve\"].get<ipa::Pwl>(ipa::Pwl{});\n-\t} else if (params.contains(\"spatial_gain\")) {\n-\t\tdouble spatialGain = params[\"spatial_gain\"].get<double>(2.0);\n+\tif (auto *sgc = params.find(\"spatial_gain_curve\")) {\n+\t\tspatialGainCurve = sgc->get<ipa::Pwl>(ipa::Pwl{});\n+\t} else if (auto *sg = params.find(\"spatial_gain\")) {\n+\t\tdouble spatialGain = sg->get<double>(2.0);\n \t\tspatialGainCurve.append(0.0, spatialGain);\n \t\tspatialGainCurve.append(0.01, spatialGain);\n \t\tspatialGainCurve.append(0.06, 1.0); /* maybe make this programmable? */\n@@ -68,24 +69,24 @@ void HdrConfig::read(const libcamera::YamlObject ¶ms, const std::string &mod\n \tif (tonemapEnable)\n \t\ttonemap = params[\"tonemap\"].get<ipa::Pwl>(ipa::Pwl{});\n \tspeed = params[\"speed\"].get<double>(1.0);\n-\tif (params.contains(\"hi_quantile_targets\")) {\n-\t\thiQuantileTargets = params[\"hi_quantile_targets\"].getList<double>().value();\n+\tif (auto *hqt = params.find(\"hi_quantile_targets\")) {\n+\t\thiQuantileTargets = hqt->getList<double>().value();\n \t\tif (hiQuantileTargets.empty() || hiQuantileTargets.size() % 2)\n \t\t\tLOG(RPiHdr, Fatal) << \"hi_quantile_targets much be even and non-empty\";\n \t} else\n \t\thiQuantileTargets = { 0.95, 0.65, 0.5, 0.28, 0.3, 0.25 };\n \thiQuantileMaxGain = params[\"hi_quantile_max_gain\"].get<double>(1.6);\n-\tif (params.contains(\"quantile_targets\")) {\n-\t\tquantileTargets = params[\"quantile_targets\"].getList<double>().value();\n+\tif (auto *qt = params.find(\"quantile_targets\")) {\n+\t\tquantileTargets = qt->getList<double>().value();\n \t\tif (quantileTargets.empty() || quantileTargets.size() % 2)\n \t\t\tLOG(RPiHdr, Fatal) << \"quantile_targets much be even and non-empty\";\n \t} else\n \t\tquantileTargets = { 0.2, 0.03, 1.0, 0.15 };\n \tpowerMin = params[\"power_min\"].get<double>(0.65);\n \tpowerMax = params[\"power_max\"].get<double>(1.0);\n-\tif (params.contains(\"contrast_adjustments\")) {\n-\t\tcontrastAdjustments = params[\"contrast_adjustments\"].getList<double>().value();\n-\t} else\n+\tif (auto *ca = params.find(\"contrast_adjustments\"))\n+\t\tcontrastAdjustments = ca->getList<double>().value();\n+\telse\n \t\tcontrastAdjustments = { 0.5, 0.75 };\n \n \t/* Read any stitch parameters. */\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex e1b6d3af..ca3fe487 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -114,12 +114,13 @@ int IPASoftSimple::init(const IPASettings &settings,\n \tunsigned int version = (*data)[\"version\"].get<uint32_t>(0);\n \tLOG(IPASoft, Debug) << \"Tuning file version \" << version;\n \n-\tif (!data->contains(\"algorithms\")) {\n+\tauto *algos = data->find(\"algorithms\");\n+\tif (!algos) {\n \t\tLOG(IPASoft, Error) << \"Tuning file doesn't contain algorithms\";\n \t\treturn -EINVAL;\n \t}\n \n-\tint ret = createAlgorithms(context_, (*data)[\"algorithms\"]);\n+\tint ret = createAlgorithms(context_, *algos);\n \tif (ret)\n \t\treturn ret;\n \n", "prefixes": [ "v1", "2/3" ] }