{"id":17231,"url":"https://patchwork.libcamera.org/api/patches/17231/?format=json","web_url":"https://patchwork.libcamera.org/patch/17231/","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":"<20220829163742.1006102-5-umang.jain@ideasonboard.com>","date":"2022-08-29T16:37:39","name":"[libcamera-devel,v3,4/7] libcamera: colorspace: Rectify the ColorSpace::Srgb preset","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c2bb4e6e2bb296ca75e2ba48cd2e50cdbb7fab2a","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17231/mbox/","series":[{"id":3447,"url":"https://patchwork.libcamera.org/api/series/3447/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3447","date":"2022-08-29T16:37:35","name":"Colorspace adjustments and gstreamer mappings","version":3,"mbox":"https://patchwork.libcamera.org/series/3447/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17231/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17231/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 36154C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Aug 2022 16:38:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E315161FCF;\n\tMon, 29 Aug 2022 18:38:12 +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 2DE6E61FBA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Aug 2022 18:38:09 +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 E55EC505;\n\tMon, 29 Aug 2022 18:38:07 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661791092;\n\tbh=BJE/sijghjgSBi4m+tWWT8qpCRnDSH7pzLiDtsHQR6Y=;\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=nnrB+HE9bIAvviV74CBelN5fWVx4IDcVl740JOKdJaZPVT8CZdlPNodrdo4Pv3hy0\n\twXdZC0lss4bxBOxu5c2Tsh69UlCvOZKBGER8ZzJBk5eHOXP3KGpJZAuDY9QiGdNcu8\n\terRI30EQEROLPOB70o55vzrUZ9EU//GffmUPcGmAoWjT4waDCuhWtl95e0xF/eDg8k\n\tfeHuoLBij/gSZcpFkZ+j4lyGDczmKKr84fTnMT4L77RQ3QQZd40+O8ctW+EaFGY/Ty\n\tOUyn3KQvmoSq8tFZc3N2Bd+odAskebTrlGhr7GpUq34zs56yTQ9+utRiGUkgykMw/5\n\tZ2zeP5Jg7B2qg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661791088;\n\tbh=BJE/sijghjgSBi4m+tWWT8qpCRnDSH7pzLiDtsHQR6Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=tX0dchPFM26CB+AtCuJZeamyipuTnMZBuAfmt2314fPWer3o8dVaVaDuMZpo6SqwX\n\tOEXNXw5Hh+bbIky3w44sPzjmmyKlNeSYdSXAF+mjh3wiwdNSj+akpY13AqX9FCvGC9\n\tZUYZq+kQhXUT/KJPPGnrfVTOjz+JLPE4IxOEgiU8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"tX0dchPF\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 29 Aug 2022 22:07:39 +0530","Message-Id":"<20220829163742.1006102-5-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.37.2","In-Reply-To":"<20220829163742.1006102-1-umang.jain@ideasonboard.com>","References":"<20220829163742.1006102-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 4/7] 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 and full range.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/color_space.cpp | 18 ++++++++++--------\n src/libcamera/v4l2_device.cpp |  7 +++++--\n 2 files changed, 15 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp\nindex 944d0e98..ec34620a 100644\n--- a/src/libcamera/color_space.cpp\n+++ b/src/libcamera/color_space.cpp\n@@ -49,8 +49,13 @@ namespace libcamera {\n  * - <a href=\"https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/colorspaces-details.html#col-bt2020\">Rec.2020</a>\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+ * and definitions in libcamera and V4L2. Two notable differences are\n+ *\n+ * - The sRGB libcamera color space is defined for RGB formats only with no\n+ *   Y'CbCr encoding and a full quantization range, while the V4L2 SRGB color\n+ *   space has a Y'CbCr encoding and a limited quantization range.\n+ * - The sYCC libcamera color space is called JPEG in V4L2 due to historical\n+ *   reasons.\n  *\n  * \\todo Define the color space fully in the libcamera API to avoid referencing\n  * V4L2\n@@ -138,16 +143,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 301620f8..1d899657 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","v3","4/7"]}