From patchwork Tue Aug 2 18:57:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16920 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 F15CBC3275 for ; Tue, 2 Aug 2022 18:57:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF74363316; Tue, 2 Aug 2022 20:57:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659466656; bh=p4UcN+mdL4/pKtc5ZnC3kX4FFsnQ9RXd+SNOwB3OrL4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mZUV56fY7AT8kqYq+yP81m8GW325kEeeECtT9buhH+nzD4JjN154gtm14l4etoRqZ jARFxNuED1drGN+IFelOIKXdnkdIX+BTN2AmOHtIy+68PUgNZrjU+6AZUQsYw5H4r1 RxPL9bgS6pY4rq8+/KzvHYx++x7CbKmbWIIE+nGOsI4j6bsKuTPzrxSvUpbTJ+S6lr PEhqLRpCRzr1fC8VuKCLeGs2/hlQBMPndY0OzjtzZbl6KKr1CUh35yGvJeOFkAUzN7 VZbBYFYPVrISRBTqBeI7zyGiqmBRryTHRqGhRBAu24VSQ690mFRkD0SxRIR/cSFLzS f3HWaRr6Ah+DA== 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 B47CD603E7 for ; Tue, 2 Aug 2022 20:57:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pelhQINk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:85c2:5ee8:5bb8:aca7:5517]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4FE4825B; Tue, 2 Aug 2022 20:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659466654; bh=p4UcN+mdL4/pKtc5ZnC3kX4FFsnQ9RXd+SNOwB3OrL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pelhQINkFhAtnEsXgEqiDWKD2LgWnAFZqX37rA72IiandH8Lz2eVj7B0SFmvfvmCX WXMPalyjq89Wrb8FqCg4yXmsgjLEMEGTDh0Z82yQVPTYVpl91Hz2vldzcbt5HK9MSf gQHB4oFEEzHwU5+iH5PPHtNoGZNIik0p4AQWjTyU= To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 00:27:18 +0530 Message-Id: <20220802185719.380855-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220802185719.380855-1-umang.jain@ideasonboard.com> References: <20220802185719.380855-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/4] 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 Cc: rishikeshdonadkar@gmail.com 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. Signed-off-by: Umang Jain --- test/stream/meson.build | 1 + test/stream/stream_colorspace.cpp | 57 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/stream/stream_colorspace.cpp diff --git a/test/stream/meson.build b/test/stream/meson.build index 73608ffd..bf78ddfe 100644 --- a/test/stream/meson.build +++ b/test/stream/meson.build @@ -2,6 +2,7 @@ stream_tests = [ ['stream_formats', 'stream_formats.cpp'], + ['stream_colorspace', 'stream_colorspace.cpp'], ] foreach t : stream_tests diff --git a/test/stream/stream_colorspace.cpp b/test/stream/stream_colorspace.cpp new file mode 100644 index 00000000..e8ac17d3 --- /dev/null +++ b/test/stream/stream_colorspace.cpp @@ -0,0 +1,57 @@ +/* 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 "test.h" + +using namespace libcamera; + +class StreamColorSpaceTest : public Test +{ +protected: + int run() + { + StreamConfiguration cfg; + cfg.size = { 640, 320 }; + cfg.pixelFormat = formats::YUV422; + cfg.colorSpace = ColorSpace::Srgb; + + /* YUV stream with sRGB colorspace should have y'cbcr encoding adjusted */ + ColorSpace adjColorSpace = cfg.colorSpace->adjust(cfg); + if (adjColorSpace.ycbcrEncoding == ColorSpace::YcbcrEncoding::None) + return TestFail; + + /* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */ + cfg.pixelFormat = formats::RGB888; + adjColorSpace = cfg.colorSpace->adjust(cfg); + if (adjColorSpace == ColorSpace::Srgb) + ; + else + return TestFail; + + /* + * For YUV pixelFormat, encoding should picked up according to + * primaries. + */ + cfg.pixelFormat = formats::YUV422; + cfg.colorSpace = ColorSpace(ColorSpace::Primaries::Rec2020, + ColorSpace::TransferFunction::Rec709, + ColorSpace::YcbcrEncoding::None, + ColorSpace::Range::Limited); + adjColorSpace = cfg.colorSpace->adjust(cfg); + if (adjColorSpace.ycbcrEncoding != ColorSpace::YcbcrEncoding::Rec2020) + return TestFail; + + return TestPass; + } +}; + +TEST_REGISTER(StreamColorSpaceTest)