From patchwork Fri Jun 13 10:09:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23560 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 5B980BDE6B for ; Fri, 13 Jun 2025 10:10:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 16BB968DC3; Fri, 13 Jun 2025 12:10:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BchVZ5Ls"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E081968DBD for ; Fri, 13 Jun 2025 12:10:15 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:37bc:6352:9b26:2f94]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 8C40416C5; Fri, 13 Jun 2025 12:10:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1749809406; bh=I2A0lR6CeaffCi2hrOyhn/4aS2n5HD5H4EIKhhY3lEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BchVZ5LsF+4+pNTtRQRLFQoBvx3jH+7i8LvYQKm+NqzxHA3U/UAyVJm2hq1v0dvHg DkFQLLG5Izxtz6wSyRn8HzFWfgqw3LdoycZw4Q/+YjtermYiAHdtbSoDyv9QTw1okN ccZAUHmj/xzng3NFBN8ZhTQliVuZ6EWVRt8Ort8U= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 4/4] libipa: pwl: Fix single point Pwl Date: Fri, 13 Jun 2025 12:09:39 +0200 Message-ID: <20250613100947.589875-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250613100947.589875-1-stefan.klug@ideasonboard.com> References: <20250613100947.589875-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" Fix the eval() function for Pwls that contain only a single point. Remove the shouldi_fail from the corresponding test case. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/ipa/libipa/pwl.cpp | 4 ++++ test/ipa/libipa/meson.build | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 3d2188170d83..69a9334112e8 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -210,6 +210,10 @@ double Pwl::eval(double x, int *span, bool updateSpan) const : points_.size() / 2 - 1); if (span && updateSpan) *span = index; + + if (points_.size() == 1) + return points_[0].y(); + return points_[index].y() + (x - points_[index].x()) * (points_[index + 1].y() - points_[index].y()) / (points_[index + 1].x() - points_[index].x()); diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build index c553366a7934..2070bed70222 100644 --- a/test/ipa/libipa/meson.build +++ b/test/ipa/libipa/meson.build @@ -4,7 +4,7 @@ libipa_test = [ {'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']}, {'name': 'histogram', 'sources': ['histogram.cpp']}, {'name': 'interpolator', 'sources': ['interpolator.cpp']}, - {'name': 'pwl', 'sources': ['pwl.cpp'], 'should_fail': true }, + {'name': 'pwl', 'sources': ['pwl.cpp'] }, ] foreach test : libipa_test