{"id":20275,"url":"https://patchwork.libcamera.org/api/patches/20275/?format=json","web_url":"https://patchwork.libcamera.org/patch/20275/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240613013944.23344-4-laurent.pinchart@ideasonboard.com>","date":"2024-06-13T01:39:36","name":"[03/11] ipa: libipa: vector: Specialize YamlObject getter","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"e1a85d4c2befd9ba3c97a26e1f6ed0e968be2f9a","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20275/mbox/","series":[{"id":4386,"url":"https://patchwork.libcamera.org/api/series/4386/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4386","date":"2024-06-13T01:39:33","name":"ipa: libipa: Vector and Pwl improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/4386/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20275/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20275/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 8A2DBC3293\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Jun 2024 01:40:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 112F965493;\n\tThu, 13 Jun 2024 03:40:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E6DB06548C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jun 2024 03:40:08 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2DBD7E39;\n\tThu, 13 Jun 2024 03:39:55 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sxLc39Lo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1718242795;\n\tbh=vEHaev4LalzGsWPM+nfMRN0TeBcAy0Ra1ZUNuwKQxo4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sxLc39LoSC5da49TATx8c+iU3+cdfv5ONSAeoyzeI5BDBL3l222QlxSrFyHTE2uMk\n\tZhUSyMOlWVVA5irChhI2gCywZ5RHIm1/PjdmE9iKkpdba4gMCWr4l0Nvvu494cHwKB\n\tbmA0sczb/Wvro8lg/SbpqBBKh7Q5uvYlTPJG4Dm4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH 03/11] ipa: libipa: vector: Specialize YamlObject getter","Date":"Thu, 13 Jun 2024 04:39:36 +0300","Message-ID":"<20240613013944.23344-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.44.2","In-Reply-To":"<20240613013944.23344-1-laurent.pinchart@ideasonboard.com>","References":"<20240613013944.23344-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"Implement a specialization of the YamlObject::Getter structure to\nsupport deserializing ipa::Vector objects from YAML data.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/vector.cpp | 17 +++++++++++++++++\n src/ipa/libipa/vector.h   | 25 +++++++++++++++++++++++++\n 2 files changed, 42 insertions(+)","diff":"diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\nindex 5de4ae48b419..4e987d82fa70 100644\n--- a/src/ipa/libipa/vector.cpp\n+++ b/src/ipa/libipa/vector.cpp\n@@ -148,6 +148,23 @@ namespace ipa {\n  * \\return True if the two vectors are not equal, false otherwise\n  */\n \n+#ifndef __DOXYGEN__\n+bool vectorValidateYaml(const YamlObject &obj, unsigned int size)\n+{\n+\tif (!obj.isList())\n+\t\treturn false;\n+\n+\tif (obj.size() != size) {\n+\t\tLOG(Vector, Error)\n+\t\t\t<< \"Wrong number of values in YAML vector: expected \"\n+\t\t\t<< size << \", got \" << obj.size();\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+#endif /* __DOXYGEN__ */\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex 7c444363d4bb..4b2fe581ecc2 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -180,6 +180,10 @@ bool operator!=(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs)\n \treturn !(lhs == rhs);\n }\n \n+#ifndef __DOXYGEN__\n+bool vectorValidateYaml(const YamlObject &obj, unsigned int size);\n+#endif /* __DOXYGEN__ */\n+\n } /* namespace ipa */\n \n #ifndef __DOXYGEN__\n@@ -195,6 +199,27 @@ std::ostream &operator<<(std::ostream &out, const ipa::Vector<T, Rows> &v)\n \n \treturn out;\n }\n+\n+template<typename T, unsigned int Rows>\n+struct YamlObject::Getter<ipa::Vector<T, Rows>> {\n+\tstd::optional<ipa::Vector<T, Rows>> get(const YamlObject &obj) const\n+\t{\n+\t\tif (!ipa::vectorValidateYaml(obj, Rows))\n+\t\t\treturn std::nullopt;\n+\n+\t\tipa::Vector<T, Rows> vector;\n+\n+\t\tunsigned int i = 0;\n+\t\tfor (const YamlObject &entry : obj.asList()) {\n+\t\t\tconst auto value = entry.get<T>();\n+\t\t\tif (!value)\n+\t\t\t\treturn std::nullopt;\n+\t\t\tvector[i++] = *value;\n+\t\t}\n+\n+\t\treturn vector;\n+\t}\n+};\n #endif /* __DOXYGEN__ */\n \n } /* namespace libcamera */\n","prefixes":["03/11"]}