{"id":17145,"url":"https://patchwork.libcamera.org/api/1.1/patches/17145/?format=json","web_url":"https://patchwork.libcamera.org/patch/17145/","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":"<20220817211824.20980-1-laurent.pinchart@ideasonboard.com>","date":"2022-08-17T21:18:24","name":"[libcamera-devel] libcamera: color_space: Rename Jpeg to Sycc","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"71c6874c141ab7571d1f978e31740c5719e77e4f","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17145/mbox/","series":[{"id":3423,"url":"https://patchwork.libcamera.org/api/1.1/series/3423/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3423","date":"2022-08-17T21:18:24","name":"[libcamera-devel] libcamera: color_space: Rename Jpeg to Sycc","version":1,"mbox":"https://patchwork.libcamera.org/series/3423/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17145/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17145/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 BC352BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Aug 2022 21:18:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26A2661FA8;\n\tWed, 17 Aug 2022 23:18:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EE9B61FA8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Aug 2022 23:18:26 +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 A7A6551C;\n\tWed, 17 Aug 2022 23:18:25 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660771108;\n\tbh=Hc+YiOXkrQiyp3uFB8IKmxBqLewjAii0qRf9q8Y/IWw=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=S0f5QDncjvt4SwGGllA+U3FPWhpP4diCGW89mxiyScwxyHXWMPrJB2pkDMaeyQT5G\n\tDBOgrvh27twNlZ1mawKVhzKrIPtpt+VregmgprFUNTUCNbscAtggN288bz20RZoW56\n\tks14Yxsm4uMsWxq9e+gmJmxRRcJZAkyVUxuFzm6ImZgtid2H1bTr04ETytyZAVUo0R\n\tU608TD9yfafdheQJbkvHgaNh9rteu0XcaJScGdiei1ZjQ8m2McSzy4fgncVPmZJVop\n\t/ojmele+H8574V/r4eHEh2kNW/JVkgmstT8OjG29e4rj1o0ZRaguW7zSBEqblSoFVO\n\tSWQXqaMiyy9sw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660771105;\n\tbh=Hc+YiOXkrQiyp3uFB8IKmxBqLewjAii0qRf9q8Y/IWw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=ucAHebse6liKtMcneO0G32O3M2Px5JI7ugTYqY/8WEJjHPhrth87/uFdLfrvdje6P\n\tQAhhretAiwkLU40mZfbMuFtCUuCrd3TefV/vmYaBnEQR6l3/ljAZ0MvIf/OfI/XGY4\n\tMjRr843Z3R6tbxBaidQ4QkOhyxUS79g4/J6P5X1k="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ucAHebse\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 18 Aug 2022 00:18:24 +0300","Message-Id":"<20220817211824.20980-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: color_space: Rename Jpeg to\n\tSycc","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":"Hans Verkuil <hverkuil-cisco@xs4all.nl>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The JPEG color space is badly name, as the JPEG specification (ITU-T\nT.81) doesn't define any particular color space:\n\n    The interchange format does not specify a complete coded image\n    representation. Application-dependent information, e.g. colour\n    space, is outside the scope of this Specification.\n\nThe JFIF specification (ITU-T T.871) is clearer as it requires ITU-R\nBT.601 YCbCr encoding and a full quantization range:\n\n  The interpretations of Y, CB, and CR are derived from the E'Y, E'Cb,\n  and E'Cr signals defined in the 625-line specification of Rec. ITU-R\n  BT.601, but these signals are normalized so as to permit the usage of\n  the full range of 256 levels of the 8-bit binary encoding of the Y\n  component.\n\nIt however doesn't specify color primaries or a transfer function\nexplicitly. It only mentions the latter when describing the conversion\nfrom YCbCr to RGB:\n\n  The inverse relationship for computing full scale 8-bit per colour\n  channel gamma pre-corrected RGB values (following Rec. ITU-R BT.601\n  gamma pre-correction and colour primary specifications) from YCbCr\n  colours (with 256 levels per component) can be computed as follows:\n  [...]\n\nGiven that ITU-R BT.601-5 (1995) didn't specify color primaries or a\ntransfer function, and that the later ITU-R BT.601-7 (2011) version\nspecifies color primaries for the 625-line variant that do not match\nsRGB, the JPEG color space in libcamera is badly named.\n\nRename the color space to sYCC, as its definition matches the sYCC\nstandard, and indicate that it is typically used to encode JPEG images.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n\nHans, following our discussion on IRC, I double-check the JFIF standard,\nand my findings are described in the commit message above. It seems that\nnaming the color space \"JPEG\" in V4L2 is actually incorrect, as JFIF\nexpects the 626-line ITU-R BT.601 chromaticities for the primary colors,\nwhich are slightly different than sRGB (the 525-line chromaticities\nmatch SMPTE 170M and SMPTE 240M, but not sRGB either). It seems that we\nare missing a V4L2_COLORSPACE_* value to describe the 625-line ITU-R\nBT.601 chromaticities, is that an oversight ?\n\n---\n include/libcamera/color_space.h               |  2 +-\n src/libcamera/color_space.cpp                 | 28 +++++++++----------\n .../pipeline/raspberrypi/raspberrypi.cpp      | 10 +++----\n src/libcamera/v4l2_device.cpp                 |  4 +--\n src/py/libcamera/py_main.cpp                  |  2 +-\n 5 files changed, 23 insertions(+), 23 deletions(-)","diff":"diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h\nindex 0d39fbc02220..8030a264c66f 100644\n--- a/include/libcamera/color_space.h\n+++ b/include/libcamera/color_space.h\n@@ -46,8 +46,8 @@ public:\n \t}\n \n \tstatic const ColorSpace Raw;\n-\tstatic const ColorSpace Jpeg;\n \tstatic const ColorSpace Srgb;\n+\tstatic const ColorSpace Sycc;\n \tstatic const ColorSpace Smpte170m;\n \tstatic const ColorSpace Rec709;\n \tstatic const ColorSpace Rec2020;\ndiff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp\nindex caf397607b10..6ace40dcb0fb 100644\n--- a/src/libcamera/color_space.cpp\n+++ b/src/libcamera/color_space.cpp\n@@ -121,8 +121,8 @@ namespace libcamera {\n  * \\brief Assemble and return a readable string representation of the\n  * ColorSpace\n  *\n- * If the color space matches a standard ColorSpace (such as ColorSpace::Jpeg)\n- * then the short name of the color space (\"JPEG\") is returned. Otherwise\n+ * If the color space matches a standard ColorSpace (such as ColorSpace::Sycc)\n+ * then the short name of the color space (\"sYCC\") is returned. Otherwise\n  * the four constituent parts of the ColorSpace are assembled into a longer\n  * string.\n  *\n@@ -134,8 +134,8 @@ std::string ColorSpace::toString() const\n \n \tstatic const std::array<std::pair<ColorSpace, const char *>, 6> colorSpaceNames = { {\n \t\t{ ColorSpace::Raw, \"RAW\" },\n-\t\t{ ColorSpace::Jpeg, \"JPEG\" },\n \t\t{ ColorSpace::Srgb, \"sRGB\" },\n+\t\t{ ColorSpace::Sycc, \"sYCC\" },\n \t\t{ ColorSpace::Smpte170m, \"SMPTE170M\" },\n \t\t{ ColorSpace::Rec709, \"Rec709\" },\n \t\t{ ColorSpace::Rec2020, \"Rec2020\" },\n@@ -242,17 +242,6 @@ const ColorSpace ColorSpace::Raw = {\n \tRange::Full\n };\n \n-/**\n- * \\brief A constant representing the JPEG color space used for\n- * encoding JPEG images\n- */\n-const ColorSpace ColorSpace::Jpeg = {\n-\tPrimaries::Rec709,\n-\tTransferFunction::Srgb,\n-\tYcbcrEncoding::Rec601,\n-\tRange::Full\n-};\n-\n /**\n  * \\brief A constant representing the sRGB color space\n  *\n@@ -266,6 +255,17 @@ const ColorSpace ColorSpace::Srgb = {\n \tRange::Limited\n };\n \n+/**\n+ * \\brief A constant representing the sYCC color space, typically used for\n+ * encoding JPEG images\n+ */\n+const ColorSpace ColorSpace::Sycc = {\n+\tPrimaries::Rec709,\n+\tTransferFunction::Srgb,\n+\tYcbcrEncoding::Rec601,\n+\tRange::Full\n+};\n+\n /**\n  * \\brief A constant representing the SMPTE170M color space\n  */\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex e895584d4fbc..b4094898ca6c 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -593,11 +593,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n \t\t\tpixelFormat = formats::NV12;\n \t\t\t/*\n-\t\t\t * Still image codecs usually expect the JPEG color space.\n+\t\t\t * Still image codecs usually expect the sYCC color space.\n \t\t\t * Even RGB codecs will be fine as the RGB we get with the\n-\t\t\t * JPEG color space is the same as sRGB.\n+\t\t\t * sYCC color space is the same as sRGB.\n \t\t\t */\n-\t\t\tcolorSpace = ColorSpace::Jpeg;\n+\t\t\tcolorSpace = ColorSpace::Sycc;\n \t\t\t/* Return the largest sensor resolution. */\n \t\t\tsize = sensorSize;\n \t\t\tbufferCount = 1;\n@@ -628,7 +628,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \t\tcase StreamRole::Viewfinder:\n \t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n \t\t\tpixelFormat = formats::ARGB8888;\n-\t\t\tcolorSpace = ColorSpace::Jpeg;\n+\t\t\tcolorSpace = ColorSpace::Sycc;\n \t\t\tsize = { 800, 600 };\n \t\t\tbufferCount = 4;\n \t\t\toutCount++;\n@@ -835,7 +835,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\tformat.size = maxSize;\n \t\tformat.fourcc = dev->toV4L2PixelFormat(formats::YUV420);\n \t\t/* No one asked for output, so the color space doesn't matter. */\n-\t\tformat.colorSpace = ColorSpace::Jpeg;\n+\t\tformat.colorSpace = ColorSpace::Sycc;\n \t\tret = dev->setFormat(&format);\n \t\tif (ret) {\n \t\t\tLOG(RPI, Error)\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 3fc8438f6579..b22a981ff1a6 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -745,8 +745,8 @@ void V4L2Device::eventAvailable()\n \n static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {\n \t{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },\n-\t{ V4L2_COLORSPACE_JPEG, ColorSpace::Jpeg },\n \t{ V4L2_COLORSPACE_SRGB, ColorSpace::Srgb },\n+\t{ V4L2_COLORSPACE_JPEG, ColorSpace::Sycc },\n \t{ V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m },\n \t{ V4L2_COLORSPACE_REC709, ColorSpace::Rec709 },\n \t{ V4L2_COLORSPACE_BT2020, ColorSpace::Rec2020 },\n@@ -771,8 +771,8 @@ 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::Jpeg, V4L2_COLORSPACE_JPEG },\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 \t{ ColorSpace::Rec2020, V4L2_COLORSPACE_BT2020 },\ndiff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex 505cc3dc1a0d..2a58e34a7cdb 100644\n--- a/src/py/libcamera/py_main.cpp\n+++ b/src/py/libcamera/py_main.cpp\n@@ -602,8 +602,8 @@ PYBIND11_MODULE(_libcamera, m)\n \t\t.def_readwrite(\"ycbcrEncoding\", &ColorSpace::ycbcrEncoding)\n \t\t.def_readwrite(\"range\", &ColorSpace::range)\n \t\t.def_static(\"Raw\", []() { return ColorSpace::Raw; })\n-\t\t.def_static(\"Jpeg\", []() { return ColorSpace::Jpeg; })\n \t\t.def_static(\"Srgb\", []() { return ColorSpace::Srgb; })\n+\t\t.def_static(\"Sycc\", []() { return ColorSpace::Sycc; })\n \t\t.def_static(\"Smpte170m\", []() { return ColorSpace::Smpte170m; })\n \t\t.def_static(\"Rec709\", []() { return ColorSpace::Rec709; })\n \t\t.def_static(\"Rec2020\", []() { return ColorSpace::Rec2020; });\n","prefixes":["libcamera-devel"]}