From patchwork Wed Aug 24 16:24:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 17199 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 EAFB5C3272 for ; Wed, 24 Aug 2022 16:24:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A546061FCF; Wed, 24 Aug 2022 18:24:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1661358288; bh=xdYyiuqowynTlV470DeRsF6JDN3ZgJRLBfXG8RQDm2w=; 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=GhJICO0hd8KcKrGoSOLiPUsFe6a4j6VU3evaS+L3XWNSMUwp5ryS4zKCQ0rA8wgP/ CTTaOJZbxH4QPrR/XEQt/Tl9xqSSqCUoABGV2YvS97hscBOloNiaNQbNq08Q++yPzy KjDn6ohXjR7k2XVyzeUIu9PYBCeIlgL/g4GblJKDfY4+CXH7SmUNGxoIaxwsrTGaWq vGLGt9O+ZlAoqu3kWxloEMEWL/RSEOd9BGk6FHlvLNZe+x83r5gahlb2U4Q3ymjDMS DbpARR8oY3HDVDpEpb5Vo/5Vg0DGX8Z8s02XUlTROyamQPH19qAvpOvZRqxSKzEXoy XHpUs50b9CbcQ== 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 0880D60E26 for ; Wed, 24 Aug 2022 18:24:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ibvh4CQ9"; dkim-atps=neutral Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:806e:6647:8e5c:f441:ca9a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EB4F72B3; Wed, 24 Aug 2022 18:24:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1661358286; bh=xdYyiuqowynTlV470DeRsF6JDN3ZgJRLBfXG8RQDm2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ibvh4CQ95bdTons/oeBlWxGI4Le7mx/C05vNUWrOiF2r8a4Gb9A5jSg/oUwjdKXzE GpEUSJCZE2L0Oqo5cmrbVgDNQiJDROCQpVyY8F0Qv5FQ84fjmbca+1m72+exZtXiqe 316LtZwqtcKDX0NngGgSfUcGPhXRsPp7ncuLfUhg= To: libcamera-devel Date: Wed, 24 Aug 2022 21:54:24 +0530 Message-Id: <20220824162425.71087-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220824162425.71087-1-umang.jain@ideasonboard.com> References: <20220824162425.71087-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] 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 --- test/stream/meson.build | 1 + test/stream/stream_colorspace.cpp | 80 +++++++++++++++++++++++++++++++ 2 files changed, 81 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..65e695ca --- /dev/null +++ b/test/stream/stream_colorspace.cpp @@ -0,0 +1,80 @@ +/* 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 stream with sRGB colorspace should have Y'CbCr encoding + * adjusted. + */ + config_.validate(); + if (streamCfg.colorSpace->ycbcrEncoding == ColorSpace::YcbcrEncoding::None) + 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; + + /* + * For YUV pixelFormat, encoding should picked up according to + * primaries. + */ + 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; + + return TestPass; + } + + TestCameraConfiguration config_; +}; + +TEST_REGISTER(StreamColorSpaceTest)