{"id":17199,"url":"https://patchwork.libcamera.org/api/1.1/patches/17199/?format=json","web_url":"https://patchwork.libcamera.org/patch/17199/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220824162425.71087-6-umang.jain@ideasonboard.com>","date":"2022-08-24T16:24:24","name":"[libcamera-devel,v2,5/6] tests: stream: Add a colorspace adjustment test","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f52b048f743c46bf986acfde16fa7bab524fe364","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/17199/mbox/","series":[{"id":3434,"url":"https://patchwork.libcamera.org/api/1.1/series/3434/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3434","date":"2022-08-24T16:24:19","name":"Colorspace adjustments and gstreamer mappings","version":2,"mbox":"https://patchwork.libcamera.org/series/3434/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17199/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17199/checks/","tags":{},"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 EAFB5C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Aug 2022 16:24:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A546061FCF;\n\tWed, 24 Aug 2022 18:24:48 +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 0880D60E26\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Aug 2022 18:24:47 +0200 (CEST)","from umang.jainideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3f:806e:6647:8e5c:f441:ca9a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EB4F72B3;\n\tWed, 24 Aug 2022 18:24:45 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661358288;\n\tbh=xdYyiuqowynTlV470DeRsF6JDN3ZgJRLBfXG8RQDm2w=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=GhJICO0hd8KcKrGoSOLiPUsFe6a4j6VU3evaS+L3XWNSMUwp5ryS4zKCQ0rA8wgP/\n\tCTTaOJZbxH4QPrR/XEQt/Tl9xqSSqCUoABGV2YvS97hscBOloNiaNQbNq08Q++yPzy\n\tKjDn6ohXjR7k2XVyzeUIu9PYBCeIlgL/g4GblJKDfY4+CXH7SmUNGxoIaxwsrTGaWq\n\tvGLGt9O+ZlAoqu3kWxloEMEWL/RSEOd9BGk6FHlvLNZe+x83r5gahlb2U4Q3ymjDMS\n\tDbpARR8oY3HDVDpEpb5Vo/5Vg0DGX8Z8s02XUlTROyamQPH19qAvpOvZRqxSKzEXoy\n\tXHpUs50b9CbcQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661358286;\n\tbh=xdYyiuqowynTlV470DeRsF6JDN3ZgJRLBfXG8RQDm2w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ibvh4CQ95bdTons/oeBlWxGI4Le7mx/C05vNUWrOiF2r8a4Gb9A5jSg/oUwjdKXzE\n\tGpEUSJCZE2L0Oqo5cmrbVgDNQiJDROCQpVyY8F0Qv5FQ84fjmbca+1m72+exZtXiqe\n\t316LtZwqtcKDX0NngGgSfUcGPhXRsPp7ncuLfUhg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ibvh4CQ9\"; dkim-atps=neutral","To":"libcamera-devel <libcamera-devel@lists.libcamera.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 5/6] tests: stream: Add a colorspace\n\tadjustment 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":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"ColorSpace can be adjusted based on the stream's pixelFormat being\nrequested. Add a test to check the adjustment logic defined in\nColorSpace::adjust().\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n test/stream/meson.build           |  1 +\n test/stream/stream_colorspace.cpp | 80 +++++++++++++++++++++++++++++++\n 2 files changed, 81 insertions(+)\n create mode 100644 test/stream/stream_colorspace.cpp","diff":"diff --git a/test/stream/meson.build b/test/stream/meson.build\nindex 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 \ndiff --git a/test/stream/stream_colorspace.cpp b/test/stream/stream_colorspace.cpp\nnew file mode 100644\nindex 00000000..65e695ca\n--- /dev/null\n+++ b/test/stream/stream_colorspace.cpp\n@@ -0,0 +1,80 @@\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+\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 stream 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\treturn TestFail;\n+\n+\t\t/* For RGB pixelFormat, sRGB colorspace shouldn't get adjusted */\n+\t\tstreamCfg.pixelFormat = formats::RGB888;\n+\t\tstreamCfg.colorSpace = ColorSpace::Srgb;\n+\t\tconfig_.validate();\n+\t\tif (streamCfg.colorSpace != ColorSpace::Srgb)\n+\t\t\treturn TestFail;\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\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\treturn TestPass;\n+\t}\n+\n+\tTestCameraConfiguration config_;\n+};\n+\n+TEST_REGISTER(StreamColorSpaceTest)\n","prefixes":["libcamera-devel","v2","5/6"]}