{"id":17255,"url":"https://patchwork.libcamera.org/api/patches/17255/?format=json","web_url":"https://patchwork.libcamera.org/patch/17255/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220830074725.1059643-7-umang.jain@ideasonboard.com>","date":"2022-08-30T07:47:24","name":"[libcamera-devel,v4,6/7] tests: stream: Add a colorspace adjustment test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"14d8caa7c375cf06863f2e7d43622df9b274771c","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/17255/mbox/","series":[{"id":3452,"url":"https://patchwork.libcamera.org/api/series/3452/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3452","date":"2022-08-30T07:47:18","name":"Colospace adjustment and gstreamer mapping","version":4,"mbox":"https://patchwork.libcamera.org/series/3452/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17255/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17255/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 28BB1C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Aug 2022 07:47:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB13261FCC;\n\tTue, 30 Aug 2022 09:47:52 +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 F0F6061FB9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Aug 2022 09:47:50 +0200 (CEST)","from umang.jainideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3f:1548:78ac:4a3:edc3:c28a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7022C481;\n\tTue, 30 Aug 2022 09:47:49 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661845672;\n\tbh=Jdj0XGz/2g2ed/6YUcDmE0nB72gTUKyrwSC/zUCODMs=;\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:Cc:\n\tFrom;\n\tb=le2NdP+qJJj5qwerUpbKLB/1x0gr3QoGujMduXn4X0l/eIJBOplRcQ5zlinU7xrmX\n\taqCZKDXz8MFBECHOnrZxWW94OnTyi+dAiFqRFy5DSWwxyvCQcVoiqwmPrkGsUuJzVF\n\tGWTlgUbNBY675hPV0amCRYj3ZNGTJLdyopaLLqZoExkCMGLMt6p0XZ/MSXP247jTiH\n\ttmMF/zV6wBzwVcVGjqUdjbq3fdLGywuBSKtWh4p4f/Eyj/dfTC0fS0YeZgsRA+17ol\n\tGIJTmlyIsvILKbr8VMPY1PIngLYPJyScSFY0SJ5s16rFusbsOeIQZ24+TW3hSrcbvr\n\tX1MEzeDOOzIOQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661845670;\n\tbh=Jdj0XGz/2g2ed/6YUcDmE0nB72gTUKyrwSC/zUCODMs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=C0s69qaSv/0FBKn1oTL0iV0TCSNfQcdsIDGA3wpzgIVKQ7t2f4ZFfrMsNLbr8Sh8C\n\tsH84PLXGACR+KZzhf/ruKi7/ztKfozwQ7Gz+p0Dnhj4swfYWfciUTWTA+2HJuHySRE\n\tjdCGSDNsxVbNwTuihdYVaD32b/YKoMMCwCkYN7Mw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"C0s69qaS\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Aug 2022 13:17:24 +0530","Message-Id":"<20220830074725.1059643-7-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.37.2","In-Reply-To":"<20220830074725.1059643-1-umang.jain@ideasonboard.com>","References":"<20220830074725.1059643-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 6/7] 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>","Cc":"rishikeshdonadkar@gmail.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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\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","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..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","prefixes":["libcamera-devel","v4","6/7"]}