From patchwork Tue Apr 7 15:34:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 26455 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 42C92C3300 for ; Tue, 7 Apr 2026 15:34:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8545162DD4; Tue, 7 Apr 2026 17:34:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="M4438fYb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA59B62DE5 for ; Tue, 7 Apr 2026 17:34:48 +0200 (CEST) Received: from killaraus.ideasonboard.com (2001-14ba-703d-e500--2a1.rev.dnainternet.fi [IPv6:2001:14ba:703d:e500::2a1]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 109C498A for ; Tue, 7 Apr 2026 17:33:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775576001; bh=KgSje6QVWRqdn0N+xzAWeZ1L8NrPB2FXHp79Rqrq7mg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M4438fYbDV82H/q4IpMhRdbFmD4rW8uAkI1cgfjz0CgaegxaBsK0Puy1plCWpq2gT y8SfWKzXTC1ER9I83eU5v6Pghd/2kWVCbGho4JgJEWiFWWmCOzf/q6el5uty0mfQcf NcpMsGVxaMSL4swZgPflEc7f0/A/kk92p58yZghc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 15/42] libcamera: yaml_parser: Move Size handling to geometry.cpp Date: Tue, 7 Apr 2026 18:34:00 +0300 Message-ID: <20260407153427.1825999-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260407153427.1825999-1-laurent.pinchart@ideasonboard.com> References: <20260407153427.1825999-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The YamlObject::Accessor structure is designed to extend the YamlObject class with new getter and setter types without modifying yaml_parser.cpp. This feature is used for various libcamera classes, while standard C++ types are handled in yaml_parser.cpp. The Size class is an outlier: it is a libcamera class, but is handled in yaml_parser.cpp. Move it to geometry.cpp. Drop the std::vector specialization as it is currently unused. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- include/libcamera/internal/yaml_parser.h | 2 -- src/ipa/libipa/lsc_polynomial.h | 2 ++ src/libcamera/geometry.cpp | 29 ++++++++++++++++++++++++ src/libcamera/yaml_parser.cpp | 22 ------------------ test/yaml-parser.cpp | 2 ++ 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h index c41397df67ab..7707e7469aca 100644 --- a/include/libcamera/internal/yaml_parser.h +++ b/include/libcamera/internal/yaml_parser.h @@ -17,8 +17,6 @@ #include -#include - namespace libcamera { class File; diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h index df3a0d4b39c4..c71f215de3fc 100644 --- a/src/ipa/libipa/lsc_polynomial.h +++ b/src/ipa/libipa/lsc_polynomial.h @@ -14,6 +14,8 @@ #include #include +#include + #include "libcamera/internal/yaml_parser.h" namespace libcamera { diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 2763967a6e57..2e8e9e33ea78 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -12,6 +12,8 @@ #include +#include "libcamera/internal/yaml_parser.h" + /** * \file geometry.h * \brief Data structures related to geometric objects @@ -924,4 +926,31 @@ std::ostream &operator<<(std::ostream &out, const Rectangle &r) return out; } +#ifndef __DOXYGEN__ +/* + * The YAML data shall be a list of two numerical values containing the x and y + * coordinates, in that order. + */ +template<> +std::optional +YamlObject::Accessor::get(const YamlObject &obj) const +{ + if (obj.type_ != Type::List) + return std::nullopt; + + if (obj.list_.size() != 2) + return std::nullopt; + + auto width = obj.list_[0].value->get(); + if (!width) + return std::nullopt; + + auto height = obj.list_[1].value->get(); + if (!height) + return std::nullopt; + + return Size(*width, *height); +} +#endif /* __DOXYGEN__ */ + } /* namespace libcamera */ diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index 6caacc3111c4..bf098360191b 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -284,27 +284,6 @@ void YamlObject::Accessor::set(YamlObject &obj, std::string value) obj.value_ = std::move(value); } -template<> -std::optional -YamlObject::Accessor::get(const YamlObject &obj) const -{ - if (obj.type_ != Type::List) - return std::nullopt; - - if (obj.list_.size() != 2) - return std::nullopt; - - auto width = obj.list_[0].value->get(); - if (!width) - return std::nullopt; - - auto height = obj.list_[1].value->get(); - if (!height) - return std::nullopt; - - return Size(*width, *height); -} - template struct YamlObject::Accessor> { std::optional> get(const YamlObject &obj) const @@ -336,7 +315,6 @@ template struct YamlObject::Accessor>; template struct YamlObject::Accessor>; template struct YamlObject::Accessor>; template struct YamlObject::Accessor>; -template struct YamlObject::Accessor>; #endif /* __DOXYGEN__ */ /** diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index 566401afcab6..01e734d23059 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include "libcamera/internal/yaml_parser.h" #include "test.h"