From patchwork Fri Sep 20 13:39:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21297 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 C2245C3257 for ; Fri, 20 Sep 2024 13:39:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5388D63504; Fri, 20 Sep 2024 15:39:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="a6wzyUE0"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E097D634F5 for ; Fri, 20 Sep 2024 15:39:51 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:8ade:938d:48b1:cede]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 031F24CE; Fri, 20 Sep 2024 15:38:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726839508; bh=SUnWlOhmwR6l9+epK/dD3PuK4kwZCJnKspqBgbcvbjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a6wzyUE0H2wOQ57CSq3bjFtixEkZDp0eGTHkJUqqapjfo9gcYH5fX0qkL/HtKOV9x ZOmOub70ZpGOZdxUi0HmrvSzQZVgSm2vmZnsdLL2EIglCjP7AOgEnB3gcWuC/+SZaW /zQ1ygnM0HKlrakr1B7zbzmMun98dBhQuF0ff6Hk= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder Subject: [PATCH v3 2/9] test: ipa: libipa: Add tets for Interpolator Date: Fri, 20 Sep 2024 15:39:17 +0200 Message-ID: <20240920133941.90629-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240920133941.90629-1-stefan.klug@ideasonboard.com> References: <20240920133941.90629-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" Add tests for the Interpolator class. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- Changes in v3: - Stylefixes - Collected tags - Fixed copyright --- test/ipa/libipa/interpolator.cpp | 54 ++++++++++++++++++++++++++++++++ test/ipa/libipa/meson.build | 15 +++++++++ test/ipa/meson.build | 1 + 3 files changed, 70 insertions(+) create mode 100644 test/ipa/libipa/interpolator.cpp create mode 100644 test/ipa/libipa/meson.build diff --git a/test/ipa/libipa/interpolator.cpp b/test/ipa/libipa/interpolator.cpp new file mode 100644 index 000000000000..6abb776060d4 --- /dev/null +++ b/test/ipa/libipa/interpolator.cpp @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * Interpolator tests + */ + +#include "../src/ipa/libipa/interpolator.h" + +#include +#include +#include +#include +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; +using namespace ipa; + +#define ASSERT_EQ(a, b) \ + if ((a) != (b)) { \ + printf(#a " != " #b "\n"); \ + return TestFail; \ + } + +class InterpolatorTest : public Test +{ +protected: + int run() + { + Interpolator interpolator; + interpolator.setData({ { 10, 100 }, { 20, 200 }, { 30, 300 } }); + + ASSERT_EQ(interpolator.getInterpolated(0), 100); + ASSERT_EQ(interpolator.getInterpolated(10), 100); + ASSERT_EQ(interpolator.getInterpolated(20), 200); + ASSERT_EQ(interpolator.getInterpolated(25), 250); + ASSERT_EQ(interpolator.getInterpolated(30), 300); + ASSERT_EQ(interpolator.getInterpolated(40), 300); + + interpolator.setQuantization(10); + unsigned int q = 0; + ASSERT_EQ(interpolator.getInterpolated(25, &q), 300); + ASSERT_EQ(q, 30); + ASSERT_EQ(interpolator.getInterpolated(24, &q), 200); + ASSERT_EQ(q, 20); + + return TestPass; + } +}; + +TEST_REGISTER(InterpolatorTest) diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build new file mode 100644 index 000000000000..4d2427dbd4e7 --- /dev/null +++ b/test/ipa/libipa/meson.build @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: CC0-1.0 + +libipa_test = [ + {'name': 'interpolator', 'sources': ['interpolator.cpp']}, +] + +foreach test : libipa_test + exe = executable(test['name'], test['sources'], + dependencies : [libcamera_private, libipa_dep], + link_with : [test_libraries], + include_directories : [test_includes_internal, + '../../../src/ipa/libipa/']) + + test(test['name'], exe, suite : 'ipa') +endforeach diff --git a/test/ipa/meson.build b/test/ipa/meson.build index e9871aba44ee..63820de54899 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,5 +1,6 @@ # SPDX-License-Identifier: CC0-1.0 +subdir('libipa') subdir('rkisp1') ipa_test = [