From patchwork Tue Oct 14 14:24:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24643 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 5C476BE080 for ; Tue, 14 Oct 2025 14:24:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0EA9060605; Tue, 14 Oct 2025 16:24:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="X9MSVqqc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5101660609 for ; Tue, 14 Oct 2025 16:24:40 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:61fb:8e55:ff1e:be62]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id D2241104D; Tue, 14 Oct 2025 16:23:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760451781; bh=lgIAzDG0NRsV3A0ed7UTU2hFjwNgg3Gr1KofJ+C/whw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9MSVqqcsPcPGiniOpk5MpIu2P0/tSVuwamwRl2CvVUxaZUKzyqHButqBhjw4rBQP 201v7tZyTKgRI4HlSF9TkFABCsHr0otHqjFp/xLemIZtI8MjiWtTWuhDrj6TnLF/u+ 1aIXNwSJaV7i9fjdUwiPmIGPr89EIzxND3tUcZow= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 3/4] ipa: libipa: pwl: Add construction from initializer_list Date: Tue, 14 Oct 2025 16:24:18 +0200 Message-ID: <20251014142427.3107490-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251014142427.3107490-1-stefan.klug@ideasonboard.com> References: <20251014142427.3107490-1-stefan.klug@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" In the tuning files it is possible to construct the PWL from a linear list of numbers. Add a initializer_list based constructor to replicate similar style in C++ code. An initializer_list is preferred to a Span based constructor because the Span makes the static construction cumbersome ( {{{ 1.0, 2.0 }}} vs { 1.0, 2.0 } ) and initialization is the only use case at the moment. Signed-off-by: Stefan Klug --- src/ipa/libipa/pwl.cpp | 19 +++++++++++++++++++ src/ipa/libipa/pwl.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 1858ab37b101..501ac79ea8b5 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -122,6 +122,25 @@ Pwl::Pwl(std::vector &&points) { } +/** + * \brief Construct a piecewise linear function from a initializer list + * \param[in] data initializer list of doubles + * + * This constructor takes a even number of doubles and treats them as + * x0,y0,x1,y1,...,xn,yn coordinates for the PWL. + */ +Pwl::Pwl(std::initializer_list data) +{ + ASSERT((data.size() % 2) == 0); + + auto iter = data.begin(); + while (iter != data.end()) { + double x = *iter++; + double y = *iter++; + append(x, y); + } +} + /** * \brief Append a point to the end of the piecewise linear function * \param[in] x x-coordinate of the point to add to the piecewise linear function diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h index add20b5867af..b82b17317a5e 100644 --- a/src/ipa/libipa/pwl.h +++ b/src/ipa/libipa/pwl.h @@ -45,6 +45,7 @@ public: Pwl(); Pwl(const std::vector &points); Pwl(std::vector &&points); + Pwl(std::initializer_list data); void append(double x, double y, double eps = 1e-6);