From patchwork Mon Aug 29 16:37:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 17233 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 BDB05C3272 for ; Mon, 29 Aug 2022 16:38:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 820FC61FC9; Mon, 29 Aug 2022 18:38:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1661791096; bh=WUe0whjXp/ttI/abCisnscXe/TV7eSKa/0M0PXQ8bXA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wxpyim4Rm7oi9ZbQSIhiRcxdxOX9gtWzl3Pli3RocmgoILP4B6PuMsZbZld0CcbHo bH9j/WHol5XbUkiu4zErCWLoe4CCLzOzXTHJcN3yU2YBkwL4gYWKnI15pd9GMDHgNn qrV9imG0PxrezmwehoF4tIG+EYRXNexdfPQiHOkrAbFYhTJPT2LDX/TN3FRlcpSo5A c999Pexar+sCbq7ZVoDnhD2efEIG/8c5wQtxprUSXtkdKOeaxM2ppozDsPyrthU+KF pCYBDXxWJa1H8sZoxNGf84NQAf3aNH9kZbvjIJZM90vYXD0CjeIPJy+rYrFzn9HKA8 IFNt0arjmSJ2Q== 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 F182F61FD0 for ; Mon, 29 Aug 2022 18:38:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EHlKk9eW"; dkim-atps=neutral Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:1548:78ac:4a3:edc3:c28a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E3DE4505; Mon, 29 Aug 2022 18:38:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1661791092; bh=WUe0whjXp/ttI/abCisnscXe/TV7eSKa/0M0PXQ8bXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHlKk9eWkHntxjsmbkBgvgwUtNFF1uhTDVqV8tbf0FtQxeMpC2jwPzEwCjH1aDbTQ 1yy1hsO7zv1zIr85EV80U1lbB0OHKhmR+Eo8OFhifHxekDOOa36eD6ekIbAT2uz6Zq zkZTKRS+hr6/Sakh+weVJGl007K3Q3r4vXkiRVgc= To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Aug 2022 22:07:41 +0530 Message-Id: <20220829163742.1006102-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829163742.1006102-1-umang.jain@ideasonboard.com> References: <20220829163742.1006102-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/7] tests: stream: Add a colorspace adjustment test 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: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" ColorSpace can be adjusted based on the stream's pixelFormat being requested. Add a test to check the adjustment logic defined in ColorSpace::adjust(). Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- test/stream/meson.build | 1 + test/stream/stream_colorspace.cpp | 87 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 test/stream/stream_colorspace.cpp diff --git a/test/stream/meson.build b/test/stream/meson.build index 73608ffd..89f51c18 100644 --- a/test/stream/meson.build +++ b/test/stream/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 stream_tests = [ + ['stream_colorspace', 'stream_colorspace.cpp'], ['stream_formats', 'stream_formats.cpp'], ] diff --git a/test/stream/stream_colorspace.cpp b/test/stream/stream_colorspace.cpp new file mode 100644 index 00000000..7b7e84e0 --- /dev/null +++ b/test/stream/stream_colorspace.cpp @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Ideas on Board Oy. + * + * stream_colorspace.cpp - Stream colorspace tests + */ + +#include + +#include +#include +#include + +#include "test.h" + +using namespace libcamera; +using namespace std; + +class TestCameraConfiguration : public CameraConfiguration +{ +public: + TestCameraConfiguration() + : CameraConfiguration() + { + } + + Status validate() override + { + return validateColorSpaces(); + } +}; + +class StreamColorSpaceTest : public Test +{ +protected: + int run() + { + StreamConfiguration cfg; + cfg.size = { 640, 320 }; + cfg.pixelFormat = formats::YUV422; + cfg.colorSpace = ColorSpace::Srgb; + config_.addConfiguration(cfg); + + StreamConfiguration &streamCfg = config_.at(0); + + /* + * YUV pixelformat with sRGB colorspace should have Y'CbCr encoding + * adjusted. + */ + config_.validate(); + if (streamCfg.colorSpace->ycbcrEncoding == ColorSpace::YcbcrEncoding::None) + return TestFail; + + /* + * For YUV pixelFormat, encoding should picked up according to + * primaries and transfer function, if 'None' is specified. + */ + streamCfg.pixelFormat = formats::YUV422; + streamCfg.colorSpace = ColorSpace(ColorSpace::Primaries::Rec2020, + ColorSpace::TransferFunction::Rec709, + ColorSpace::YcbcrEncoding::None, + ColorSpace::Range::Limited); + config_.validate(); + if (streamCfg.colorSpace->ycbcrEncoding != ColorSpace::YcbcrEncoding::Rec2020) + return TestFail; + + /* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */ + streamCfg.pixelFormat = formats::RGB888; + streamCfg.colorSpace = ColorSpace::Srgb; + config_.validate(); + if (streamCfg.colorSpace != ColorSpace::Srgb) + return TestFail; + + /* Raw formats should always set colorspace to ColorSpace::Raw */ + streamCfg.pixelFormat = formats::SBGGR8; + streamCfg.colorSpace = ColorSpace::Rec709; + config_.validate(); + if (streamCfg.colorSpace != ColorSpace::Raw) + return TestFail; + + return TestPass; + } + + TestCameraConfiguration config_; +}; + +TEST_REGISTER(StreamColorSpaceTest)