[{"id":23784,"web_url":"https://patchwork.libcamera.org/comment/23784/","msgid":"<CACGrz-PfyGHn4C7Fbm2=o_RkukhoXZF5BqJV2Okbqj67WDDGMg@mail.gmail.com>","date":"2022-07-07T11:25:37","subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer colorimetry.","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hello Rishikesh,\n\nThanks for the patch.\n\n> gstreamer: convert from libcamera colorspace toGStreamer colorimetry\n\n----^----\nYou might want to fix the subject (s/toGstreamer/to Gstreamer)\n\nOn Thu, Jul 7, 2022 at 11:45 AM Rishikesh Donadkar <\nrishikeshdonadkar@gmail.com> wrote:\n\n> Libcamera StreamConfiguration class has colorSpace attribute, which\n> holds the colorspace that is being applied to the camera after the\n> validation of the camera configuration.\n>\n> Map the libcamera colorspace to GStreamer colorimetry and find\n> the colorimetry corresponding to the colorspace that is being applied to\n> the camera. This colorimetry if found will be pushed in the caps.\n>\n> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp\n> b/src/gstreamer/gstlibcamera-utils.cpp\n> index c97c0d43..60ac8c8e 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -45,6 +45,12 @@ static struct {\n>         /* \\todo NV42 is used in libcamera but is not mapped in GStreamer\n> yet. */\n>  };\n>\n> +static const std::vector<std::pair<ColorSpace, std::string>>\n> ColorSpaceTocolorimetry = {\n>\n\nThis might be a nitpick, but I think the variable name should be\nColorSpaceToColorimetry (can someone confirm this please ?)\n\n\n> +       { ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB },\n> +       { ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 },\n> +       { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 },\n> +};\n> +\n>  static GstVideoFormat\n>  pixel_format_to_gst_format(const PixelFormat &format)\n>  {\n> @@ -87,6 +93,32 @@ bare_structure_from_format(const PixelFormat &format)\n>         }\n>  }\n>\n> +static gchar *\n> +colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n> +{\n> +       gchar *colorimetry_str = nullptr;\n> +       gchar *colorimetry_found = nullptr;\n> +       GstVideoColorimetry colorimetry;\n> +       gboolean isColorimetryValid;\n> +\n> +       auto iterColorimetry =\n> std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(),\n> +                                           [&colorSpace](const auto\n> &item) {\n> +                                                   return colorSpace ==\n> item.first;\n> +                                           });\n> +       if (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n> +               colorimetry_found = (gchar\n> *)iterColorimetry->second.c_str();\n> +               isColorimetryValid =\n> gst_video_colorimetry_from_string(&colorimetry, colorimetry_found);\n> +       }\n> +       if (isColorimetryValid) {\n> +               colorimetry_str =\n> gst_video_colorimetry_to_string(&colorimetry);\n> +               return colorimetry_str;\n> +       } else {\n> +               g_free(colorimetry_found);\n>\n\nI don't think you need to free this, it is owned by the string\n(iterColorimetry->second) and it's lifetime will be taken care by the\nstring.\n\n+               g_free(colorimetry_str);\n>\n\n> Frees the memory pointed to by mem. If mem is NULL it simply returns.\n\nUmm, you don't need to free this string here as the if statement above\nnever ran, colorimetry_str is still a nullptr.\n\n+               return nullptr;\n> +       }\n> +}\n> +\n>\n\nSo, now the whole if-else block can be simplified as follows:\n\n+       if (isColorimetryValid) {\n+               colorimetry_str =\ngst_video_colorimetry_to_string(&colorimetry);\n+       }\n+\n+ return colorimetry_str;\n\n GstCaps *\n>  gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n>  {\n> --\n> 2.25.1\n>\n>\nRegards,\nVedant Paranjape","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 5F7EBBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 11:25:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B8C96330D;\n\tThu,  7 Jul 2022 13:25:51 +0200 (CEST)","from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com\n\t[IPv6:2607:f8b0:4864:20::1131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 940B760400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 13:25:50 +0200 (CEST)","by mail-yw1-x1131.google.com with SMTP id\n\t00721157ae682-3137316bb69so166488007b3.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Jul 2022 04:25:50 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657193151;\n\tbh=HBHRII3704XRpKbS8yYyHyRgieONbxKXAJFNYERwEOg=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=NfEd7v2lxspbMFqE8J6aAS6x+7WTNwEHpTnn6nU7JHtG8zkGgDAgp7jbPfB0cEzVH\n\tRlyFXgeVJMZ6oPsEjBVNAW/IGVq401oka1J2U+CZ0sTn2bFg58cbSGC3uXECfAeW0p\n\txlUZIlLgzzBcAG3J5BnebN9M47kmxGhHUBIhFQ1A+Nisbmmhq287QfiPLwaw7y5YUH\n\tZf2bw1MvQvL+UFZKZ6hQqCbPmZpTQp3xNCZ2NwAAAvFrhK6fKmitlUUG/fF1tiuH+l\n\tpku5H07QdacJyQdm6tU41ZcIAuYnfT8igUcccZe4fQbek+3SPzX1PhNlYiCydqOE79\n\tfdvUZtjLFjeKw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=mMpwXWXcFsgpHstziZxz/E03FKOUF/5GQH2saIcT9t4=;\n\tb=qnkFVkX6H4LIW0HE0nnzkExw4aQPMYymx6jh8ROb1HqetOPzFeaKutCky9M7GZc0Bu\n\tejxXuEWor2BaAg72/YHWwtYMFhjwXQ1DsWgcCvEL88yz0FrahRZ61BXpOZg8HLRc71ym\n\tNRuJgQzfgSW5YdhCd8S558xljprXmiDjFBvMUmtYDnskxquo3ci5CeFgJXATmFTAYOnI\n\tTn6yXNiXJfWLEWfRbyOlMvnMNNU0mUY262KWrpL2tkoyBuSIab2pk84D0i4fEdom49du\n\t47uHJz23FQowqSf/2hfsZ1kuyoI1fDEvGSsVBANIUDAEWeJt3BKD8/o9FwMObbsEthZr\n\tVecw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"qnkFVkX6\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=mMpwXWXcFsgpHstziZxz/E03FKOUF/5GQH2saIcT9t4=;\n\tb=4lSVwTAPOkJ7+aPYP4IxV9Bokci6rSdZEl6/oNqaz76HqtfCEqsSo5QlQ49SNzpWpE\n\tSyG/xZqsUz+sOp4eke3JuUgoybtnCfdU2h9qTr3pV2xf9QsU22aVTNY//YQh0TCeslWP\n\tkXrr43i3YfrR8egzyzEaMCJBRTb1vShaiXdb4EaRXl6E8sauqx0p9NApbfGUBk7eW/bY\n\t3IxRgwk/2+J9QMsSocXpvzGyQCvc3tULT/Dc8bhjpYddQ05ay9NitrXrfFnmQ7qVeA6B\n\tksyGCLP++C3tkJrrakRoDrxuMKIc8joSP19s8M5LNof50T3SE7FX/LfgNh4k8Km4dMpa\n\tsngw==","X-Gm-Message-State":"AJIora/4xE8RM4PErCyoG+pck+zjHAa8rnSPNa2Eqg9gel2NGqdKrpDA\n\tc5OUrw+JDb+UvVWu7lu8lGg5b2SgowzaQT3bepY=","X-Google-Smtp-Source":"AGRyM1sLv1oWYeirPGiOA85WQrWfLtXNn/fRTH8ebnk3z1VL3mPLZG/0aLsXW7A2Js4odCdHeQzG8mFP1GF9rqq29ls=","X-Received":"by 2002:a81:f86:0:b0:31c:daf0:8ac8 with SMTP id\n\t128-20020a810f86000000b0031cdaf08ac8mr13285910ywp.275.1657193149250;\n\tThu, 07 Jul 2022 04:25:49 -0700 (PDT)","MIME-Version":"1.0","References":"<20220707094402.28730-1-rishikeshdonadkar@gmail.com>\n\t<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","In-Reply-To":"<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","Date":"Thu, 7 Jul 2022 13:25:37 +0200","Message-ID":"<CACGrz-PfyGHn4C7Fbm2=o_RkukhoXZF5BqJV2Okbqj67WDDGMg@mail.gmail.com>","To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>","Content-Type":"multipart/alternative; boundary=\"000000000000fc436c05e33558a8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer 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":"Vedant Paranjape via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23786,"web_url":"https://patchwork.libcamera.org/comment/23786/","msgid":"<CACGrz-M1o0Dq5jusNdJOZXHamJ-qf4RjxkjqnA2-+9shQ8sXnw@mail.gmail.com>","date":"2022-07-07T11:57:09","subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer colorimetry.","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hello Rishikesh,\n\nI have one more comment relating to Patch 1 and 2.\n\nSince colorimerty_from_colorspace is called in patch 2 only after\ncolorspace has been confirmed to have a value, why not change the\ndatatype of the argument to ColorSpace instead of\nstd::optional<ColorSpace>, you can use ColorSpace.value() to access\nthe value stored in the std::optional.\n\nJust as a footnote, I found this blog useful to understand the\nfunctioning of std::optional:\nhttps://devblogs.microsoft.com/cppblog/stdoptional-how-when-and-why/\n\n+       if (colorspace) {\n+               colorimetry = colorimerty_from_colorspace(co\nlorspace);\n\nOn Thu, Jul 7, 2022 at 11:45 AM Rishikesh Donadkar\n<rishikeshdonadkar@gmail.com> wrote:\n>\n> Libcamera StreamConfiguration class has colorSpace attribute, which\n> holds the colorspace that is being applied to the camera after the\n> validation of the camera configuration.\n>\n> Map the libcamera colorspace to GStreamer colorimetry and find\n> the colorimetry corresponding to the colorspace that is being applied to\n> the camera. This colorimetry if found will be pushed in the caps.\n>\n> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index c97c0d43..60ac8c8e 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -45,6 +45,12 @@ static struct {\n>         /* \\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> +       { ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB },\n> +       { ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 },\n> +       { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 },\n> +};\n> +\n>  static GstVideoFormat\n>  pixel_format_to_gst_format(const PixelFormat &format)\n>  {\n> @@ -87,6 +93,32 @@ bare_structure_from_format(const PixelFormat &format)\n>         }\n>  }\n>\n> +static gchar *\n> +colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n> +{\n> +       gchar *colorimetry_str = nullptr;\n> +       gchar *colorimetry_found = nullptr;\n> +       GstVideoColorimetry colorimetry;\n> +       gboolean isColorimetryValid;\n> +\n> +       auto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(),\n> +                                           [&colorSpace](const auto &item) {\n> +                                                   return colorSpace == item.first;\n> +                                           });\n> +       if (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n> +               colorimetry_found = (gchar *)iterColorimetry->second.c_str();\n> +               isColorimetryValid = gst_video_colorimetry_from_string(&colorimetry, colorimetry_found);\n> +       }\n> +       if (isColorimetryValid) {\n> +               colorimetry_str = gst_video_colorimetry_to_string(&colorimetry);\n> +               return colorimetry_str;\n> +       } else {\n> +               g_free(colorimetry_found);\n> +               g_free(colorimetry_str);\n> +               return nullptr;\n> +       }\n> +}\n> +\n>  GstCaps *\n>  gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n>  {\n> --\n> 2.25.1\n>","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 C4C3DBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 11:57:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2A7C56043F;\n\tThu,  7 Jul 2022 13:57:24 +0200 (CEST)","from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com\n\t[IPv6:2607:f8b0:4864:20::b31])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 09D7060400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 13:57:22 +0200 (CEST)","by mail-yb1-xb31.google.com with SMTP id r3so32077012ybr.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Jul 2022 04:57:21 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657195044;\n\tbh=sT9WE7haPIOJkHy4rUC8zfDWQacg+2TeyA5PQjLaUwc=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=B75ehKrBIdtU9zrdTywCQsb+fOIa+BKMM6o0IQAYknLKtSSODJc1OnDK5ARShmElB\n\tQzGfHeqb4nNldk5ZbGcoc4heV62pV9zIwZPRnn97CVYaa7eWAxaQ6JcLog3cyct9WM\n\tVL3tbr/p94ul4V91UU37niybxB2Yye/o7hyDzkeufVwIL7v+77aAkath/uQtcSwfli\n\tsslEkTLOIXkjn6cXnSRM7UPQSY2EYVs4CpnKPykCqLzVP2ab37U/l1tX/oG4CbZOKb\n\tZM8ItESiz2lAa17fXai+p0kb1kutHOGhDVBNCUtLJhirUptRAkhPolAJLrmw3aes+F\n\tngavb4cdQo8yQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=MUIbOarPZ5V+p9TVREnV+x/Z7zYxilRl6W1r0tokGYY=;\n\tb=M0fa6lj7ezIKS9RfiAPJO8Z5GW303EQug+nAC48/hjy2jJJAsZUAA/CUNCyGl1NA8y\n\tdlxBc1IJ9iOSWtPk6XimUid5jHt6getN3H29PXhpK0OWU8Q3D3EU6uFrlBCcxms+d5ce\n\tAn2yY5nONXkgpwpRONjatBPDfJeNeUpUwN1NYhZ3rkVQOMUTwXP93kreDOM6XJKDSHiA\n\tbCuKOGz31fkkNXvCgAjbxl2buMZPcjlF5lvYzNaMe6VqkW9qDpTrxDZOT4xZhUJQUSKS\n\tYpRkbPer8rvcUj8ZDKCVAQn66PImbPc+pbISd/8pu0qmi3al2PRlfbuCnV1zcR6fAqyv\n\t4ofA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"M0fa6lj7\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=MUIbOarPZ5V+p9TVREnV+x/Z7zYxilRl6W1r0tokGYY=;\n\tb=iQaWA3mv2scsXxxMomNh+Oa6TiEugzKovG1QaLjphNnAPLq1ZapnoNypg20sv0hTE6\n\tcZlJJJx6Rspg73EhTLA0eaQ4xGvM9iMt4Sn4sAy9ggyeP2Wp5iyzWTxQHAkL2x8D6D+E\n\tq7YUboDdNMpD7LNV7CKN9m0dkxGvj9tTDfO7nceeXmYiueSSfn37OU+G8ACOjFdL0QsK\n\tbmgo87dq3G0K49DGnC4kvzy/eN6SS5kkotcd10+qTM93kBSWu+aNRncG+dIBY3Y7nav8\n\t6caPta/AQa/qD9cGHAbMnRYPGrYufI2wRI42xAOgSAak4VvWZLxX7MytvhcgO8xwSs27\n\tXv/w==","X-Gm-Message-State":"AJIora/DWo5FQSiDPndulMCl/SD20DBiYgHnuO1U33bAsY7WWQfUmvaI\n\tCXDMqWLIzGkBsNmtQKVTC8li4c9MBGwP7lvOMg8=","X-Google-Smtp-Source":"AGRyM1t8+y0tFm2PSNZVjFerAgJGLvfAZ5wlEDF14UDysvcXT8omXd29Oya39PBb4kp8MH+7NUqDLYPQf+WaquD2fmU=","X-Received":"by 2002:a25:2604:0:b0:66e:4574:6fee with SMTP id\n\tm4-20020a252604000000b0066e45746feemr24110702ybm.515.1657195040819;\n\tThu, 07 Jul 2022 04:57:20 -0700 (PDT)","MIME-Version":"1.0","References":"<20220707094402.28730-1-rishikeshdonadkar@gmail.com>\n\t<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","In-Reply-To":"<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","Date":"Thu, 7 Jul 2022 13:57:09 +0200","Message-ID":"<CACGrz-M1o0Dq5jusNdJOZXHamJ-qf4RjxkjqnA2-+9shQ8sXnw@mail.gmail.com>","To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer 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":"Vedant Paranjape via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23787,"web_url":"https://patchwork.libcamera.org/comment/23787/","msgid":"<CACGrz-O8vzCso8HZwXRFsjqpGwTNh2hmCSX2bDMP52-8ru83sA@mail.gmail.com>","date":"2022-07-07T12:14:05","subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer colorimetry.","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hello Rishikesh,\n\nOn Thu, Jul 7, 2022 at 11:45 AM Rishikesh Donadkar\n<rishikeshdonadkar@gmail.com> wrote:\n>\n> Libcamera StreamConfiguration class has colorSpace attribute, which\n> holds the colorspace that is being applied to the camera after the\n> validation of the camera configuration.\n>\n> Map the libcamera colorspace to GStreamer colorimetry and find\n> the colorimetry corresponding to the colorspace that is being applied to\n> the camera. This colorimetry if found will be pushed in the caps.\n>\n> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index c97c0d43..60ac8c8e 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -45,6 +45,12 @@ static struct {\n>         /* \\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> +       { ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB },\n> +       { ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 },\n> +       { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 },\n> +};\n> +\n>  static GstVideoFormat\n>  pixel_format_to_gst_format(const PixelFormat &format)\n>  {\n> @@ -87,6 +93,32 @@ bare_structure_from_format(const PixelFormat &format)\n>         }\n>  }\n>\n> +static gchar *\n> +colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n          ------^^^-----\nIt should be colorimetry\n\n> +{\n> +       gchar *colorimetry_str = nullptr;\n> +       gchar *colorimetry_found = nullptr;\n> +       GstVideoColorimetry colorimetry;\n> +       gboolean isColorimetryValid;\n> +\n> +       auto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(),\n> +                                           [&colorSpace](const auto &item) {\n> +                                                   return colorSpace == item.first;\n> +                                           });\n> +       if (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n> +               colorimetry_found = (gchar *)iterColorimetry->second.c_str();\n> +               isColorimetryValid = gst_video_colorimetry_from_string(&colorimetry, colorimetry_found);\n> +       }\n> +       if (isColorimetryValid) {\n> +               colorimetry_str = gst_video_colorimetry_to_string(&colorimetry);\n> +               return colorimetry_str;\n> +       } else {\n> +               g_free(colorimetry_found);\n> +               g_free(colorimetry_str);\n> +               return nullptr;\n> +       }\n> +}\n> +\n>  GstCaps *\n>  gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n>  {\n> --\n> 2.25.1\n>","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 8E2E4BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 12:14:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D5B186330D;\n\tThu,  7 Jul 2022 14:14:18 +0200 (CEST)","from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com\n\t[IPv6:2607:f8b0:4864:20::1133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA86860400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 14:14:17 +0200 (CEST)","by mail-yw1-x1133.google.com with SMTP id\n\t00721157ae682-31c9b70c382so105426087b3.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Jul 2022 05:14:17 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657196058;\n\tbh=ecddJmKRf0LD5+HAriuvpTJjyGsRUYTiygcTYD5S6Sg=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=wvLE9RMuGIrf6PvNcJJ1xkvzNjyCW6B5v6bCNdcCyfqGRcYrlx1h+2m2WFZMUJs4d\n\tJIYgczLVsncNNIAhm3fc97Jvmm7v1QALlPWRa1/lYnMjMww87Xr8v8TPRO1VgZlhUZ\n\te2sqygeOD3HaDQKxwa/FCIQVOyOZJWqdDaaAJwInxmZ17ukdG0ORik3PEvLCvKG8jL\n\tWLLQ8T58NrWxXuQXS6iTFC1CLuCp2wCLyMbhF/81auqymbuHF5KzWSoQGjO4I50zmJ\n\tVBHosBDS5qsnIS7tuxO7ho0Im4Y1LWfyGQ2mLo3tWuX9RkB85tbzZZaPX646ABHuaz\n\t2udtX+fJnj0Iw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=K09yDAyJrBkhg7h9+Q1gJo9tzIg2oNc2IoIeQI7DCV4=;\n\tb=FhVzV9ea1NTyBPnqqZxo2138ZEr8gt79EARb9LBtmhIDxj6z0APFbUa72mZtB+f5cr\n\tD5rftUhcNEHKVtb28vzyXb5eGum5lJjPaxAk19c9rz+BxJQ0UYyL72QcAqWKtMGiIqaR\n\t2bUObophYnmiZjM9SVj0wg20IhsdEz7JOnExu7x4oK+0nnf4r0/AK5STg/pWVJnOycOB\n\tX95AHkVKslKou8hrW7wHBC4K7UkTZp6KAVFrWfi3TxEQQeh8ONsk2BEKEDp5x7HxhKje\n\tj4CnK89xa35MXNxFcOdhKDvLeoVzXnayZTniuXu7h13i/hMaaJlzHZFTVybmMGd/L/1f\n\t/64w=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"FhVzV9ea\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=K09yDAyJrBkhg7h9+Q1gJo9tzIg2oNc2IoIeQI7DCV4=;\n\tb=HWeTqo8/2eU62t800D0u3oEt6tvReW6NZeb35Ple+2clLr5Yh90A+XUDGRqKswSJO/\n\tLJqpi49I8f+8YWnvw3ntVqsHQQd78b+RDV0BUAThcs2WNfwi+loIATuacdhmbXOsRRJr\n\toGPmzOkDwf85fvQyCAA0d9JhP41gZk8uM3qjpvZPMbhH4XHqORxvvtzzv3eAp2PerFcl\n\tNcmXuaxHznxvE4EQuaNAc+ROVuFFalpGlNPbAcHHID+FW9iVybIaLB5XZbdX74kAcnzp\n\tDOgGVYxMEInlquNYs83BE1K/UVuVdBVmI/lVUyC/eZv7R6BQYOGCwNr2qQxL5IuYZwGN\n\tEWUw==","X-Gm-Message-State":"AJIora+ogY6xqdTpdJATc93IzgF6hSyLoQSFiua9pP7L6I68wgWkUOxy\n\tFfq/kMO4RrAYWLnTzvTxRPKxGMcWXHXDE76i1m4=","X-Google-Smtp-Source":"AGRyM1sipp3H/56aLh5XhRAgsNFnhNI61Z9VYhONr3GijeYPJ7BHSqW37hc/f69HqSs5NVhe5+opGIjzuykmVCXS3S4=","X-Received":"by 2002:a81:144:0:b0:31c:af69:28c2 with SMTP id\n\t65-20020a810144000000b0031caf6928c2mr21154581ywb.305.1657196056402;\n\tThu, 07 Jul 2022 05:14:16 -0700 (PDT)","MIME-Version":"1.0","References":"<20220707094402.28730-1-rishikeshdonadkar@gmail.com>\n\t<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","In-Reply-To":"<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","Date":"Thu, 7 Jul 2022 14:14:05 +0200","Message-ID":"<CACGrz-O8vzCso8HZwXRFsjqpGwTNh2hmCSX2bDMP52-8ru83sA@mail.gmail.com>","To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer 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":"Vedant Paranjape via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23788,"web_url":"https://patchwork.libcamera.org/comment/23788/","msgid":"<CACGrz-MVWogGu9=DbK1LwdVhErJuxyGR3G_fbzLQt3aMcQdmcw@mail.gmail.com>","date":"2022-07-07T12:16:07","subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer colorimetry.","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Somehow the pointer to the mistake didn't format as it is visible in\nthe reply ;( About time I stop using Gmail.\n\nOn Thu, Jul 7, 2022 at 2:14 PM Vedant Paranjape\n<vedantparanjape160201@gmail.com> wrote:\n>\n> Hello Rishikesh,\n>\n> On Thu, Jul 7, 2022 at 11:45 AM Rishikesh Donadkar\n> <rishikeshdonadkar@gmail.com> wrote:\n> >\n> > Libcamera StreamConfiguration class has colorSpace attribute, which\n> > holds the colorspace that is being applied to the camera after the\n> > validation of the camera configuration.\n> >\n> > Map the libcamera colorspace to GStreamer colorimetry and find\n> > the colorimetry corresponding to the colorspace that is being applied to\n> > the camera. This colorimetry if found will be pushed in the caps.\n> >\n> > Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n> > ---\n> >  src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++\n> >  1 file changed, 32 insertions(+)\n> >\n> > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> > index c97c0d43..60ac8c8e 100644\n> > --- a/src/gstreamer/gstlibcamera-utils.cpp\n> > +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> > @@ -45,6 +45,12 @@ static struct {\n> >         /* \\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> > +       { ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB },\n> > +       { ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 },\n> > +       { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 },\n> > +};\n> > +\n> >  static GstVideoFormat\n> >  pixel_format_to_gst_format(const PixelFormat &format)\n> >  {\n> > @@ -87,6 +93,32 @@ bare_structure_from_format(const PixelFormat &format)\n> >         }\n> >  }\n> >\n> > +static gchar *\n> > +colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n>           ------^^^-----\n> It should be colorimetry\n>\n> > +{\n> > +       gchar *colorimetry_str = nullptr;\n> > +       gchar *colorimetry_found = nullptr;\n> > +       GstVideoColorimetry colorimetry;\n> > +       gboolean isColorimetryValid;\n> > +\n> > +       auto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(),\n> > +                                           [&colorSpace](const auto &item) {\n> > +                                                   return colorSpace == item.first;\n> > +                                           });\n> > +       if (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n> > +               colorimetry_found = (gchar *)iterColorimetry->second.c_str();\n> > +               isColorimetryValid = gst_video_colorimetry_from_string(&colorimetry, colorimetry_found);\n> > +       }\n> > +       if (isColorimetryValid) {\n> > +               colorimetry_str = gst_video_colorimetry_to_string(&colorimetry);\n> > +               return colorimetry_str;\n> > +       } else {\n> > +               g_free(colorimetry_found);\n> > +               g_free(colorimetry_str);\n> > +               return nullptr;\n> > +       }\n> > +}\n> > +\n> >  GstCaps *\n> >  gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n> >  {\n> > --\n> > 2.25.1\n> >","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 2EC60BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 12:16:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 900B66330E;\n\tThu,  7 Jul 2022 14:16:21 +0200 (CEST)","from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com\n\t[IPv6:2607:f8b0:4864:20::b2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 38F5760400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 14:16:20 +0200 (CEST)","by mail-yb1-xb2e.google.com with SMTP id y195so944468yby.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Jul 2022 05:16:20 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657196181;\n\tbh=lLHjsHoxMOjzZv7Kh2kGbzZU2DOVUBr9y3R9129v7/I=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=qwWWrhFAL53xxaDBhdz5+CN+qeyGszaVWMvLig7BC3hiWksTGe0s6DY9S845jxezi\n\tAXC8uPnXIY0qead8tw9z8dB2uJ/Y9oM/tfWeKcGJo/dkUFmfFLPyJqiOShHKTAoAJf\n\tTqlqugf81DsUuIx0fkbO/4c42fim8AN595/WheT0Ageh7HEAIABQe/6PZIcPz9vY8W\n\txNgUjsH0yb6jDG8nmE4sFkrWvFBXBnmi4giC80dNSOQbrp1bDtPWiiihS3qc4Zlwa4\n\t0rR5U8sWtSrqYj9qPKRIzw19MMtzXOHUS7NG6VuqDvvsiX6NvCNxXGXYGlWcIUirr0\n\tTYRLixz0gDBfA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Em/dVmogY/hqOo98IPlqpboeIlNa/HHsowj+ozZKzRc=;\n\tb=gbLUcW26++7QVQvaepvv6pNFnUx0RiYlxClk+jOQmaekpHuYDeeSKJeUmV5n82P9k1\n\tRAqSj/V9Qoirbzm6vhdVRiJG2vI5p5fs+i4kUhHvhF8hZtS/zHJHShLbmuHYCXrUWLc1\n\t5GcksLmgK49hYmVr0CgVJRpDpR70V9ygcW6vU1HjbRSDO5lrQr6IksEBbWkuFOkT6wX+\n\tby8VgGCJ/nDH+0DYjSyC0IcG9WCg06VRwTuiydYUYds75J6zEKrLhN3nV1pIZk08blH5\n\t9ie8pknBuRis/gFRfC+BXpLqBXIgBFnPh/XtSYfSW93koKmHr3O4ay+ndo22IPNAG5de\n\tcQSA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"gbLUcW26\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Em/dVmogY/hqOo98IPlqpboeIlNa/HHsowj+ozZKzRc=;\n\tb=VpFX/ddr5pTYK2MSye4QsxsVucQaqom65MnNxFP34BStyCBDtdEG88UUwBOFBmXKTd\n\tgA8rXzD20y6evWgoWqtTAQTGPAfA23N+k0mjA6lFwm+QrRsOKJrAVAWO7q1ofcMN0PS1\n\twmgfGK7pkxFQuPdNGEgwgP1AbIbheiIp8OIuDbbZ7+ep3c/22oJwisbNJRe+PMsK7YzD\n\tbOTbbmwt/YHP4g4yX32YF3yCx40vOgbagSCJQXxuAmn41vaUBV7rDzC6Jq5WqW3swXxT\n\tDwCRvVxekdeZXcfpdRRTJ7vZez5VHlaSBf9cd/bW/oCAoVloeeV9Qcyj1zMHlI05+exp\n\t3HPg==","X-Gm-Message-State":"AJIora+kZ5RcBj2HTy+XshTYW3P8sjKJnDyZX3odR0GDuk8J40rWoOy/\n\tJFhyOEBxEqLTbQJ27K3DzfjU9rq/pUXJUa76SG1Mh4CQ","X-Google-Smtp-Source":"AGRyM1vdW1aHAqPZe6ETuAkE3TSS+Lg5xC4nPv9Ws2xvzO6xihcrTMYtY4nnZ601PvZDemL48z/F9RhTlodOyxHafS0=","X-Received":"by 2002:a25:4cd:0:b0:66e:6b7c:7c7c with SMTP id\n\t196-20020a2504cd000000b0066e6b7c7c7cmr17175600ybe.195.1657196178926;\n\tThu, 07 Jul 2022 05:16:18 -0700 (PDT)","MIME-Version":"1.0","References":"<20220707094402.28730-1-rishikeshdonadkar@gmail.com>\n\t<20220707094402.28730-2-rishikeshdonadkar@gmail.com>\n\t<CACGrz-O8vzCso8HZwXRFsjqpGwTNh2hmCSX2bDMP52-8ru83sA@mail.gmail.com>","In-Reply-To":"<CACGrz-O8vzCso8HZwXRFsjqpGwTNh2hmCSX2bDMP52-8ru83sA@mail.gmail.com>","Date":"Thu, 7 Jul 2022 14:16:07 +0200","Message-ID":"<CACGrz-MVWogGu9=DbK1LwdVhErJuxyGR3G_fbzLQt3aMcQdmcw@mail.gmail.com>","To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer 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":"Vedant Paranjape via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23793,"web_url":"https://patchwork.libcamera.org/comment/23793/","msgid":"<45e4f1143226128c6b37357c3be0cb1505c4c582.camel@collabora.com>","date":"2022-07-07T14:00:56","subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer colorimetry.","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Le jeudi 07 juillet 2022 à 15:13 +0530, Rishikesh Donadkar via libcamera-devel a\nécrit :\n> Libcamera StreamConfiguration class has colorSpace attribute, which\n> holds the colorspace that is being applied to the camera after the\n> validation of the camera configuration.\n> \n> Map the libcamera colorspace to GStreamer colorimetry and find\n> the colorimetry corresponding to the colorspace that is being applied to\n> the camera. This colorimetry if found will be pushed in the caps.\n> \n> Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n> \n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index c97c0d43..60ac8c8e 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -45,6 +45,12 @@ 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 GstVideoFormat\n>  pixel_format_to_gst_format(const PixelFormat &format)\n>  {\n> @@ -87,6 +93,32 @@ bare_structure_from_format(const PixelFormat &format)\n>  \t}\n>  }\n>  \n> +static gchar *\n> +colorimerty_from_colorspace(std::optional<ColorSpace> colorSpace)\n> +{\n> +\tgchar *colorimetry_str = nullptr;\n> +\tgchar *colorimetry_found = nullptr;\n> +\tGstVideoColorimetry colorimetry;\n> +\tgboolean isColorimetryValid;\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\nPerhaps more readable if you make a helper libcamera_colorimetry_to_gst_string()\n?\n\n> +\tif (iterColorimetry != ColorSpaceTocolorimetry.end()) {\n> +\t\tcolorimetry_found = (gchar *)iterColorimetry->second.c_str();\n> +\t\tisColorimetryValid = gst_video_colorimetry_from_string(&colorimetry, colorimetry_found);\n> +\t}\n\nI think you should cary the colorimetry structure over, as matching the\ncolorpsace is just a first step, there might be alteration to that colorspace.\n\n> +\tif (isColorimetryValid) {\n> +\t\tcolorimetry_str = gst_video_colorimetry_to_string(&colorimetry);\n> +\t\treturn colorimetry_str;\n> +\t} else {\n> +\t\tg_free(colorimetry_found);\n> +\t\tg_free(colorimetry_str);\n> +\t\treturn nullptr;\n> +\t}\n> +}\n> +\n>  GstCaps *\n>  gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)\n>  {","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 C564ABD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 14:01:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 19CE06330D;\n\tThu,  7 Jul 2022 16:01:07 +0200 (CEST)","from madras.collabora.co.uk (madras.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DFD960400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 16:01:05 +0200 (CEST)","from nicolas-tpx395.localdomain (mtl.collabora.ca [66.171.169.34])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby madras.collabora.co.uk (Postfix) with ESMTPSA id DF1A566019AA;\n\tThu,  7 Jul 2022 15:01:04 +0100 (BST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657202467;\n\tbh=yKkoe11Tz3v/mleCuVMb5Y1FyCezdRkY+KkWlTiizFU=;\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=yT9mnzU010/dfFOCyjuxx2GHbCuD9GKrdWDsdgcakhcDLTiFHl/YYFqcIiVN0SCh/\n\tdMnp74oq9Hp2xJzx8IkctwOdFrFUSrYpmRtyDPGQtQzoW/GMZAZXBvcStiH99ctoG9\n\tBeqkYHsOImSxzPuK+YECJkRG6wDF5hbtek1+2oc13BhBU8OXjUcBDelyRDwQYuLKNG\n\tLGx+m9ognguD86RCwb6G9FD7uijPRKFwjVSHQqZWO0KevzY0VNU5jj3J7k+rJEU8oo\n\tKpM7BPRcbnL7v+CybqbntrZ05lS/dnkisqEoGQBsSdU/AW+kjWmjMUoIwYU2P+0Ouf\n\tv7JgnYIV6eYIg==","v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com;\n\ts=mail; t=1657202465;\n\tbh=yKkoe11Tz3v/mleCuVMb5Y1FyCezdRkY+KkWlTiizFU=;\n\th=Subject:From:To:Cc:Date:In-Reply-To:References:From;\n\tb=nwfiaraOr6rxlUczrx3YUgCDBPg9qLP4SY4/JBWgPPhsvYvo+N36UB67CZTVzjNXm\n\tkZCQ9Dvrn7Wn93VyA0dGYAb5DrStTemrMu/nKACKQ/ZQLyLXkhczSTQRO8e6SaAWBG\n\tPVYVX3gMyjeVizEXBozirQh2SXJeaX0xf7//IL5sp+uC9SdeQRJbSEttAzgqVqD3Ul\n\tPDkeXn99hPRPCX04fxLzCalPGw7jlR7l4hiunYZZ9LnkKHSv8nIp6jga7AnQHGcRE4\n\tAwfjVzNoKrCHrIdcL0txavmQzXZ88VN9p/AY1yHIYFpJ5nNal8DV8e09KnkFPQotQP\n\t75OuD+YNepOjA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=collabora.com\n\theader.i=@collabora.com\n\theader.b=\"nwfiaraO\"; dkim-atps=neutral","Message-ID":"<45e4f1143226128c6b37357c3be0cb1505c4c582.camel@collabora.com>","To":"Rishikesh Donadkar <rishikeshdonadkar@gmail.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 07 Jul 2022 10:00:56 -0400","In-Reply-To":"<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","References":"<20220707094402.28730-1-rishikeshdonadkar@gmail.com>\n\t<20220707094402.28730-2-rishikeshdonadkar@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.44.2 (3.44.2-1.fc36) ","MIME-Version":"1.0","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from\n\tlibcamera colorspace toGStreamer 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":"Nicolas Dufresne via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","Cc":"vedantparanjape160201@gmail.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]