From patchwork Thu Jun 13 01:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20272 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 DFD63C3237 for ; Thu, 13 Jun 2024 01:40:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 04C386548E; Thu, 13 Jun 2024 03:40:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YP8tqTsz"; 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 1B7E361A1C for ; Thu, 13 Jun 2024 03:40:05 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 10ADDBEB; Thu, 13 Jun 2024 03:39:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718242791; bh=jOKiP6BODrVaxp0GvsbHsAmdqlc0v+Z48biOThgOhFk=; h=From:To:Cc:Subject:Date:From; b=YP8tqTszNFOs1HlPG/42ADhPz2yeFR106wL0qWUn4kaoH61e7MnJUruyPkhcA8SJB xnFazdU8vmFA6QjVXF5HDiETDwZDWlqhQ80J5TlGeftH05MYecWnKOJuzb1J4Krpqd vKhu3MUXklq0Z5RWxaPP78ooPbKARrEPV0UuCjvA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , David Plowman , Naushir Patuck Subject: [PATCH 00/11] ipa: libipa: Vector and Pwl improvements Date: Thu, 13 Jun 2024 04:39:33 +0300 Message-ID: <20240613013944.23344-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 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" Hello, This patch series tries to improve the ipa::Vector and ipa::Pwl classes that have been recently merged. They started from an attempt to replace the readYaml() member of those two classes with a better (in my opinion) alternative, and grew beyond that. The main change in this series is the removal of the readYaml() function from the Vector and Pwl classes. The rationale for this is that the two classes are generic math objects, and should not be tied to a particular serialization mechanism. For the same reason, we have currently no Size::readYaml() function, but a specialization of YamlObject::get() for the Size type. Copying the implementation of YamlObject::get() for the Size type would have been the most straightforward option, but isn't an option as the Vector and Pwl classes, unlike the Size class, are part of libipa, while YamlObject is part of libcamera. libipa links to libcamera, but libcamera doesn't link to libipa. As the YamlObject::get() function is a template function with support for different data types implemented through template specializations, I decided to try and implement specializations for the Vector and Pwl classes inside libipa. This was blocked by std::enable_if_t guards in YamlObject::get(), which are removed by patch 01/11. The second issue is that specializing the function template for another template type (e.g. ipa::Vector) is a partial specialization of a function, which is not allowed by C++. Only partial specializations of classes and variables are supported by the language. Patch 02/11 works around that issue by delegating the YamlObject::get() function template to a new YamlObject::Getter structure template, which implements a non-template get() function. With that in place, a specialization of the getter for ipa::Vector is implemented in patch 03/11. The ipa::Vector::readYaml() is then dropped in patch 04/11 without further ado, as it turned out the function wasn't used. I would be fine dropping patch 03/11 until reading a Vector from YAML data becomes needed if preferred. Patches 05/11 to 08/11 follow with miscellaneous cleanups and enhancements for the ipa::Pwl class, in preparation of patch 09/11 that adds a getter specialization for ipa::Pwl. Patch 10/11 switches the users of the ipa::Pwl::readYaml() function to YamlObject::get() (unlike ipa::Vector, we read ipa::Pwl instances from YAML data). This showcases usage of the new API. Finally, patch 11/11 drops the ipa::Pwl::readYaml() function. Beside thinking that C++ and/or myself are crazy, does anyone have an opinion ? Laurent Pinchart (11): libcamera: yaml_parser: Drop std::enable_if_t guards for get() function libcamera: yaml_parser: Delegate YamlObject::get() to helper structure ipa: libipa: vector: Specialize YamlObject getter ipa: libipa: vector: Drop readYaml() function ipa: libipa: pwl: Suffix \param with direction ipa: libipa: pwl: Make the empty() function inline ipa: libipa: pwl: Add a size() function ipa: libipa: pwl: Add a constructor that moves a Point vector ipa: libipa: pwl: Specialize YamlObject getter ipa: rpi: controller: Replace Pwl::readYaml() with YamlObject::get() ipa: libipa: pwl: Drop readYaml() function include/libcamera/internal/yaml_parser.h | 27 ++--- src/ipa/libipa/pwl.cpp | 132 +++++++++++---------- src/ipa/libipa/pwl.h | 6 +- src/ipa/libipa/vector.cpp | 30 +++-- src/ipa/libipa/vector.h | 48 ++++---- src/ipa/rpi/controller/rpi/af.cpp | 2 +- src/ipa/rpi/controller/rpi/agc_channel.cpp | 9 +- src/ipa/rpi/controller/rpi/awb.cpp | 3 +- src/ipa/rpi/controller/rpi/ccm.cpp | 6 +- src/ipa/rpi/controller/rpi/contrast.cpp | 4 +- src/ipa/rpi/controller/rpi/geq.cpp | 6 +- src/ipa/rpi/controller/rpi/hdr.cpp | 4 +- src/ipa/rpi/controller/rpi/tonemap.cpp | 2 +- src/libcamera/yaml_parser.cpp | 78 ++++++------ 14 files changed, 193 insertions(+), 164 deletions(-) base-commit: 20b8538a197c45597eecf5c7a51058263e816eb9