[{"id":37617,"web_url":"https://patchwork.libcamera.org/comment/37617/","msgid":"<20af35a1-2513-4e12-8368-05adb8c0f1b0@ideasonboard.com>","date":"2026-01-13T16:33:22","subject":"Re: [PATCH 15/36] libcamera: yaml_parser: Move Size handling to\n\tgeometry.cpp","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 13. 1:07 keltezéssel, Laurent Pinchart írta:\n> The YamlObject::Accessor structure is designed to extend the YamlObject\n> class with new getter and setter types without modifying\n> yaml_parser.cpp. This feature is used for various libcamera classes,\n> while standard C++ types are handled in yaml_parser.cpp.\n> \n> The Size class is an outlier: it is a libcamera class, but is handled in\n> yaml_parser.cpp. Move it to geometry.cpp. Drop the std::vector<Size>\n> specialization as it is currently unused.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n\nLooks ok.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   include/libcamera/internal/yaml_parser.h |  2 --\n>   src/ipa/libipa/lsc_polynomial.h          |  2 ++\n>   src/libcamera/geometry.cpp               | 29 ++++++++++++++++++++++++\n>   src/libcamera/yaml_parser.cpp            | 25 +-------------------\n>   test/yaml-parser.cpp                     |  2 ++\n>   5 files changed, 34 insertions(+), 26 deletions(-)\n> \n> diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\n> index 02e39e4cd7a1..7b6d16de1a04 100644\n> --- a/include/libcamera/internal/yaml_parser.h\n> +++ b/include/libcamera/internal/yaml_parser.h\n> @@ -17,8 +17,6 @@\n>   \n>   #include <libcamera/base/class.h>\n>   \n> -#include <libcamera/geometry.h>\n> -\n>   namespace libcamera {\n>   \n>   class File;\n> diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h\n> index df3a0d4b39c4..c71f215de3fc 100644\n> --- a/src/ipa/libipa/lsc_polynomial.h\n> +++ b/src/ipa/libipa/lsc_polynomial.h\n> @@ -14,6 +14,8 @@\n>   #include <libcamera/base/log.h>\n>   #include <libcamera/base/span.h>\n>   \n> +#include <libcamera/geometry.h>\n> +\n>   #include \"libcamera/internal/yaml_parser.h\"\n>   \n>   namespace libcamera {\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 2763967a6e57..2e8e9e33ea78 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -12,6 +12,8 @@\n>   \n>   #include <libcamera/base/log.h>\n>   \n> +#include \"libcamera/internal/yaml_parser.h\"\n> +\n>   /**\n>    * \\file geometry.h\n>    * \\brief Data structures related to geometric objects\n> @@ -924,4 +926,31 @@ std::ostream &operator<<(std::ostream &out, const Rectangle &r)\n>   \treturn out;\n>   }\n>   \n> +#ifndef __DOXYGEN__\n> +/*\n> + * The YAML data shall be a list of two numerical values containing the x and y\n> + * coordinates, in that order.\n> + */\n> +template<>\n> +std::optional<Size>\n> +YamlObject::Accessor<Size>::get(const YamlObject &obj) const\n> +{\n> +\tif (obj.type_ != Type::List)\n> +\t\treturn std::nullopt;\n> +\n> +\tif (obj.list_.size() != 2)\n> +\t\treturn std::nullopt;\n> +\n> +\tauto width = obj.list_[0].value->get<uint32_t>();\n> +\tif (!width)\n> +\t\treturn std::nullopt;\n> +\n> +\tauto height = obj.list_[1].value->get<uint32_t>();\n> +\tif (!height)\n> +\t\treturn std::nullopt;\n> +\n> +\treturn Size(*width, *height);\n> +}\n> +#endif /* __DOXYGEN__ */\n> +\n>   } /* namespace libcamera */\n> diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\n> index fa1a487a13dc..46c1fb9bce7e 100644\n> --- a/src/libcamera/yaml_parser.cpp\n> +++ b/src/libcamera/yaml_parser.cpp\n> @@ -284,27 +284,6 @@ void YamlObject::Accessor<std::string>::set(YamlObject &obj, std::string value)\n>   \tobj.value_ = std::move(value);\n>   }\n>   \n> -template<>\n> -std::optional<Size>\n> -YamlObject::Accessor<Size>::get(const YamlObject &obj) const\n> -{\n> -\tif (obj.type_ != Type::List)\n> -\t\treturn std::nullopt;\n> -\n> -\tif (obj.list_.size() != 2)\n> -\t\treturn std::nullopt;\n> -\n> -\tauto width = obj.list_[0].value->get<uint32_t>();\n> -\tif (!width)\n> -\t\treturn std::nullopt;\n> -\n> -\tauto height = obj.list_[1].value->get<uint32_t>();\n> -\tif (!height)\n> -\t\treturn std::nullopt;\n> -\n> -\treturn Size(*width, *height);\n> -}\n> -\n>   template<typename T>\n>   struct YamlObject::Accessor<std::vector<T>, std::enable_if_t<\n>   \tstd::is_same_v<bool, T> ||\n> @@ -316,8 +295,7 @@ struct YamlObject::Accessor<std::vector<T>, std::enable_if_t<\n>   \tstd::is_same_v<uint16_t, T> ||\n>   \tstd::is_same_v<int32_t, T> ||\n>   \tstd::is_same_v<uint32_t, T> ||\n> -\tstd::is_same_v<std::string, T> ||\n> -\tstd::is_same_v<Size, T>>>\n> +\tstd::is_same_v<std::string, T>>>\n>   {\n>   \tstd::optional<std::vector<T>> get(const YamlObject &obj) const\n>   \t{\n> @@ -348,7 +326,6 @@ template struct YamlObject::Accessor<std::vector<uint16_t>>;\n>   template struct YamlObject::Accessor<std::vector<int32_t>>;\n>   template struct YamlObject::Accessor<std::vector<uint32_t>>;\n>   template struct YamlObject::Accessor<std::vector<std::string>>;\n> -template struct YamlObject::Accessor<std::vector<Size>>;\n>   #endif /* __DOXYGEN__ */\n>   \n>   /**\n> diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> index 566401afcab6..01e734d23059 100644\n> --- a/test/yaml-parser.cpp\n> +++ b/test/yaml-parser.cpp\n> @@ -14,6 +14,8 @@\n>   #include <libcamera/base/file.h>\n>   #include <libcamera/base/utils.h>\n>   \n> +#include <libcamera/geometry.h>\n> +\n>   #include \"libcamera/internal/yaml_parser.h\"\n>   \n>   #include \"test.h\"","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 A66B1BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 16:33:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CEAB061FC3;\n\tTue, 13 Jan 2026 17:33:27 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61F9D61FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 17:33:26 +0100 (CET)","from [192.168.33.30] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 35E6250A;\n\tTue, 13 Jan 2026 17:33:00 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gHrPEQMT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768321980;\n\tbh=QEYjVsUx/p7RE+UEUUenpYf+0JpDUyiJakh8KU+xFbU=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=gHrPEQMT/uk/JLLyR91WIwxl+F0CXOomw1oGI1Kkn5Nv16hn/kFP25VtbPRo+XZFk\n\tRdeObutagppHKAZnY+D5w54FO8hX1tdLusgUwZzFL1KqkeYZXTXp0kPZaR9i9miBsR\n\tCwoVmKtVvflSqW0kWx+JHaAZZFBQQqsc+qAEVPnI=","Message-ID":"<20af35a1-2513-4e12-8368-05adb8c0f1b0@ideasonboard.com>","Date":"Tue, 13 Jan 2026 17:33:22 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 15/36] libcamera: yaml_parser: Move Size handling to\n\tgeometry.cpp","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>\n\t<20260113000808.15395-16-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260113000808.15395-16-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]