[{"id":18886,"web_url":"https://patchwork.libcamera.org/comment/18886/","msgid":"<YRxZl7Ypat1NJDL+@pendragon.ideasonboard.com>","date":"2021-08-18T00:51:35","subject":"Re: [libcamera-devel] [RFC PATCH 07/10] gstreamer:\n\tgstlibcameraallocator: Use offset in creating a buffer","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\n(CC'ing Nicolas)\n\nThank you for the patch.\n\nOn Mon, Aug 16, 2021 at 01:31:35PM +0900, Hirokazu Honda wrote:\n> The plane length is the length of the plane size. The buffer length\n> to be allocated for a plane is the offset and the length of\n> FrameBuffer::Plane.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/gstreamer/gstlibcameraallocator.cpp | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp\n> index 7bd8ba2d..a3ffec5b 100644\n> --- a/src/gstreamer/gstlibcameraallocator.cpp\n> +++ b/src/gstreamer/gstlibcameraallocator.cpp\n> @@ -52,7 +52,8 @@ FrameWrap::FrameWrap(GstAllocator *allocator, FrameBuffer *buffer,\n>  \t  outstandingPlanes_(0)\n>  {\n>  \tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> -\t\tGstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.fd(), plane.length,\n> +\t\tGstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.fd(),\n> +\t\t\t\t\t\t\tplane.offset + plane.length,\n\nI'm not familiar enough with GStreamer to know the details, but it seems\nthat there's something problematic here. There's no offset passed to\ngst_fd_allocator_alloc(), so the GstMemory object will \"point\" to the\nbeginning of the dmabuf. When it will then be used, I don't think it\nwill access the plane memory at plane.offset.\n\n>  \t\t\t\t\t\t\tGST_FD_MEMORY_FLAG_DONT_CLOSE);\n>  \t\tgst_mini_object_set_qdata(GST_MINI_OBJECT(mem), getQuark(), this, nullptr);\n>  \t\tGST_MINI_OBJECT(mem)->dispose = gst_libcamera_allocator_release;","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 8BCFDBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Aug 2021 00:51:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E2C0E68894;\n\tWed, 18 Aug 2021 02:51:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A567A6025D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Aug 2021 02:51:43 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 197DF499;\n\tWed, 18 Aug 2021 02:51:43 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"h81Jj1dd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629247903;\n\tbh=NRRk4NArh9ZQXML2FoyXOXBtW2wPH5gJRj+e3c+DOps=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=h81Jj1dd3j4VCW71Ya0y6wGIPZ5dtNvqBZuP2C/udsO2I/sR1ee5VSUF8sm2ZWFf2\n\tVog23sCT/uLed5t096WdScmCgzHJybLKeU58gNb5F4W8TvU5MLrxpPNR31bctVQOqp\n\twbKh6HvslLsAf+P9sxdQl99907YRKwJe+nNOHrvA=","Date":"Wed, 18 Aug 2021 03:51:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YRxZl7Ypat1NJDL+@pendragon.ideasonboard.com>","References":"<20210816043138.957984-1-hiroh@chromium.org>\n\t<20210816043138.957984-8-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210816043138.957984-8-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [RFC PATCH 07/10] gstreamer:\n\tgstlibcameraallocator: Use offset in creating a buffer","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":"Nicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18917,"web_url":"https://patchwork.libcamera.org/comment/18917/","msgid":"<308562aa50addad2084d050740a3e0c6980bd49f.camel@collabora.com>","date":"2021-08-18T13:19:46","subject":"Re: [libcamera-devel] [RFC PATCH 07/10] gstreamer:\n\tgstlibcameraallocator: Use offset in creating a buffer","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Le mercredi 18 août 2021 à 03:51 +0300, Laurent Pinchart a écrit :\n> Hi Hiro,\n> \n> (CC'ing Nicolas)\n> \n> Thank you for the patch.\n> \n> On Mon, Aug 16, 2021 at 01:31:35PM +0900, Hirokazu Honda wrote:\n> > The plane length is the length of the plane size. The buffer length\n> > to be allocated for a plane is the offset and the length of\n> > FrameBuffer::Plane.\n> > \n> > Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> > ---\n> >  src/gstreamer/gstlibcameraallocator.cpp | 3 ++-\n> >  1 file changed, 2 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp\n> > index 7bd8ba2d..a3ffec5b 100644\n> > --- a/src/gstreamer/gstlibcameraallocator.cpp\n> > +++ b/src/gstreamer/gstlibcameraallocator.cpp\n> > @@ -52,7 +52,8 @@ FrameWrap::FrameWrap(GstAllocator *allocator, FrameBuffer *buffer,\n> >  \t  outstandingPlanes_(0)\n> >  {\n> >  \tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> > -\t\tGstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.fd(), plane.length,\n> > +\t\tGstMemory *mem = gst_fd_allocator_alloc(allocator, plane.fd.fd(),\n> > +\t\t\t\t\t\t\tplane.offset + plane.length,\n> \n> I'm not familiar enough with GStreamer to know the details, but it seems\n> that there's something problematic here. There's no offset passed to\n> gst_fd_allocator_alloc(), so the GstMemory object will \"point\" to the\n> beginning of the dmabuf. When it will then be used, I don't think it\n> will access the plane memory at plane.offset.\n\nIndeed, the offset needs to be set using gst_memory_resize() call. Please check\ncorrect the libcamera code, in V4L2, length includes the data offset, so careful\nreview of the v4l2 code seems needed if libcamera uses the opposite semantic.\n\nFor the reference:\n\nhttps://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2allocator.c#L929\n\n> \n> >  \t\t\t\t\t\t\tGST_FD_MEMORY_FLAG_DONT_CLOSE);\n> >  \t\tgst_mini_object_set_qdata(GST_MINI_OBJECT(mem), getQuark(), this, nullptr);\n> >  \t\tGST_MINI_OBJECT(mem)->dispose = gst_libcamera_allocator_release;\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 31753BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Aug 2021 13:19:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D4C568895;\n\tWed, 18 Aug 2021 15:19:57 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BC876888A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Aug 2021 15:19:56 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nicolas) with ESMTPSA id 4ED841F4369A"],"Message-ID":"<308562aa50addad2084d050740a3e0c6980bd49f.camel@collabora.com>","From":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Hirokazu Honda\n\t<hiroh@chromium.org>","Date":"Wed, 18 Aug 2021 09:19:46 -0400","In-Reply-To":"<YRxZl7Ypat1NJDL+@pendragon.ideasonboard.com>","References":"<20210816043138.957984-1-hiroh@chromium.org>\n\t<20210816043138.957984-8-hiroh@chromium.org>\n\t<YRxZl7Ypat1NJDL+@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.40.3 (3.40.3-1.fc34) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [RFC PATCH 07/10] gstreamer:\n\tgstlibcameraallocator: Use offset in creating a buffer","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]