From patchwork Fri Sep 13 07:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21251 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 DF09AC324C for ; Fri, 13 Sep 2024 07:58:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 93165634F8; Fri, 13 Sep 2024 09:58:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="b82OH/Xj"; 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 279D4634F8 for ; Fri, 13 Sep 2024 09:58:00 +0200 (CEST) Received: from ideasonboard.com (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B95E1011; Fri, 13 Sep 2024 09:56:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726214201; bh=tjh4IHdZhV9Q/6JixLvDs4zZHFCRZQIr5+oEcwpDoeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b82OH/Xj0wKhef/cUWqcg8e+pe5t2RTkyI8Q2sO27EETgGmvy8UiofAv0RbofKpin nd1VvvUDtIsBhSqamtUrJj1J++flT0PVoIC4ZaPGcfgwHmMcpr6aj/7K18QNSg5xsA qpM7TzVGBgFo4JAMTYJuQHXPQUx8mdmrlcinaaXw= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 2/9] test: ipa: libipa: Add tets for Interpolator Date: Fri, 13 Sep 2024 09:57:20 +0200 Message-ID: <20240913075750.35115-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240913075750.35115-1-stefan.klug@ideasonboard.com> References: <20240913075750.35115-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 --- test/ipa/libipa/interpolator.cpp | 55 ++++++++++++++++++++++++++++++++ test/ipa/libipa/meson.build | 15 +++++++++ test/ipa/meson.build | 1 + 3 files changed, 71 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..adb215386f0e --- /dev/null +++ b/test/ipa/libipa/interpolator.cpp @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024, Paul Elder + * + * Miscellaneous utility tests + */ + +#include +#include +#include +#include +#include + +#include "../src/ipa/libipa/interpolator.h" + +#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 = [