[{"id":24590,"web_url":"https://patchwork.libcamera.org/comment/24590/","msgid":"<YvsCiA1UqQO0C+mU@pendragon.ideasonboard.com>","date":"2022-08-16T02:35:52","subject":"Re: [libcamera-devel] [RFC PATCH 3/4] 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 Wed, Aug 03, 2022 at 12:27:18AM +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.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  test/stream/meson.build           |  1 +\n>  test/stream/stream_colorspace.cpp | 57 +++++++++++++++++++++++++++++++\n>  2 files changed, 58 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..bf78ddfe 100644\n> --- a/test/stream/meson.build\n> +++ b/test/stream/meson.build\n> @@ -2,6 +2,7 @@\n>  \n>  stream_tests = [\n>      ['stream_formats',  'stream_formats.cpp'],\n> +    ['stream_colorspace', 'stream_colorspace.cpp'],\n>  ]\n>  \n>  foreach t : stream_tests\n> diff --git a/test/stream/stream_colorspace.cpp b/test/stream/stream_colorspace.cpp\n> new file mode 100644\n> index 00000000..e8ac17d3\n> --- /dev/null\n> +++ b/test/stream/stream_colorspace.cpp\n> @@ -0,0 +1,57 @@\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/formats.h>\n> +#include <libcamera/stream.h>\n> +\n> +#include \"test.h\"\n> +\n> +using namespace libcamera;\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> +\n> +\t\t/* YUV stream with sRGB colorspace should have y'cbcr encoding adjusted */\n\ns/y'cbcr/Y'CbCr/\n\n> +\t\tColorSpace adjColorSpace = cfg.colorSpace->adjust(cfg);\n> +\t\tif (adjColorSpace.ycbcrEncoding == ColorSpace::YcbcrEncoding::None)\n> +\t\t\treturn TestFail;\n> +\n> +\t\t/* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */\n> +\t\tcfg.pixelFormat = formats::RGB888;\n> +\t\tadjColorSpace = cfg.colorSpace->adjust(cfg);\n> +\t\tif (adjColorSpace == ColorSpace::Srgb)\n> +\t\t\t;\n> +\t\telse\n> +\t\t\treturn TestFail;\n\nThat's peculiar.\n\n\t\tif (adjColorSpace != ColorSpace::Srgb)\n\t\t\treturn TestFail;\n\nI expect this patch to change based on the comments on 2/4, so I'll\nreview it again then.\n\n> +\n> +\t\t/*\n> +\t\t * For YUV pixelFormat, encoding should picked up according to\n> +\t\t * primaries.\n> +\t\t */\n> +\t\tcfg.pixelFormat = formats::YUV422;\n> +\t\tcfg.colorSpace = ColorSpace(ColorSpace::Primaries::Rec2020,\n> +\t\t\t\t\t    ColorSpace::TransferFunction::Rec709,\n> +\t\t\t\t\t    ColorSpace::YcbcrEncoding::None,\n> +\t\t\t\t\t    ColorSpace::Range::Limited);\n> +\t\tadjColorSpace = cfg.colorSpace->adjust(cfg);\n> +\t\tif (adjColorSpace.ycbcrEncoding != ColorSpace::YcbcrEncoding::Rec2020)\n> +\t\t\treturn TestFail;\n> +\n> +\t\treturn TestPass;\n> +\t}\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 4B8D6BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Aug 2022 02:36:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A068961FC0;\n\tTue, 16 Aug 2022 04:36:07 +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 215F7603E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Aug 2022 04:36:06 +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 6CCAF496;\n\tTue, 16 Aug 2022 04:36:05 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660617367;\n\tbh=XLHRNf9+se13dQjnDG90MMZFwN/PHlYaEUjngul0xeU=;\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=GCiW4vqH4gSqwkrUkR19Jyw8AfkTscgX+Q5APuCjc8Y+me2eXG5RlJIG612MkKwQp\n\tGjNY+2hFb7Bn5lIdRJHyIgDds2VVrBPAIKjMM7Z4A8miWiB1yRxUiENhAg4VTmEWYB\n\tDr6Oiu8A4TF3esozq4vFMiAlAdgUpYo5OPqP2UBI88pIOsdYZjvRS4m/UzDlAcuw73\n\t8RyAnPnq0lBZL8oTYW2z09IwdiVGeoCHYNvdl19mpMoYbUos8sCj3+FvvNg53t0uT7\n\tZUPDt1N3uF4nq1aI/SviY208VIZx2sQYHh57gBGtZqj7iaEjSec7E7lVLPr3+BBm3b\n\tD3o1TyixRnZxQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660617365;\n\tbh=XLHRNf9+se13dQjnDG90MMZFwN/PHlYaEUjngul0xeU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=amDwZnPN5eMfjRpU6XbnDIJFUI6ibwNy/7F2MV5jrdah5EVWOj35ys+VOtJC/xgz1\n\takEn+VzBb+Va42rv/8DKaL3p0TUtTsgn4WLPm1Mrg1atQKuzh4s1r2a5Pvoj3NzqeL\n\teXvM7ApynNuyTk8CAUdV1fXF2oNW/SUYXvEFVOJI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"amDwZnPN\"; dkim-atps=neutral","Date":"Tue, 16 Aug 2022 05:35:52 +0300","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YvsCiA1UqQO0C+mU@pendragon.ideasonboard.com>","References":"<20220802185719.380855-1-umang.jain@ideasonboard.com>\n\t<20220802185719.380855-4-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220802185719.380855-4-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH 3/4] 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":"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>"}}]