[{"id":24878,"web_url":"https://patchwork.libcamera.org/comment/24878/","msgid":"<20220901040332.GH27075@pyrite.rasen.tech>","date":"2022-09-01T04:03:32","subject":"Re: [libcamera-devel] [PATCH v4 6/7] tests: stream: Add a\n\tcolorspace adjustment test","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Tue, Aug 30, 2022 at 01:17:24PM +0530, Umang Jain via libcamera-devel wrote:\n> ColorSpace can be adjusted based on the stream's pixelFormat being\n> requested. Add a test to check the adjustment logic defined in\n> ColorSpace::adjust().\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  test/stream/meson.build           |  1 +\n>  test/stream/stream_colorspace.cpp | 96 +++++++++++++++++++++++++++++++\n>  2 files changed, 97 insertions(+)\n>  create mode 100644 test/stream/stream_colorspace.cpp\n> \n> diff --git a/test/stream/meson.build b/test/stream/meson.build\n> index 73608ffd..89f51c18 100644\n> --- a/test/stream/meson.build\n> +++ b/test/stream/meson.build\n> @@ -1,6 +1,7 @@\n>  # SPDX-License-Identifier: CC0-1.0\n>  \n>  stream_tests = [\n> +    ['stream_colorspace', 'stream_colorspace.cpp'],\n>      ['stream_formats',  'stream_formats.cpp'],\n>  ]\n>  \n> diff --git a/test/stream/stream_colorspace.cpp b/test/stream/stream_colorspace.cpp\n> new file mode 100644\n> index 00000000..1b7afe65\n> --- /dev/null\n> +++ b/test/stream/stream_colorspace.cpp\n> @@ -0,0 +1,96 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2022, Ideas on Board Oy.\n> + *\n> + * stream_colorspace.cpp - Stream colorspace adjustment test\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/camera.h>\n> +#include <libcamera/formats.h>\n> +#include <libcamera/stream.h>\n> +\n> +#include \"test.h\"\n> +\n> +using namespace libcamera;\n> +using namespace std;\n> +\n> +class TestCameraConfiguration : public CameraConfiguration\n> +{\n> +public:\n> +\tTestCameraConfiguration()\n> +\t\t: CameraConfiguration()\n> +\t{\n> +\t}\n> +\n> +\tStatus validate() override\n> +\t{\n> +\t\treturn validateColorSpaces();\n> +\t}\n> +};\n> +\n> +class StreamColorSpaceTest : public Test\n> +{\n> +protected:\n> +\tint run()\n> +\t{\n> +\t\tTestCameraConfiguration config;\n> +\n> +\t\tStreamConfiguration cfg;\n> +\t\tcfg.size = { 640, 320 };\n> +\t\tcfg.pixelFormat = formats::YUV422;\n> +\t\tcfg.colorSpace = ColorSpace::Srgb;\n> +\t\tconfig.addConfiguration(cfg);\n> +\n> +\t\tStreamConfiguration &streamCfg = config.at(0);\n> +\n> +\t\t/*\n> +\t\t * YUV pixelformat with sRGB colorspace should have Y'CbCr encoding\n> +\t\t * adjusted.\n> +\t\t */\n> +\t\tconfig.validate();\n> +\t\tif (streamCfg.colorSpace->ycbcrEncoding == ColorSpace::YcbcrEncoding::None) {\n> +\t\t\tcerr << \"YUV format must have YCbCr encoding\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * For YUV pixelFormat, encoding should be picked up according\n> +\t\t * to primaries and transfer function, if 'None' is specified.\n> +\t\t */\n> +\t\tstreamCfg.pixelFormat = formats::YUV422;\n> +\t\tstreamCfg.colorSpace = ColorSpace(ColorSpace::Primaries::Rec2020,\n> +\t\t\t\t\t\t  ColorSpace::TransferFunction::Rec709,\n> +\t\t\t\t\t\t  ColorSpace::YcbcrEncoding::None,\n> +\t\t\t\t\t\t  ColorSpace::Range::Limited);\n> +\t\tconfig.validate();\n> +\t\tif (streamCfg.colorSpace->ycbcrEncoding != ColorSpace::YcbcrEncoding::Rec2020) {\n> +\t\t\tcerr << \"Failed to adjust colorspace Y'CbCr encoding according\"\n> +\t\t\t     << \" to primaries and transfer function\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* For RGB pixelFormat, Sycc colorspace should get adjusted to sRGB. */\n> +\t\tstreamCfg.pixelFormat = formats::RGB888;\n> +\t\tstreamCfg.colorSpace = ColorSpace::Sycc;\n> +\t\tconfig.validate();\n> +\t\tif (streamCfg.colorSpace != ColorSpace::Srgb) {\n> +\t\t\tcerr << \"RGB format's colorspace should be set to Srgb\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* Raw formats should always set colorspace to ColorSpace::Raw. */\n> +\t\tstreamCfg.pixelFormat = formats::SBGGR8;\n> +\t\tstreamCfg.colorSpace = ColorSpace::Rec709;\n> +\t\tconfig.validate();\n> +\t\tif (streamCfg.colorSpace != ColorSpace::Raw) {\n> +\t\t\tcerr << \"Raw format must always have Raw colorspace\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(StreamColorSpaceTest)\n> -- \n> 2.37.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C24CEC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  1 Sep 2022 04:03:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D7A861FCA;\n\tThu,  1 Sep 2022 06:03:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D1A361F9A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  1 Sep 2022 06:03:42 +0200 (CEST)","from pyrite.rasen.tech (unknown [50.228.9.220])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E4A8481;\n\tThu,  1 Sep 2022 06:03:41 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662005024;\n\tbh=T7oOVVqPEocd63qNxrheCj39m+4E2iTuCXhcANiA5Jw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ePwAOomryOktoZApGHrRr7xqlF1dsRQRgiqiC1zAuwq/v1ednybKCGBI13gso/uku\n\tCxSFYYtbgNi4qSTJpFbqwMVZQDyQ4OSB+fsnfBoEiq6xmwWj48YsJbD2Vrxtchoa4j\n\tvpbF0/HXDIUqZQmDd4McnhAW56t93/v075NoXa1puadXpu0L4lPq/DwGFVrCAxgOdC\n\tPGrl9WBd8/+ce0Q++c1N+KgiiioBikA8byS68J33X4FXpFyDa1KlJTMm6+THNAH4Yq\n\tWsYEUDJ0lnXTc4aRABHzAKKFyoWWIEGRjA8V9rfxDziPn+JTg+KchywPE6zj9Xzesa\n\tdExawX2zgd3YQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662005022;\n\tbh=T7oOVVqPEocd63qNxrheCj39m+4E2iTuCXhcANiA5Jw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fUn5+ISTKghRBlvGnw3GHoK7HfFvPwtMaQXdg1Hrmer3SSMEtJPF+aoXvO40qVfbi\n\tK/gyCDzM4UQxfC2/43i2G8a28qnsidVYcc64fnMN4lAQNwnT2WGcoC3lMoynRA7q9a\n\t9bR5Wis7bsAPzez8GmXWzC897jRMKTPGW6B51Z/Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fUn5+IST\"; dkim-atps=neutral","Date":"Thu, 1 Sep 2022 00:03:32 -0400","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<20220901040332.GH27075@pyrite.rasen.tech>","References":"<20220830074725.1059643-1-umang.jain@ideasonboard.com>\n\t<20220830074725.1059643-7-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220830074725.1059643-7-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 6/7] tests: stream: Add a\n\tcolorspace adjustment test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"rishikeshdonadkar@gmail.com, libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]