{"id":16524,"url":"https://patchwork.libcamera.org/api/patches/16524/?format=json","web_url":"https://patchwork.libcamera.org/patch/16524/","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":"<20220703073358.76643-1-rishikeshdonadkar@gmail.com>","date":"2022-07-03T07:33:54","name":"[libcamera-devel,v1,1/5] gstreamer: Convert form colorspace to colorimetry.","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"96eb7271d13d0e8d2af0d1bf45c09fff52ee34ab","submitter":{"id":118,"url":"https://patchwork.libcamera.org/api/people/118/?format=json","name":"Rishikesh Donadkar","email":"rishikeshdonadkar@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16524/mbox/","series":[{"id":3245,"url":"https://patchwork.libcamera.org/api/series/3245/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3245","date":"2022-07-03T07:33:54","name":"[libcamera-devel,v1,1/5] gstreamer: Convert form colorspace to colorimetry.","version":1,"mbox":"https://patchwork.libcamera.org/series/3245/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16524/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16524/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 D5D1EBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  3 Jul 2022 07:34:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E16A6564E;\n\tSun,  3 Jul 2022 09:34:11 +0200 (CEST)","from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com\n\t[IPv6:2607:f8b0:4864:20::1033])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E5B561FB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 Jul 2022 09:34:10 +0200 (CEST)","by mail-pj1-x1033.google.com with SMTP id\n\tj1-20020a17090aeb0100b001ef777a7befso1308171pjz.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 03 Jul 2022 00:34:10 -0700 (PDT)","from localhost.localdomain\n\t([2402:8100:30af:f358:3ebf:ad3f:f834:3344])\n\tby smtp.googlemail.com with ESMTPSA id\n\tl11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 03 Jul 2022 00:34:08 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656833651;\n\tbh=1be0cULGX9WjRXUnQ3WYCT+hSTxYbW0VRIrm7vonzRc=;\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=qIHRi/9q56SahZfMnG9HDPZ+1ipLCKPa4vpy2j5vLTPDeJ18Ta/x3IUmDD9AOgwqi\n\tJOA90GAF/kJXTVEH51ZhBpTdQrkUiiStQC+kaspz14BbetHDawMHvBrKIMOiihBWTi\n\tqkwh9Yvp5Kh3ef8pQ129/PbdXOHb/+gN8VwNRz0quFi7rhXHeso/MjDLxc/LywEmDe\n\tle3uVgguzABGcoQm8gRiYuvF1I/bjKcEXh9lJnf+RrvAhhKgNBrbVL+aAQY9SU50iX\n\t3lMtAhamfrXL9QKdsb6Oci+osmyZNQCuvOq5vSvCYIcugMhZzA5zXh4yDgVYQy5ZZe\n\tiVWJCVgTy6tNw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cvCl0z382EYdkVPSkS58OKglurMkpOPZlcquWibtLi8=;\n\tb=mqXWRA/wfvwac8bzFe20xC8z1RPZ+TvpXL3ErGo3zqAufpXvIi0UKk/Jbc15GmevEm\n\tMCpdM5K8mDNjSMAX5+f+TmldQaj/ycCJJyyis1NHWZ9LNdTdoPFQMBp1ExCCcbzv3HKD\n\tNVkD3QnSwzssmfAirQ0kzhfGYwIhQQJY1BORI7J0KCSYOtECMRlTfn4l3eg+M3pjqXgH\n\tnxcA8efOjWMnNOshBSFqPo10FbB0rEbwdJJutRn7abpZ38ZQ9dBfbtd2007UxXF6rjtz\n\tCg5nR6VKpY7tCELoXZZrUrQzuFlpHpECzIyyO62BZglNJHCb4lyN3o7aE57eYCXSSL23\n\tkofA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"mqXWRA/w\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cvCl0z382EYdkVPSkS58OKglurMkpOPZlcquWibtLi8=;\n\tb=QQDU1KrVFi4NcyLmuZdEGZamhuw2nVd/alS+Dj13bwFG2HNeE2lLrJFMwlGa4LCsZy\n\tDpKNaw9qcolHgmsM59MYx4xH8rC36o+Ikfw7oUnazUu53q3NAOt/YSyo+G2D7O3ErzyR\n\tvk/8Vqit4Mfako2LAkKzriDJyaiVkqopsVZ4Cw0yWFT0lPop8/IdfRHA6X1kiTy+Vd9u\n\tZYQz4He790+im65bLz0E1AjkkJ3RPGkqWQOV2eMHBlRjLc2fi9U5YJhURSn6bLtCE9Qe\n\tVyno/nqGWSVVPayvrw1dBVD8j95BkQqjJdBBum0Du8KqoZftIFAgIqpLG0RJaFUMrlIE\n\tVFHw==","X-Gm-Message-State":"AJIora8Jtm/+twsfWExU/ohS22e80skCd7sI502AynUKAJkCX+rOAeyy\n\tXjHlOn6zNK++gWYy7dj72A4ypJpJsDU1YbYt","X-Google-Smtp-Source":"AGRyM1u0Ig2PP8/NdwgzMHfiDKlGNNwC2DLJcjcbJYN1Ib+07UHAJoKkNRZtarK3OAOb4GXsa1WMZw==","X-Received":"by 2002:a17:902:7d86:b0:16a:53f:4d36 with SMTP id\n\ta6-20020a1709027d8600b0016a053f4d36mr29125219plm.34.1656833648516; \n\tSun, 03 Jul 2022 00:34:08 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Sun,  3 Jul 2022 13:03:54 +0530","Message-Id":"<20220703073358.76643-1-rishikeshdonadkar@gmail.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 1/5] gstreamer: Convert form colorspace\n\tto colorimetry.","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":"Rishikesh Donadkar via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>","Cc":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>,\n\tnicolas.dufresne@collabora.com, vedantparanjape160201@gmail.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Libcamera StreamConfiguration class has colorSpace attribute, which\nholds the colorspace that is being applied to the camera after the\nvalidation of the camera configuration.\n\nMap between the libcamera colorspace and GStreamer colorimetry and find\nthe closest colorimetry corresponding to the colorspace in stream\nconfiguration.\n\nSigned-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n---\n src/gstreamer/gstlibcamera-utils.cpp | 71 ++++++++++++++++++++++++++++\n 1 file changed, 71 insertions(+)","diff":"diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex 3f242286..20c39919 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -45,6 +45,34 @@ static struct {\n \t/* \\todo NV42 is used in libcamera but is not mapped in GStreamer yet. */\n };\n \n+static const std::vector<std::pair<ColorSpace, std::string>> ColorSpaceTocolorimetry = {\n+\t{ ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB },\n+\t{ ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 },\n+\t{ ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 },\n+};\n+\n+static const std::map<ColorSpace::Primaries, GstVideoColorPrimaries> ToGstVideoColorPrimaries = {\n+\t{ ColorSpace::Primaries::Smpte170m, GST_VIDEO_COLOR_PRIMARIES_SMPTE170M },\n+\t{ ColorSpace::Primaries::Rec709, GST_VIDEO_COLOR_PRIMARIES_BT709 },\n+\t{ ColorSpace::Primaries::Rec2020, GST_VIDEO_COLOR_PRIMARIES_BT2020 },\n+};\n+\n+static const std::map<ColorSpace::TransferFunction, GstVideoTransferFunction> ToGstVideoTransferFunction = {\n+\t{ ColorSpace::TransferFunction::Srgb, GST_VIDEO_TRANSFER_SRGB },\n+\t{ ColorSpace::TransferFunction::Rec709, GST_VIDEO_TRANSFER_BT709 },\n+};\n+\n+static const std::map<ColorSpace::YcbcrEncoding, GstVideoColorMatrix> ToGstVideoColorMatrix = {\n+\t{ ColorSpace::YcbcrEncoding::Rec601, GST_VIDEO_COLOR_MATRIX_BT601 },\n+\t{ ColorSpace::YcbcrEncoding::Rec709, GST_VIDEO_COLOR_MATRIX_BT709 },\n+\t{ ColorSpace::YcbcrEncoding::Rec2020, GST_VIDEO_COLOR_MATRIX_BT2020 },\n+};\n+\n+static const std::map<ColorSpace::Range, GstVideoColorRange> ToGstVideoColorRange = {\n+\t{ ColorSpace::Range::Full, GST_VIDEO_COLOR_RANGE_0_255 },\n+\t{ ColorSpace::Range::Limited, GST_VIDEO_COLOR_RANGE_16_235 },\n+};\n+\n static GstVideoFormat\n pixel_format_to_gst_format(const PixelFormat &format)\n {\n@@ -87,6 +115,49 @@ bare_structure_from_format(const PixelFormat &format)\n \t}\n }\n \n+static const gchar *\n+colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n+{\n+\tconst gchar *colorimetry_str;\n+\tGstVideoColorimetry colorimetry;\n+\n+\tauto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(),\n+\t\t\t\t\t    [&colorSpace](const auto &item) {\n+\t\t\t\t\t\t    return colorSpace == item.first;\n+\t\t\t\t\t    });\n+\tif (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n+\t\tcolorimetry_str = (gchar *)iterColorimetry->second.c_str();\n+\t\treturn colorimetry_str;\n+\t}\n+\n+\tauto iterPrimaries = ToGstVideoColorPrimaries.find(colorSpace->primaries);\n+\tif (iterPrimaries != ToGstVideoColorPrimaries.end())\n+\t\tcolorimetry.primaries = iterPrimaries->second;\n+\telse\n+\t\tcolorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;\n+\n+\tauto iterTransferFunction = ToGstVideoTransferFunction.find(colorSpace->transferFunction);\n+\tif (iterTransferFunction != ToGstVideoTransferFunction.end())\n+\t\tcolorimetry.transfer = iterTransferFunction->second;\n+\telse\n+\t\tcolorimetry.transfer = GST_VIDEO_TRANSFER_UNKNOWN;\n+\n+\tauto iterYcbcrEncoding = ToGstVideoColorMatrix.find(colorSpace->ycbcrEncoding);\n+\tif (iterYcbcrEncoding != ToGstVideoColorMatrix.end())\n+\t\tcolorimetry.matrix = iterYcbcrEncoding->second;\n+\telse\n+\t\tcolorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN;\n+\n+\tauto iterRange = ToGstVideoColorRange.find(colorSpace->range);\n+\tif (iterRange != ToGstVideoColorRange.end())\n+\t\tcolorimetry.range = iterRange->second;\n+\telse\n+\t\tcolorimetry.range = GST_VIDEO_COLOR_RANGE_UNKNOWN;\n+\n+\tcolorimetry_str = gst_video_colorimetry_to_string(&colorimetry);\n+\treturn colorimetry_str;\n+}\n+\n GstCaps *\n gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n {\n","prefixes":["libcamera-devel","v1","1/5"]}