[{"id":24822,"web_url":"https://patchwork.libcamera.org/comment/24822/","msgid":"<Yw09ctiaLWK259/9@pendragon.ideasonboard.com>","date":"2022-08-29T22:28:02","subject":"Re: [libcamera-devel] [PATCH v3 6/7] tests: stream: Add a\n\tcolorspace adjustment test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Mon, Aug 29, 2022 at 10:07:41PM +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> ---\n>  test/stream/meson.build           |  1 +\n>  test/stream/stream_colorspace.cpp | 87 +++++++++++++++++++++++++++++++\n>  2 files changed, 88 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..7b7e84e0\n> --- /dev/null\n> +++ b/test/stream/stream_colorspace.cpp\n> @@ -0,0 +1,87 @@\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 tests\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\nClever way to test this :-)\n\n> +\t}\n> +};\n> +\n> +class StreamColorSpaceTest : public Test\n> +{\n> +protected:\n> +\tint run()\n> +\t{\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\nTest failures should print an error message, to identify the test that\nfails. Something like.\n\n\t\t\tstd::cerr << \"YUV format must have YCbCr encoding\" << std::endl;\n\nSame below.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\treturn TestFail;\n> +\n> +\t\t/*\n> +\t\t * For YUV pixelFormat, encoding should picked up according to\n\ns/should picked/should be picked/\n\n> +\t\t * 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\treturn TestFail;\n> +\n> +\t\t/* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */\n\ns/adjusted/adjusted./\n\nSame below.\n\n> +\t\tstreamCfg.pixelFormat = formats::RGB888;\n> +\t\tstreamCfg.colorSpace = ColorSpace::Srgb;\n\nI'd set it to Sycc here to test that it gets adjusted to Srgb.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\tconfig_.validate();\n> +\t\tif (streamCfg.colorSpace != ColorSpace::Srgb)\n> +\t\t\treturn TestFail;\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\treturn TestFail;\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tTestCameraConfiguration config_;\n> +};\n> +\n> +TEST_REGISTER(StreamColorSpaceTest)","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 D2E69C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Aug 2022 22:28:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E85861FC0;\n\tTue, 30 Aug 2022 00:28:14 +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 39C7761FBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Aug 2022 00:28:12 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FA5D481;\n\tTue, 30 Aug 2022 00:28:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661812094;\n\tbh=l2BahL+lKlbsLCNBcwYPzAn3hyVgz/2fbjW7tv80qhk=;\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=sfM2OAY/TaYhIR64GLhxGKl8aU17wGS0YfZm4KIXaumnbJeEiWDUhuG1i4qy9vHQo\n\tGJgu8xxvRJi3fBL2Ws6Ia0mnXanAkwwogs57kUD2wIhOPizLgmTcGLDzIc/xP2Mh4b\n\tmV+cJBQAOwV20T0mSiiGVBUlAJptLP568TT50SGZvgjycb/zCodxpUA5WolxYlzEzK\n\tO8XZdUkRV2iC2kEdYD+0e93QdvGV1abnNiBBw2qXnn8SWFTV7+kCoh4mx8kEcKJIWO\n\tJ1qw9A2LGIF5x8PEYv4J4YvxvCK9QM6UNF5W8QEJWe2mqyndZlQC6rBkvMkP4rfzzq\n\tiogzN9eNqgwRA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661812091;\n\tbh=l2BahL+lKlbsLCNBcwYPzAn3hyVgz/2fbjW7tv80qhk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=j3oJVUGMsgfxfKCsTvRv+eeLaflFbM0nKNd6EUQiSAdeWef6ljIWofMnFtKf3o1uw\n\tMObkbGqV1e39+tEBTU8/tf3agEeSNfwqlGQdtf3ugRMN1Pmf3NI5HYa7Iwlis0kZLd\n\tELOs3UhBzlTYLXCq8MJyl9em7bCnms5KU3yvKB7U="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"j3oJVUGM\"; dkim-atps=neutral","Date":"Tue, 30 Aug 2022 01:28:02 +0300","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<Yw09ctiaLWK259/9@pendragon.ideasonboard.com>","References":"<20220829163742.1006102-1-umang.jain@ideasonboard.com>\n\t<20220829163742.1006102-7-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220829163742.1006102-7-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24823,"web_url":"https://patchwork.libcamera.org/comment/24823/","msgid":"<Yw09lYOQKeeGjurN@pendragon.ideasonboard.com>","date":"2022-08-29T22:28:37","subject":"Re: [libcamera-devel] [PATCH v3 6/7] tests: stream: Add a\n\tcolorspace adjustment test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"One more comment.\n\nOn Tue, Aug 30, 2022 at 01:28:04AM +0300, Laurent Pinchart wrote:\n> Hi Umang,\n> \n> Thank you for the patch.\n> \n> On Mon, Aug 29, 2022 at 10:07:41PM +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> > ---\n> >  test/stream/meson.build           |  1 +\n> >  test/stream/stream_colorspace.cpp | 87 +++++++++++++++++++++++++++++++\n> >  2 files changed, 88 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..7b7e84e0\n> > --- /dev/null\n> > +++ b/test/stream/stream_colorspace.cpp\n> > @@ -0,0 +1,87 @@\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 tests\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> \n> Clever way to test this :-)\n> \n> > +\t}\n> > +};\n> > +\n> > +class StreamColorSpaceTest : public Test\n> > +{\n> > +protected:\n> > +\tint run()\n> > +\t{\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> \n> Test failures should print an error message, to identify the test that\n> fails. Something like.\n> \n> \t\t\tstd::cerr << \"YUV format must have YCbCr encoding\" << std::endl;\n> \n> Same below.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\t\t\treturn TestFail;\n> > +\n> > +\t\t/*\n> > +\t\t * For YUV pixelFormat, encoding should picked up according to\n> \n> s/should picked/should be picked/\n> \n> > +\t\t * 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\treturn TestFail;\n> > +\n> > +\t\t/* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */\n> \n> s/adjusted/adjusted./\n> \n> Same below.\n> \n> > +\t\tstreamCfg.pixelFormat = formats::RGB888;\n> > +\t\tstreamCfg.colorSpace = ColorSpace::Srgb;\n> \n> I'd set it to Sycc here to test that it gets adjusted to Srgb.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\t\tconfig_.validate();\n> > +\t\tif (streamCfg.colorSpace != ColorSpace::Srgb)\n> > +\t\t\treturn TestFail;\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\treturn TestFail;\n> > +\n> > +\t\treturn TestPass;\n> > +\t}\n> > +\n> > +\tTestCameraConfiguration config_;\n\nThis can be a local variable in the run() function.\n\n> > +};\n> > +\n> > +TEST_REGISTER(StreamColorSpaceTest)","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 5DAAAC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Aug 2022 22:28:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 27C9261FC0;\n\tTue, 30 Aug 2022 00:28:49 +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 3D66461FBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Aug 2022 00:28:47 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C0FAE481;\n\tTue, 30 Aug 2022 00:28:46 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661812129;\n\tbh=sLu0QHSpsPGnF7e1rfQNQ9GGz+jqJ5a7VkngEN6J8tk=;\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=wE/iurckpmKXV9YQXNEqEhOBBO/vgKV7DoOhNuOMUkfuWdCQXHCkdPowgsTjzb6/u\n\tJhXXOzeo4cWuxeAOD1G30KlhKScHHIbVC3MOZqU8fIj3+On6XLIGP79eaNOFjbfOHG\n\tZbrLKCjQ2EfTcRfS9/Pm/iGEK26iYDdsUH6apMEQXHwTZkalPosy68rK7rZ4zv9zME\n\tneeGCyoBfm7IPyINHh5+SFYNi/Ixg1/QhyXgwYy9kAQtejrX3WC5AQJhB4314l8/v2\n\teEdVGBYVnkB6IE76/U5GsBnPxt4VdZ6m1sArCl2mPyKPYN5m52MqxsFyTE3dlBxxlt\n\t76C2BFwvBLk+A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661812127;\n\tbh=sLu0QHSpsPGnF7e1rfQNQ9GGz+jqJ5a7VkngEN6J8tk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dt1dPv27focMdFlFVIw5mK+/bWNLg5s40oRhVV/T6UYJTVA/Zc5UR7x+Mv8s5tEKD\n\t21qFSP1ZDfAQxC7fy0iGnHU3vThsKoayJzVq+vOs5Ch8ypEX1MIW4ojLRI786kU/c8\n\tUQjMqERiEJVpnn2twcTn9CFxd1/HUEW6pTAsmofM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"dt1dPv27\"; dkim-atps=neutral","Date":"Tue, 30 Aug 2022 01:28:37 +0300","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<Yw09lYOQKeeGjurN@pendragon.ideasonboard.com>","References":"<20220829163742.1006102-1-umang.jain@ideasonboard.com>\n\t<20220829163742.1006102-7-umang.jain@ideasonboard.com>\n\t<Yw09ctiaLWK259/9@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<Yw09ctiaLWK259/9@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]