From patchwork Tue Jan 13 00:07:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 25735 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 AA823C323E for ; Tue, 13 Jan 2026 00:08:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BC9C61FDC; Tue, 13 Jan 2026 01:08:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LOt/c8mS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F8C461FD9 for ; Tue, 13 Jan 2026 01:08:52 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi [81.175.209.152]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id E508E66B for ; Tue, 13 Jan 2026 01:08:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768262907; bh=mIZ+S2Qh0dCnCCxu+ZOVd5YJhWRivKWsAAqIijopOOc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LOt/c8mSxVNtCuhoE1UPC8LPqCyfC93umPav2No253n0bsxtL0UJkQD/892h/qA4Z ZMHrJ+3iKV5/TYLgSzRLd6nlHAI6+tJXuMS5TDp3k4pGlw5UKJejdmCtdC4+y/bU4m XAYb3hj6njPiUP0A6Ep1nj3ETi/zDa0IemF1kz0s= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 15/36] libcamera: yaml_parser: Move Size handling to geometry.cpp Date: Tue, 13 Jan 2026 02:07:47 +0200 Message-ID: <20260113000808.15395-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260113000808.15395-1-laurent.pinchart@ideasonboard.com> References: <20260113000808.15395-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 --- include/libcamera/internal/yaml_parser.h | 2 -- src/ipa/libipa/lsc_polynomial.h | 2 ++ src/libcamera/geometry.cpp | 29 ++++++++++++++++++++++++ src/libcamera/yaml_parser.cpp | 25 +------------------- test/yaml-parser.cpp | 2 ++ 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h index 02e39e4cd7a1..7b6d16de1a04 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 fa1a487a13dc..46c1fb9bce7e 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::enable_if_t< std::is_same_v || @@ -316,8 +295,7 @@ struct YamlObject::Accessor, std::enable_if_t< std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || - std::is_same_v>> + std::is_same_v>> { std::optional> get(const YamlObject &obj) const { @@ -348,7 +326,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"