[{"id":15796,"web_url":"https://patchwork.libcamera.org/comment/15796/","msgid":"<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","date":"2021-03-22T19:31:20","subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le lundi 22 mars 2021 à 11:42 +0100, Marian Cichy a écrit :\n> Access the frame duration from the controlList of the stream\n> configuration and convert it to values fitting for GST_FRACTION. By\n> setting the frame rate to the caps configuration, the Gstreamer pipeline\n> has information about the camera frame rate, which can be potentially\n> used for more efficient memory allocation or for debug purposes.\n> \n> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>\n> ---\n>  src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++\n>  1 file changed, 7 insertions(+)\n> \n> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> index 5381dca5..fdd8b85c 100644\n> --- a/src/gstreamer/gstlibcamera-utils.cpp\n> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> @@ -8,6 +8,7 @@\n>  \n> \n> \n> \n>  #include \"gstlibcamera-utils.h\"\n>  \n> >\n> +#include <libcamera/control_ids.h>\n>  #include <libcamera/formats.h>\n>  \n>  using namespace libcamera;\n> @@ -128,10 +129,16 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg\n>  {\n>  \tGstCaps *caps = gst_caps_new_empty();\n>  \tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n> +\tint numerator;\n> +\tint denominator;\n> +\tdouble framerate = 1'000'000 / static_cast<double>(stream_cfg.controls.get(\n> +\t\t\t\tcontrols::FrameDurations)[0]);\n\nPerhaps that would be defensive, but I'm worried duration might be 0, which\nwould crash here.\n\nCan you explain the array of duration, and why we know that the first item exist\n(to we don't overrun the array) and will be the selected one ?\n\n> \n>  +\tgst_util_double_to_fraction(framerate, &numerator, &denominator);\n>  \tgst_structure_set(s,\n>  \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n>  \t\t\t  \"height\", G_TYPE_INT, stream_cfg.size.height,\n> +\t\t\t  \"framerate\", GST_TYPE_FRACTION, numerator, denominator,\n\nIf duration is 0, this should be skipped, or set to 0/1 (which means variable\nframerate in GStreamer).\n\n>  \t\t\t  nullptr);\n>  \tgst_caps_append_structure(caps, s);\n>  \n> \n> \n> \n> \n> \n> \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 0AE92C32E1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Mar 2021 19:31:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 68D1B68D62;\n\tMon, 22 Mar 2021 20:31:24 +0100 (CET)","from mail-qk1-x730.google.com (mail-qk1-x730.google.com\n\t[IPv6:2607:f8b0:4864:20::730])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1239968D50\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 20:31:23 +0100 (CET)","by mail-qk1-x730.google.com with SMTP id i9so11825217qka.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 12:31:22 -0700 (PDT)","from nicolas-tpx395.lan (173-246-12-168.qc.cable.ebox.net.\n\t[173.246.12.168]) by smtp.gmail.com with ESMTPSA id\n\ta19sm11797887qkl.126.2021.03.22.12.31.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 22 Mar 2021 12:31:21 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ndufresne-ca.20150623.gappssmtp.com\n\theader.i=@ndufresne-ca.20150623.gappssmtp.com\n\theader.b=\"tzAnAkm3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=TDs/Zw6vsfp8n3wn9otTiidcA+n7Z8Q72VoEH5+QiZ4=;\n\tb=tzAnAkm3VIHakqNZd1ErKSSy0XDgHdz0xfSFfX3QhSOomJuYzjqZCE88anrhTuCl9t\n\tLCGI1n4hBUpOX/KQsa3VCAFXJhaLqbEZZ2l0rFJivW2fdLTKoRx8hBD1OF49++ED9KcI\n\tBFdP11lyWcjmabGcOW6WONMN5dC20XQXnknvHD9xgXENAtybTXAbsNRRtNk0YjRvoDhp\n\twgLrgg+3Ggl6dWBojE0ZhfB3Ss18uHlGJxi7ev3ut8f6KpcTp8kT3TzaOCxxFAIsWnqN\n\tAJV073tY0W9MrwRxlc19NFEbQ6xeV197UTu3Sotfh1nz5fTro++Izap/HFbyVaNuSo5U\n\t+olg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=TDs/Zw6vsfp8n3wn9otTiidcA+n7Z8Q72VoEH5+QiZ4=;\n\tb=RmJC/RzIO1wfI+RTuKEhri3Ud/jiATp/nzRC0xuUPUUpbqKyv3NH9OrMEVY9az2BIQ\n\tgLy5riP83Ntz78dmAJzi3Izv4V787Dv63io5OOOapPPw1fWpR+5rqc8scb7/OtSVcwUb\n\tJD2s+uz2BzBmPAv/PIDktKnM28ombgnPZqrKGGuAhYFJEukCo8dZXqtEgsj1934LnvAO\n\tV+IFjywwbqemkyKEl3IoSCwCldOBx1pTcM4m1kjKVIQiQffVDSQq5/1lW9F8yFDDfE3x\n\tT6j72NSnK3s/H/yQ3LH6f4Cx6dYnqz1kdHj1/RKvIDZJA3drrNZciaQnr1qx68j855TE\n\tXfsw==","X-Gm-Message-State":"AOAM532m7/dBApZwCMJ2hBtTmQrJsII5EXRRbbpJ22ZGad9xTaX4qxNb\n\tCkCishSDwCTX0ewSwi1XqTYogfV1kSlCID9T","X-Google-Smtp-Source":"ABdhPJy6SvEEdO+4Vxa9C2LdsY/IERtXL1E+svRHhJFm5ajN0XtlCmQWZDy+ejjwca4k7L0bPpp3Cw==","X-Received":"by 2002:a37:b07:: with SMTP id 7mr1592001qkl.437.1616441482019; \n\tMon, 22 Mar 2021 12:31:22 -0700 (PDT)","Message-ID":"<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"Marian Cichy <m.cichy@pengutronix.de>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 22 Mar 2021 15:31:20 -0400","In-Reply-To":"<20210322104242.31107-4-m.cichy@pengutronix.de>","References":"<20210322104242.31107-1-m.cichy@pengutronix.de>\n\t<20210322104242.31107-4-m.cichy@pengutronix.de>","User-Agent":"Evolution 3.38.4 (3.38.4-1.fc33) ","MIME-Version":"1.0","Subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","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>","Cc":"graphics@pengutronix.de","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15797,"web_url":"https://patchwork.libcamera.org/comment/15797/","msgid":"<b593b78b-e189-a4e5-e967-2400d55f167b@pengutronix.de>","date":"2021-03-22T19:37:40","subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","submitter":{"id":81,"url":"https://patchwork.libcamera.org/api/people/81/","name":"Marian Cichy","email":"mci@pengutronix.de"},"content":"On 3/22/21 8:31 PM, Nicolas Dufresne wrote:\n> Le lundi 22 mars 2021 à 11:42 +0100, Marian Cichy a écrit :\n>> Access the frame duration from the controlList of the stream\n>> configuration and convert it to values fitting for GST_FRACTION. By\n>> setting the frame rate to the caps configuration, the Gstreamer pipeline\n>> has information about the camera frame rate, which can be potentially\n>> used for more efficient memory allocation or for debug purposes.\n>>\n>> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>\n>> ---\n>>   src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++\n>>   1 file changed, 7 insertions(+)\n>>\n>> diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n>> index 5381dca5..fdd8b85c 100644\n>> --- a/src/gstreamer/gstlibcamera-utils.cpp\n>> +++ b/src/gstreamer/gstlibcamera-utils.cpp\n>> @@ -8,6 +8,7 @@\n>>   \n>>\n>>\n>>\n>>   #include \"gstlibcamera-utils.h\"\n>>   \n>> +#include <libcamera/control_ids.h>\n>>   #include <libcamera/formats.h>\n>>   \n>>   using namespace libcamera;\n>> @@ -128,10 +129,16 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg\n>>   {\n>>   \tGstCaps *caps = gst_caps_new_empty();\n>>   \tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n>> +\tint numerator;\n>> +\tint denominator;\n>> +\tdouble framerate = 1'000'000 / static_cast<double>(stream_cfg.controls.get(\n>> +\t\t\t\tcontrols::FrameDurations)[0]);\n> Perhaps that would be defensive, but I'm worried duration might be 0, which\n> would crash here.\n\n\nNoted\n\n\n>\n> Can you explain the array of duration, and why we know that the first item exist\n> (to we don't overrun the array) and will be the selected one ?\n\n\nBy definition of the auto-generated controls, FrameDurations is a \nuint64_t[2] where [0] is the minFrameDuration and [1] the \nmaxFrameDuration. I don't think this control can be generated in any \nother way, as libcamera auto-generates these controls.\n\n\n>\n>>   +\tgst_util_double_to_fraction(framerate, &numerator, &denominator);\n>>   \tgst_structure_set(s,\n>>   \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n>>   \t\t\t  \"height\", G_TYPE_INT, stream_cfg.size.height,\n>> +\t\t\t  \"framerate\", GST_TYPE_FRACTION, numerator, denominator,\n> If duration is 0, this should be skipped, or set to 0/1 (which means variable\n> framerate in GStreamer).\n\n\nSkipping seems fine, as Gstreamer seems to default to 0/1, right?\n\n\nMarian\n\n\n>\n>>   \t\t\t  nullptr);\n>>   \tgst_caps_append_structure(caps, s);\n>>   \n>>\n>>\n>>\n>>\n>>\n>>\n>>\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 B9E32BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Mar 2021 19:37:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4524C68D51;\n\tMon, 22 Mar 2021 20:37:42 +0100 (CET)","from metis.ext.pengutronix.de (metis.ext.pengutronix.de\n\t[IPv6:2001:67c:670:201:290:27ff:fe1d:cc33])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B1A568D50\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 20:37:41 +0100 (CET)","from gallifrey.ext.pengutronix.de\n\t([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[127.0.0.1])\n\tby metis.ext.pengutronix.de with esmtp (Exim 4.92)\n\t(envelope-from <mci@pengutronix.de>)\n\tid 1lOQMu-0000df-QS; Mon, 22 Mar 2021 20:37:40 +0100"],"To":"Nicolas Dufresne <nicolas@ndufresne.ca>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210322104242.31107-1-m.cichy@pengutronix.de>\n\t<20210322104242.31107-4-m.cichy@pengutronix.de>\n\t<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","From":"Marian Cichy <mci@pengutronix.de>","Message-ID":"<b593b78b-e189-a4e5-e967-2400d55f167b@pengutronix.de>","Date":"Mon, 22 Mar 2021 20:37:40 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.5.0","MIME-Version":"1.0","In-Reply-To":"<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","Content-Language":"en-US","X-SA-Exim-Connect-IP":"2001:67c:670:201:5054:ff:fe8d:eefb","X-SA-Exim-Mail-From":"mci@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.ext.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","Subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","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>","Cc":"graphics@pengutronix.de","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"utf-8\"; Format=\"flowed\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15798,"web_url":"https://patchwork.libcamera.org/comment/15798/","msgid":"<5c04e17d78f4f6119cc2a36bbef8f19fb1598106.camel@ndufresne.ca>","date":"2021-03-22T20:11:39","subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le lundi 22 mars 2021 à 20:37 +0100, Marian Cichy a écrit :\n> On 3/22/21 8:31 PM, Nicolas Dufresne wrote:\n> > Le lundi 22 mars 2021 à 11:42 +0100, Marian Cichy a écrit :\n> > > Access the frame duration from the controlList of the stream\n> > > configuration and convert it to values fitting for GST_FRACTION. By\n> > > setting the frame rate to the caps configuration, the Gstreamer pipeline\n> > > has information about the camera frame rate, which can be potentially\n> > > used for more efficient memory allocation or for debug purposes.\n> > > \n> > > Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>\n> > > ---\n> > >   src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++\n> > >   1 file changed, 7 insertions(+)\n> > > \n> > > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> > > index 5381dca5..fdd8b85c 100644\n> > > --- a/src/gstreamer/gstlibcamera-utils.cpp\n> > > +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> > > @@ -8,6 +8,7 @@\n> > >   \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > >   #include \"gstlibcamera-utils.h\"\n> > >   \n> > > \n> > > \n> > > \n> > > +#include <libcamera/control_ids.h>\n> > >   #include <libcamera/formats.h>\n> > >   \n> > > \n> > > \n> > > \n> > >   using namespace libcamera;\n> > > @@ -128,10 +129,16 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg\n> > >   {\n> > >   \tGstCaps *caps = gst_caps_new_empty();\n> > >   \tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n> > > +\tint numerator;\n> > > +\tint denominator;\n> > > +\tdouble framerate = 1'000'000 / static_cast<double>(stream_cfg.controls.get(\n> > > +\t\t\t\tcontrols::FrameDurations)[0]);\n> > Perhaps that would be defensive, but I'm worried duration might be 0, which\n> > would crash here.\n> \n> \n> Noted\n> \n> \n> > \n> > Can you explain the array of duration, and why we know that the first item exist\n> > (to we don't overrun the array) and will be the selected one ?\n> \n> \n> By definition of the auto-generated controls, FrameDurations is a \n> uint64_t[2] where [0] is the minFrameDuration and [1] the \n> maxFrameDuration. I don't think this control can be generated in any \n> other way, as libcamera auto-generates these controls.\n\nThanks, I'm not familiar with how libcamera controls have been implemented. This\nlooks a bit strange considering that there is ranges type for width and height\nsomewhere else, but now that I know it's a range, it helps.\n\nThe minimum framerate will trigger the highest latency, so that is definitely\nthe best value to expose in GStreamer.\n\n> \n> \n> > \n> > >   +\tgst_util_double_to_fraction(framerate, &numerator, &denominator);\n> > >   \tgst_structure_set(s,\n> > >   \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n> > >   \t\t\t  \"height\", G_TYPE_INT, stream_cfg.size.height,\n> > > +\t\t\t  \"framerate\", GST_TYPE_FRACTION, numerator, denominator,\n> > If duration is 0, this should be skipped, or set to 0/1 (which means variable\n> > framerate in GStreamer).\n> \n> \n> Skipping seems fine, as Gstreamer seems to default to 0/1, right?\n\nIndeed, both ways do, I think I would set it to 0/1 as it's more explicit that\nwe don't know and what to expect. Users can always force it with videorate\nafterward.\n\n> \n> \n> Marian\n> \n> \n> > \n> > >   \t\t\t  nullptr);\n> > >   \tgst_caps_append_structure(caps, s);\n> > >   \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > > \n> > \n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel","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 D2245BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Mar 2021 20:11:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45A5E68D62;\n\tMon, 22 Mar 2021 21:11:43 +0100 (CET)","from mail-qk1-x733.google.com (mail-qk1-x733.google.com\n\t[IPv6:2607:f8b0:4864:20::733])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 23CD568D50\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 21:11:42 +0100 (CET)","by mail-qk1-x733.google.com with SMTP id y18so11980666qky.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 13:11:42 -0700 (PDT)","from nicolas-tpx395.lan (173-246-12-168.qc.cable.ebox.net.\n\t[173.246.12.168]) by smtp.gmail.com with ESMTPSA id\n\tn2sm9331561qta.61.2021.03.22.13.11.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 22 Mar 2021 13:11:40 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ndufresne-ca.20150623.gappssmtp.com\n\theader.i=@ndufresne-ca.20150623.gappssmtp.com\n\theader.b=\"DLQgPaqG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=dQtT6vhD4zMCQhbdd3Cg+gGql6+mhagBqiH2vIfmtu0=;\n\tb=DLQgPaqGIJxkUKU2b7CHc3CtiKdKmIHcZ65je5+QRgL/nt48sIHPykfs03ImTQWyVn\n\t2chC/zRpb+Tqg7siYolR6HI2ZQhYTqEXCmufKgVzJGXAHJUatPS/wgKM5bKr45aKcRZe\n\tRM2PtZ+CR6m6cvWno4xxMvGakLgwJz4nzvJl3+dAzvQOBjcoo3DidnIquZ6wbYi5WvSX\n\tWPRhL9YfOFEqCxbH4Tf+iXoBWj0jqAtiaX0bYMyUXKEw+mbKJ1QH8BywySCSwF0C9yOM\n\trJR3bpxySwWPVyFFu4ijCkHdGO9Jwue/mf/56OMW84mGGjJ349fgTiCqXWVxgBZT0eJR\n\tPP4Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=dQtT6vhD4zMCQhbdd3Cg+gGql6+mhagBqiH2vIfmtu0=;\n\tb=rlrQvpjSsaelFvZFsvnXqpt1fdwS4Tvj9S66jKSPwgZN+InhDI0xmkVANP7wA/L5Qa\n\tyFveBrSmszGYxN9fW2+3mTBJK2R9VNwwTjOdMn0/nmm6xD75e7k03zzma2ICWMkFbceP\n\tjrS4dh2z5fdsJkmAu7FLV3yvLITy/wTlVh+hzhLeTv/jrPBXl9TS0DPYf51tcoTJbxqH\n\tb1FMgoj/T7C3YMkAIxk4uB7FvNYIvQUV4k9HdRhUtP/QUe/rJhZce/XObVLJPD6cvFF/\n\tDMauojxgbAEOow45i4HK334SvPX8W4EiYJD7V8iO3Omc6dskNz39tNwM0+Jg+o1XaeiS\n\tQV9w==","X-Gm-Message-State":"AOAM533RGB7K7K2skBKKSgQpCYK1TMfjmajS6GFHZ9e72geX6nuK8drr\n\tl8CDYNZDvJ2+N1cLwp8yXJNhZA==","X-Google-Smtp-Source":"ABdhPJyxEmEuVxAZ5pHyuIg7p2ALscdLkURmR+0UJiPckfK636dmQ+gKjv9NNm1XRSQaGN7YO4tkNA==","X-Received":"by 2002:a37:408:: with SMTP id 8mr1856995qke.406.1616443901132; \n\tMon, 22 Mar 2021 13:11:41 -0700 (PDT)","Message-ID":"<5c04e17d78f4f6119cc2a36bbef8f19fb1598106.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"Marian Cichy <mci@pengutronix.de>, libcamera-devel@lists.libcamera.org","Date":"Mon, 22 Mar 2021 16:11:39 -0400","In-Reply-To":"<b593b78b-e189-a4e5-e967-2400d55f167b@pengutronix.de>","References":"<20210322104242.31107-1-m.cichy@pengutronix.de>\n\t<20210322104242.31107-4-m.cichy@pengutronix.de>\n\t<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>\n\t<b593b78b-e189-a4e5-e967-2400d55f167b@pengutronix.de>","User-Agent":"Evolution 3.38.4 (3.38.4-1.fc33) ","MIME-Version":"1.0","Subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","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>","Cc":"graphics@pengutronix.de","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15799,"web_url":"https://patchwork.libcamera.org/comment/15799/","msgid":"<20210322203810.mforcqejqnge7nvs@uno.localdomain>","date":"2021-03-22T20:38:10","subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hello,\n\nOn Mon, Mar 22, 2021 at 03:31:20PM -0400, Nicolas Dufresne wrote:\n> Le lundi 22 mars 2021 à 11:42 +0100, Marian Cichy a écrit :\n> > Access the frame duration from the controlList of the stream\n> > configuration and convert it to values fitting for GST_FRACTION. By\n> > setting the frame rate to the caps configuration, the Gstreamer pipeline\n> > has information about the camera frame rate, which can be potentially\n> > used for more efficient memory allocation or for debug purposes.\n> >\n> > Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>\n> > ---\n> >  src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++\n> >  1 file changed, 7 insertions(+)\n> >\n> > diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\n> > index 5381dca5..fdd8b85c 100644\n> > --- a/src/gstreamer/gstlibcamera-utils.cpp\n> > +++ b/src/gstreamer/gstlibcamera-utils.cpp\n> > @@ -8,6 +8,7 @@\n> >  \n> >\n> >\n> >\n> >  #include \"gstlibcamera-utils.h\"\n> >  \n> > >\n> > +#include <libcamera/control_ids.h>\n> >  #include <libcamera/formats.h>\n> >  \n> >  using namespace libcamera;\n> > @@ -128,10 +129,16 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg\n> >  {\n> >  \tGstCaps *caps = gst_caps_new_empty();\n> >  \tGstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat);\n> > +\tint numerator;\n> > +\tint denominator;\n> > +\tdouble framerate = 1'000'000 / static_cast<double>(stream_cfg.controls.get(\n> > +\t\t\t\tcontrols::FrameDurations)[0]);\n>\n> Perhaps that would be defensive, but I'm worried duration might be 0, which\n> would crash here.\n\nAlso there are no guarantee that FrameDurations is part of the\nstream's control list, so all of this i probably better wrapped in a\n\n        if (stream_cfg.contains(controls::FrameDurations)) {\n        }\n\n>\n> Can you explain the array of duration, and why we know that the first item exist\n> (to we don't overrun the array) and will be the selected one ?\n>\n> >\n> >  +\tgst_util_double_to_fraction(framerate, &numerator, &denominator);\n> >  \tgst_structure_set(s,\n> >  \t\t\t  \"width\", G_TYPE_INT, stream_cfg.size.width,\n> >  \t\t\t  \"height\", G_TYPE_INT, stream_cfg.size.height,\n> > +\t\t\t  \"framerate\", GST_TYPE_FRACTION, numerator, denominator,\n>\n> If duration is 0, this should be skipped, or set to 0/1 (which means variable\n> framerate in GStreamer).\n>\n> >  \t\t\t  nullptr);\n> >  \tgst_caps_append_structure(caps, s);\n> >  \n> >\n> >\n> >\n> >\n> >\n> >\n> >\n>\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 0BDD9BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Mar 2021 20:37:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7CE3F68D51;\n\tMon, 22 Mar 2021 21:37:41 +0100 (CET)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C42B668D50\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 21:37:39 +0100 (CET)","from uno.localdomain (host-82-63-7-72.business.telecomitalia.it\n\t[82.63.7.72]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 3A3211BF203;\n\tMon, 22 Mar 2021 20:37:37 +0000 (UTC)"],"X-Originating-IP":"82.63.7.72","Date":"Mon, 22 Mar 2021 21:38:10 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Message-ID":"<20210322203810.mforcqejqnge7nvs@uno.localdomain>","References":"<20210322104242.31107-1-m.cichy@pengutronix.de>\n\t<20210322104242.31107-4-m.cichy@pengutronix.de>\n\t<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<b3cab48435dd949c60bae9491429b9685aa1898b.camel@ndufresne.ca>","Subject":"Re: [libcamera-devel] [PATCH 3/3] gst: utils: Add framerate to caps","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>","Cc":"libcamera-devel@lists.libcamera.org, graphics@pengutronix.de,\n\tMarian Cichy <m.cichy@pengutronix.de>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]