{"id":16751,"url":"https://patchwork.libcamera.org/api/1.1/patches/16751/?format=json","web_url":"https://patchwork.libcamera.org/patch/16751/","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":"<20220724144355.104978-3-umang.jain@ideasonboard.com>","date":"2022-07-24T14:43:54","name":"[libcamera-devel,2/3] libcamera: colorspace: Add a default colorspace","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"989556949debc09ffb79e3367225fa616f87cabe","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16751/mbox/","series":[{"id":3322,"url":"https://patchwork.libcamera.org/api/1.1/series/3322/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3322","date":"2022-07-24T14:43:52","name":"gstreamer: Plumb initial colorimetry support","version":1,"mbox":"https://patchwork.libcamera.org/series/3322/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16751/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16751/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 C26B0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 24 Jul 2022 14:44:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8069C63318;\n\tSun, 24 Jul 2022 16:44:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 52E736330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Jul 2022 16:44:10 +0200 (CEST)","from perceval.ideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3e:f7a:bc8f:12ed:b45f:c35d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACDE9835;\n\tSun, 24 Jul 2022 16:44:08 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658673852;\n\tbh=p3zcJc7vBKICC5GwNKYYxll+zLwA+KFyD6S76yoHSt8=;\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=GkiJG7riVQ0Xy36YQFfIm0zv7AqDxSmcx2Dm03SdyoXAF+YQYJV4vPhR1laSks5BO\n\td1CmV81nLDkSXfHDZ3aRbGcjt0KE/Rlte1duFl/2uSIR/4Kuq/djcJhiFsN7ohpjhT\n\tvbdqy07ji5xQwxgXTfQvFVWtRHlj0a367o9s8PTBpADX/ZzhEygv7Pr3VG/5HM+DM5\n\t636dqhcQ/iNQvjFE9QSCBAt2x9beUanYDpZjomqDvQyMeKcOORDkH0Pr7qSeQazBBb\n\ts8tlBnaeo1qy1/hUl7ah6Auk+qq9pLGLFaZpfaWX5akXyOPKsVGLE5e/MZv8FbMBVC\n\tnVI34NS+9x6ew==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658673850;\n\tbh=p3zcJc7vBKICC5GwNKYYxll+zLwA+KFyD6S76yoHSt8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=rhdeHjhY4bAmGfqFRr7WctuBNKinaLJl3KR513YXXynbLTnfTwZNsp3K3BdZdh6bj\n\tfOt3S08iYkn/WADe2jAG6hDlI1TvcXGICRml5d0f4EmzQ1nANuG7x8BDXHaHZ9/Okj\n\t7ARVhv2DXeTAxHltCkc2AGveQ2JjOi9c/pnfEX7E="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"rhdeHjhY\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 24 Jul 2022 20:13:54 +0530","Message-Id":"<20220724144355.104978-3-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20220724144355.104978-1-umang.jain@ideasonboard.com>","References":"<20220724144355.104978-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/3] libcamera: colorspace: Add a default\n\tcolorspace","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, nicolas.dufresne@collabora.com,\n\tvedantparanjape160201@gmail.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a Colorspace::Default which corresponds to default V4L2\ncolorspace identifiers.\n\n\\todo Add defaults to python colorspace bindings\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n include/libcamera/color_space.h |  5 +++++\n src/libcamera/color_space.cpp   | 29 ++++++++++++++++++++++++++++-\n src/libcamera/v4l2_device.cpp   |  5 +++++\n 3 files changed, 38 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h\nindex 086c56c1..0ad8da17 100644\n--- a/include/libcamera/color_space.h\n+++ b/include/libcamera/color_space.h\n@@ -16,6 +16,7 @@ class ColorSpace\n {\n public:\n \tenum class Primaries {\n+\t\tDefault,\n \t\tRaw,\n \t\tSmpte170m,\n \t\tRec709,\n@@ -23,12 +24,14 @@ public:\n \t};\n \n \tenum class TransferFunction {\n+\t\tDefault,\n \t\tLinear,\n \t\tSrgb,\n \t\tRec709,\n \t};\n \n \tenum class YcbcrEncoding {\n+\t\tDefault,\n \t\tNone,\n \t\tRec601,\n \t\tRec709,\n@@ -36,6 +39,7 @@ public:\n \t};\n \n \tenum class Range {\n+\t\tDefault,\n \t\tFull,\n \t\tLimited,\n \t};\n@@ -45,6 +49,7 @@ public:\n \t{\n \t}\n \n+\tstatic const ColorSpace Default;\n \tstatic const ColorSpace Raw;\n \tstatic const ColorSpace Jpeg;\n \tstatic const ColorSpace Srgb;\ndiff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp\nindex 895e5c8e..d52f58cf 100644\n--- a/src/libcamera/color_space.cpp\n+++ b/src/libcamera/color_space.cpp\n@@ -50,6 +50,9 @@ namespace libcamera {\n  * \\enum ColorSpace::Primaries\n  * \\brief The color primaries for this color space\n  *\n+ * \\var ColorSpace::Primaries::Default\n+ * \\brief Use the default primaries as defined by the driver\n+ *\n  * \\var ColorSpace::Primaries::Raw\n  * \\brief These are raw colors directly from a sensor, the primaries are\n  * unspecified\n@@ -68,6 +71,9 @@ namespace libcamera {\n  * \\enum ColorSpace::TransferFunction\n  * \\brief The transfer function used for this color space\n  *\n+ * \\var ColorSpace::TransferFunction::Default\n+ * \\brief Use the default transfer function as defined by the driver\n+ *\n  * \\var ColorSpace::TransferFunction::Linear\n  * \\brief This color space uses a linear (identity) transfer function\n  *\n@@ -82,6 +88,9 @@ namespace libcamera {\n  * \\enum ColorSpace::YcbcrEncoding\n  * \\brief The Y'CbCr encoding\n  *\n+ * \\var ColorSpace::YcbcrEncoding::Default\n+ * \\brief Use the default Y'CbCr encoding as defined by the driver\n+ *\n  * \\var ColorSpace::YcbcrEncoding::None\n  * \\brief There is no defined Y'CbCr encoding (used for non-YUV formats)\n  *\n@@ -99,6 +108,9 @@ namespace libcamera {\n  * \\enum ColorSpace::Range\n  * \\brief The range (sometimes \"quantisation\") for this color space\n  *\n+ * \\var ColorSpace::Range::Default\n+ * Use the default range as defined by the driver\n+ *\n  * \\var ColorSpace::Range::Full\n  * \\brief This color space uses full range pixel values\n  *\n@@ -132,7 +144,8 @@ std::string ColorSpace::toString() const\n {\n \t/* Print out a brief name only for standard color spaces. */\n \n-\tstatic const std::array<std::pair<ColorSpace, const char *>, 6> colorSpaceNames = { {\n+\tstatic const std::array<std::pair<ColorSpace, const char *>, 7> colorSpaceNames = { {\n+\t\t{ ColorSpace::Default, \"Default\" },\n \t\t{ ColorSpace::Raw, \"RAW\" },\n \t\t{ ColorSpace::Jpeg, \"JPEG\" },\n \t\t{ ColorSpace::Srgb, \"sRGB\" },\n@@ -150,23 +163,27 @@ std::string ColorSpace::toString() const\n \t/* Assemble a name made of the constituent fields. */\n \n \tstatic const std::map<Primaries, std::string> primariesNames = {\n+\t\t{ Primaries::Default, \"Default\" },\n \t\t{ Primaries::Raw, \"RAW\" },\n \t\t{ Primaries::Smpte170m, \"SMPTE170M\" },\n \t\t{ Primaries::Rec709, \"Rec709\" },\n \t\t{ Primaries::Rec2020, \"Rec2020\" },\n \t};\n \tstatic const std::map<TransferFunction, std::string> transferNames = {\n+\t\t{ TransferFunction::Default, \"Default\" },\n \t\t{ TransferFunction::Linear, \"Linear\" },\n \t\t{ TransferFunction::Srgb, \"sRGB\" },\n \t\t{ TransferFunction::Rec709, \"Rec709\" },\n \t};\n \tstatic const std::map<YcbcrEncoding, std::string> encodingNames = {\n+\t\t{ YcbcrEncoding::Default, \"Default\" },\n \t\t{ YcbcrEncoding::None, \"None\" },\n \t\t{ YcbcrEncoding::Rec601, \"Rec601\" },\n \t\t{ YcbcrEncoding::Rec709, \"Rec709\" },\n \t\t{ YcbcrEncoding::Rec2020, \"Rec2020\" },\n \t};\n \tstatic const std::map<Range, std::string> rangeNames = {\n+\t\t{ Range::Default, \"Default\" },\n \t\t{ Range::Full, \"Full\" },\n \t\t{ Range::Limited, \"Limited\" },\n \t};\n@@ -232,6 +249,16 @@ std::string ColorSpace::toString(const std::optional<ColorSpace> &colorSpace)\n  * \\brief The pixel range used with by color space\n  */\n \n+/**\n+ * \\brief A constant representing a default color space\n+ */\n+const ColorSpace ColorSpace::Default = {\n+\tPrimaries::Default,\n+\tTransferFunction::Default,\n+\tYcbcrEncoding::Default,\n+\tRange::Default\n+};\n+\n /**\n  * \\brief A constant representing a raw color space (from a sensor)\n  */\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 3fc8438f..ecfcf337 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -770,6 +770,7 @@ static const std::map<uint32_t, ColorSpace::Range> v4l2ToRange = {\n };\n \n static const std::vector<std::pair<ColorSpace, v4l2_colorspace>> colorSpaceToV4l2 = {\n+\t{ ColorSpace::Default, V4L2_COLORSPACE_DEFAULT },\n \t{ ColorSpace::Raw, V4L2_COLORSPACE_RAW },\n \t{ ColorSpace::Jpeg, V4L2_COLORSPACE_JPEG },\n \t{ ColorSpace::Srgb, V4L2_COLORSPACE_SRGB },\n@@ -779,6 +780,7 @@ static const std::vector<std::pair<ColorSpace, v4l2_colorspace>> colorSpaceToV4l\n };\n \n static const std::map<ColorSpace::Primaries, v4l2_colorspace> primariesToV4l2 = {\n+\t{ ColorSpace::Primaries::Default, V4L2_COLORSPACE_DEFAULT },\n \t{ ColorSpace::Primaries::Raw, V4L2_COLORSPACE_RAW },\n \t{ ColorSpace::Primaries::Smpte170m, V4L2_COLORSPACE_SMPTE170M },\n \t{ ColorSpace::Primaries::Rec709, V4L2_COLORSPACE_REC709 },\n@@ -786,18 +788,21 @@ static const std::map<ColorSpace::Primaries, v4l2_colorspace> primariesToV4l2 =\n };\n \n static const std::map<ColorSpace::TransferFunction, v4l2_xfer_func> transferFunctionToV4l2 = {\n+\t{ ColorSpace::TransferFunction::Default, V4L2_XFER_FUNC_DEFAULT },\n \t{ ColorSpace::TransferFunction::Linear, V4L2_XFER_FUNC_NONE },\n \t{ ColorSpace::TransferFunction::Srgb, V4L2_XFER_FUNC_SRGB },\n \t{ ColorSpace::TransferFunction::Rec709, V4L2_XFER_FUNC_709 },\n };\n \n static const std::map<ColorSpace::YcbcrEncoding, v4l2_ycbcr_encoding> ycbcrEncodingToV4l2 = {\n+\t{ ColorSpace::YcbcrEncoding::Default, V4L2_YCBCR_ENC_DEFAULT },\n \t{ ColorSpace::YcbcrEncoding::Rec601, V4L2_YCBCR_ENC_601 },\n \t{ ColorSpace::YcbcrEncoding::Rec709, V4L2_YCBCR_ENC_709 },\n \t{ ColorSpace::YcbcrEncoding::Rec2020, V4L2_YCBCR_ENC_BT2020 },\n };\n \n static const std::map<ColorSpace::Range, v4l2_quantization> rangeToV4l2 = {\n+\t{ ColorSpace::Range::Default, V4L2_QUANTIZATION_DEFAULT },\n \t{ ColorSpace::Range::Full, V4L2_QUANTIZATION_FULL_RANGE },\n \t{ ColorSpace::Range::Limited, V4L2_QUANTIZATION_LIM_RANGE },\n };\n","prefixes":["libcamera-devel","2/3"]}