{"id":17197,"url":"https://patchwork.libcamera.org/api/1.1/patches/17197/?format=json","web_url":"https://patchwork.libcamera.org/patch/17197/","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-4-umang.jain@ideasonboard.com>","date":"2022-08-24T16:24:22","name":"[libcamera-devel,v2,3/6] libcamera: colorspace: Rectify the ColorSpace::Srgb preset","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"85773accaff261c6c8166f3c73c65da27e9460b0","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/17197/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/17197/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17197/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 286CFC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Aug 2022 16:24:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA73561FBC;\n\tWed, 24 Aug 2022 18:24:43 +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 76CCA60E26\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Aug 2022 18:24:42 +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 66C582B3;\n\tWed, 24 Aug 2022 18:24:41 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661358283;\n\tbh=IFJrV8sGTED81EbaRi7SSg8dl8ouFKuBrP3ii/r6w8Q=;\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=LjcA+RGtZtL9hDA7WMHCeO9+yi8rt7JKzMoZl+8SAi+h4ZCyUg519ja9qE49d/uvF\n\tKPVjlFtpWeD4J7wTgq1jKU3zroP1F7KQy6++lrT9RovvgCguu6yNcUeXrrZF7dCmEs\n\t5oLvRRik8F48SEu77TXCVFfFz8SDrt0fumd9BneHcUz/fCkA46ZhEFu0KLO/xSDz/n\n\tRWFCQCLs8rgRn6Uoc1GogKUO+xrw7KGaUalPnn8lqHAMopZlKezzpu6e8hQuHVAT2M\n\tHMHUunQGercCCHzliO6RneyGnaWujkCujR0FX/w2eISuHvfOKiwIXwfjtuZRrvpOMz\n\t1UlRG+OoMyuOw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661358282;\n\tbh=IFJrV8sGTED81EbaRi7SSg8dl8ouFKuBrP3ii/r6w8Q=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=IuXEzYeHenlMmNL8Ls2gkN26pvBIN84fAmJwHC+6YK6W9hwgofNCmXV2UvgLH2831\n\thIxzUK+EeDXCd04WvCgFy62e8piFzUHW3Niek6bGrUBoMBjTjbN3XKaWsxM2uoh/6c\n\txDMngFGnvedXIZP6zj5d9lzG6ANAqRddqZtSEbxg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"IuXEzYeH\"; dkim-atps=neutral","To":"libcamera-devel <libcamera-devel@lists.libcamera.org>","Date":"Wed, 24 Aug 2022 21:54:22 +0530","Message-Id":"<20220824162425.71087-4-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 3/6] libcamera: colorspace: Rectify the\n\tColorSpace::Srgb preset","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":"Rectify the ColorSpace::Srgb to denote that it does not use\nany Y'Cbcr encoding and uses full range.\n\nThe kernel on the other hand, recommends to use Rec601 as the encoding\nfor V4L2_COLORSPACE_SRGB. It is not very explicit but it can be\ninferred that the kernel assumes V4L2_COLORSPACE_SRGB is a YUV-encoded\none. However, when the data is in RGB, no encoding is required (and\nthis is denoted by YcbcrEncoding::None in libcamera).\n\nHence, to be clear on the libcamera colorspace API, rectify the\nColorSpace::Srgb preset to use YcbcrEncoding::None.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/libcamera/color_space.cpp | 14 +++++++-------\n src/libcamera/v4l2_device.cpp |  7 +++++--\n 2 files changed, 12 insertions(+), 9 deletions(-)","diff":"diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp\nindex f0d6109a..cb47acf9 100644\n--- a/src/libcamera/color_space.cpp\n+++ b/src/libcamera/color_space.cpp\n@@ -47,7 +47,10 @@ namespace libcamera {\n  *\n  * Note that there is no guarantee of a 1:1 mapping between color space names\n  * and definitions in libcamera and V4L2. A notable difference is that the sYCC\n- * libcamera color space is called JPEG in V4L2 due to historical reasons.\n+ * libcamera color space is called JPEG in V4L2 due to historical reasons. On\n+ * a similar note, the sRGB colorspace defined in the kernel assumes a Y'CbCr\n+ * encoding to it which is not true. Hence the ColorSpace::sRGB is defined\n+ * differently in libcamera (with no Y'CbCr encoding and full range).\n  *\n  * \\todo Define the color space fully in the libcamera API to avoid referencing\n  * V4L2\n@@ -250,16 +253,13 @@ const ColorSpace ColorSpace::Raw = {\n };\n \n /**\n- * \\brief A constant representing the sRGB color space\n- *\n- * This is identical to the sYCC color space except that the Y'CbCr\n- * range is limited rather than full.\n+ * \\brief A constant representing the sRGB color space (RGB formats only)\n  */\n const ColorSpace ColorSpace::Srgb = {\n \tPrimaries::Rec709,\n \tTransferFunction::Srgb,\n-\tYcbcrEncoding::Rec601,\n-\tRange::Limited\n+\tYcbcrEncoding::None,\n+\tRange::Full\n };\n \n /**\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 1fb08b9d..a9e34ee1 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -746,7 +746,11 @@ void V4L2Device::eventAvailable()\n \n static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {\n \t{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },\n-\t{ V4L2_COLORSPACE_SRGB, ColorSpace::Srgb },\n+\t{ V4L2_COLORSPACE_SRGB, {\n+\t\tColorSpace::Primaries::Rec709,\n+\t\tColorSpace::TransferFunction::Srgb,\n+\t\tColorSpace::YcbcrEncoding::Rec601,\n+\t\tColorSpace::Range::Limited } },\n \t{ V4L2_COLORSPACE_JPEG, ColorSpace::Sycc },\n \t{ V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m },\n \t{ V4L2_COLORSPACE_REC709, ColorSpace::Rec709 },\n@@ -772,7 +776,6 @@ static const std::map<uint32_t, ColorSpace::Range> v4l2ToRange = {\n \n static const std::vector<std::pair<ColorSpace, v4l2_colorspace>> colorSpaceToV4l2 = {\n \t{ ColorSpace::Raw, V4L2_COLORSPACE_RAW },\n-\t{ ColorSpace::Srgb, V4L2_COLORSPACE_SRGB },\n \t{ ColorSpace::Sycc, V4L2_COLORSPACE_JPEG },\n \t{ ColorSpace::Smpte170m, V4L2_COLORSPACE_SMPTE170M },\n \t{ ColorSpace::Rec709, V4L2_COLORSPACE_REC709 },\n","prefixes":["libcamera-devel","v2","3/6"]}