[{"id":19399,"web_url":"https://patchwork.libcamera.org/comment/19399/","msgid":"<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>","date":"2021-09-06T07:22:56","subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing buffer","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> When dequeueing a buffer from a V4L2VideoDevice, the number of planes in\n> the FrameBuffer may not match the number of V4L2 buffer planes if the\n> PixelFormat is multi-planar (has multiple colour planes) and the V4L2\n> format is single-planar (has a single buffer plane). In this case, we\n> need to split the single V4L2 buffer plane into FrameBuffer planes. Do\n> so, and add checks to reject invalid V4L2 buffers in case of a driver\n> issue.\n> \n\nWhat checks are those exactly ? The test on the dequeued buffer size ?\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n> Changes since v1:\n> \n> - Reduce indentation\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 53 +++++++++++++++++++++++++++---\n>  1 file changed, 48 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 625d5da40337..0a7fbdb7e011 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include \"libcamera/internal/v4l2_videodevice.h\"\n>  \n> +#include <algorithm>\n>  #include <array>\n>  #include <fcntl.h>\n>  #include <iomanip>\n> @@ -1664,12 +1665,54 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \tbuffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL\n>  \t\t\t\t    + buf.timestamp.tv_usec * 1000ULL;\n>  \n> -\tbuffer->metadata_.planes.clear();\n> -\tif (multiPlanar) {\n> -\t\tfor (unsigned int nplane = 0; nplane < buf.length; nplane++)\n> -\t\t\tbuffer->metadata_.planes.push_back({ planes[nplane].bytesused });\n> +\tif (V4L2_TYPE_IS_OUTPUT(buf.type))\n> +\t\treturn buffer;\n> +\n> +\tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n> +\tFrameMetadata &metadata = buffer->metadata_;\n> +\tmetadata.planes.clear();\n> +\n> +\tif (numV4l2Planes != buffer->planes().size()) {\n> +\t\t/*\n> +\t\t * If we have a multi-planar buffer with a V4L2\n> +\t\t * single-planar format, split the V4L2 buffer across\n> +\t\t * the buffer planes. Only the last plane may have less\n> +\t\t * bytes used than its length.\n> +\t\t */\n> +\t\tif (numV4l2Planes != 1) {\n> +\t\t\tLOG(V4L2, Error)\n> +\t\t\t\t<< \"Invalid number of planes (\" << numV4l2Planes\n> +\t\t\t\t<< \" != \" << buffer->planes().size() << \")\";\n> +\n> +\t\t\tmetadata.status = FrameMetadata::FrameError;\n> +\t\t\treturn buffer;\n> +\t\t}\n> +\n> +\t\tunsigned int bytesused = multiPlanar ? planes[0].bytesused\n> +\t\t\t\t       : buf.bytesused;\n> +\n> +\t\tfor (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> +\t\t\tif (!bytesused) {\n> +\t\t\t\tLOG(V4L2, Error)\n> +\t\t\t\t\t<< \"Dequeued buffer is too small\";\n> +\n> +\t\t\t\tmetadata.status = FrameMetadata::FrameError;\n> +\t\t\t\treturn buffer;\n> +\t\t\t}\n> +\n> +\t\t\tmetadata.planes.push_back({ std::min(plane.length, bytesused) });\n> +\t\t\tbytesused -= metadata.planes.back().bytesused;\n> +\t\t}\n> +\t} else if (multiPlanar) {\n> +\t\t/*\n> +\t\t * If we use the multi-planar API, fill in the planes.\n> +\t\t * The number of planes in the frame buffer and in the\n> +\t\t * V4L2 buffer is guaranteed to be equal at this point.\n> +\t\t */\n> +\t\tfor (unsigned int i = 0; i < numV4l2Planes; ++i)\n> +\t\t\tmetadata.planes.push_back({ planes[i].bytesused });\n>  \t} else {\n> -\t\tbuffer->metadata_.planes.push_back({ buf.bytesused });\n> +\t\tmetadata.planes.push_back({ buf.bytesused });\n>  \t}\n>  \n>  \treturn buffer;\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 C0988BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 07:23:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D8CC6916A;\n\tMon,  6 Sep 2021 09:23:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40C8860503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 09:22:59 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C2DC7317;\n\tMon,  6 Sep 2021 09:22:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"jQp1h6P9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630912978;\n\tbh=kVfxRo6C6pTLJGR/ToQXdO2OuHVTbZW79Hk31Rf4T/M=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=jQp1h6P9t/Y+e9MBI+nXy7+bKpq4MiPTdUObJnkInCheG1l0hBk7xMfRM3AwNiNAP\n\tnBtAkBz1ogLIjJjJoNdJSB+AKCyg/195jHB83uFSdHtq3jRnKIgkFzFGYObIZi2RQJ\n\t8MS5ND8dkgmeKy2UpUfo67o9lS8LTU/9dgKlviQQ=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>","Date":"Mon, 6 Sep 2021 09:22:56 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19431,"web_url":"https://patchwork.libcamera.org/comment/19431/","msgid":"<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>","date":"2021-09-06T11:58:20","subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing buffer","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nOn Mon, Sep 06, 2021 at 09:22:56AM +0200, Jean-Michel Hautbois wrote:\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > When dequeueing a buffer from a V4L2VideoDevice, the number of planes in\n> > the FrameBuffer may not match the number of V4L2 buffer planes if the\n> > PixelFormat is multi-planar (has multiple colour planes) and the V4L2\n> > format is single-planar (has a single buffer plane). In this case, we\n> > need to split the single V4L2 buffer plane into FrameBuffer planes. Do\n> > so, and add checks to reject invalid V4L2 buffers in case of a driver\n> > issue.\n> \n> What checks are those exactly ? The test on the dequeued buffer size ?\n\nYes, and the test on the number of V4L2 planes.\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> > Changes since v1:\n> > \n> > - Reduce indentation\n> > ---\n> >  src/libcamera/v4l2_videodevice.cpp | 53 +++++++++++++++++++++++++++---\n> >  1 file changed, 48 insertions(+), 5 deletions(-)\n> > \n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index 625d5da40337..0a7fbdb7e011 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -7,6 +7,7 @@\n> >  \n> >  #include \"libcamera/internal/v4l2_videodevice.h\"\n> >  \n> > +#include <algorithm>\n> >  #include <array>\n> >  #include <fcntl.h>\n> >  #include <iomanip>\n> > @@ -1664,12 +1665,54 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n> >  \tbuffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL\n> >  \t\t\t\t    + buf.timestamp.tv_usec * 1000ULL;\n> >  \n> > -\tbuffer->metadata_.planes.clear();\n> > -\tif (multiPlanar) {\n> > -\t\tfor (unsigned int nplane = 0; nplane < buf.length; nplane++)\n> > -\t\t\tbuffer->metadata_.planes.push_back({ planes[nplane].bytesused });\n> > +\tif (V4L2_TYPE_IS_OUTPUT(buf.type))\n> > +\t\treturn buffer;\n> > +\n> > +\tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n> > +\tFrameMetadata &metadata = buffer->metadata_;\n> > +\tmetadata.planes.clear();\n> > +\n> > +\tif (numV4l2Planes != buffer->planes().size()) {\n> > +\t\t/*\n> > +\t\t * If we have a multi-planar buffer with a V4L2\n> > +\t\t * single-planar format, split the V4L2 buffer across\n> > +\t\t * the buffer planes. Only the last plane may have less\n> > +\t\t * bytes used than its length.\n> > +\t\t */\n> > +\t\tif (numV4l2Planes != 1) {\n> > +\t\t\tLOG(V4L2, Error)\n> > +\t\t\t\t<< \"Invalid number of planes (\" << numV4l2Planes\n> > +\t\t\t\t<< \" != \" << buffer->planes().size() << \")\";\n> > +\n> > +\t\t\tmetadata.status = FrameMetadata::FrameError;\n> > +\t\t\treturn buffer;\n> > +\t\t}\n> > +\n> > +\t\tunsigned int bytesused = multiPlanar ? planes[0].bytesused\n> > +\t\t\t\t       : buf.bytesused;\n> > +\n> > +\t\tfor (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> > +\t\t\tif (!bytesused) {\n> > +\t\t\t\tLOG(V4L2, Error)\n> > +\t\t\t\t\t<< \"Dequeued buffer is too small\";\n> > +\n> > +\t\t\t\tmetadata.status = FrameMetadata::FrameError;\n> > +\t\t\t\treturn buffer;\n> > +\t\t\t}\n> > +\n> > +\t\t\tmetadata.planes.push_back({ std::min(plane.length, bytesused) });\n> > +\t\t\tbytesused -= metadata.planes.back().bytesused;\n> > +\t\t}\n> > +\t} else if (multiPlanar) {\n> > +\t\t/*\n> > +\t\t * If we use the multi-planar API, fill in the planes.\n> > +\t\t * The number of planes in the frame buffer and in the\n> > +\t\t * V4L2 buffer is guaranteed to be equal at this point.\n> > +\t\t */\n> > +\t\tfor (unsigned int i = 0; i < numV4l2Planes; ++i)\n> > +\t\t\tmetadata.planes.push_back({ planes[i].bytesused });\n> >  \t} else {\n> > -\t\tbuffer->metadata_.planes.push_back({ buf.bytesused });\n> > +\t\tmetadata.planes.push_back({ buf.bytesused });\n> >  \t}\n> >  \n> >  \treturn buffer;","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 9B273BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:58:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3B78D69167;\n\tMon,  6 Sep 2021 13:58:41 +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 EA0E560137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:58:38 +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 82F778AD;\n\tMon,  6 Sep 2021 13:58:38 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LEtDHIMl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630929518;\n\tbh=NYQ0nHVMrJ0Nj01RWwb/E0m9oonNcZtEGMF8TwKyfh8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LEtDHIMl1/XZ1PTbE2yFUMvrZDp3G+aX8qKX+ms8WywtNXjlfkgIDM2Hd/KyxFc4g\n\tiwNMLbQ0fKTobT/Fe8F2Ej9XoddsRztIomCBAB0eT84xpPQDddqh+/w+3uy4DewRw/\n\tQIJKCqVT8N1JkgKuUiUUyjd5cORN0Mq2A0aIQ0rA=","Date":"Mon, 6 Sep 2021 14:58:20 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>\n\t<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing 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>"}},{"id":19447,"web_url":"https://patchwork.libcamera.org/comment/19447/","msgid":"<CAO5uPHO-0QoZkiCJEuQq4NK0_+z2GB3AXZ1XAmSdOXteNPLh+Q@mail.gmail.com>","date":"2021-09-06T13:16:47","subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing buffer","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thank you for the patch.\n\nOn Mon, Sep 6, 2021 at 8:58 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Jean-Michel,\n>\n> On Mon, Sep 06, 2021 at 09:22:56AM +0200, Jean-Michel Hautbois wrote:\n> > On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > > When dequeueing a buffer from a V4L2VideoDevice, the number of planes in\n> > > the FrameBuffer may not match the number of V4L2 buffer planes if the\n> > > PixelFormat is multi-planar (has multiple colour planes) and the V4L2\n> > > format is single-planar (has a single buffer plane). In this case, we\n> > > need to split the single V4L2 buffer plane into FrameBuffer planes. Do\n> > > so, and add checks to reject invalid V4L2 buffers in case of a driver\n> > > issue.\n> >\n> > What checks are those exactly ? The test on the dequeued buffer size ?\n>\n> Yes, and the test on the number of V4L2 planes.\n>\n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > > Changes since v1:\n> > >\n> > > - Reduce indentation\n> > > ---\n> > >  src/libcamera/v4l2_videodevice.cpp | 53 +++++++++++++++++++++++++++---\n> > >  1 file changed, 48 insertions(+), 5 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > > index 625d5da40337..0a7fbdb7e011 100644\n> > > --- a/src/libcamera/v4l2_videodevice.cpp\n> > > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > > @@ -7,6 +7,7 @@\n> > >\n> > >  #include \"libcamera/internal/v4l2_videodevice.h\"\n> > >\n> > > +#include <algorithm>\n> > >  #include <array>\n> > >  #include <fcntl.h>\n> > >  #include <iomanip>\n> > > @@ -1664,12 +1665,54 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n> > >     buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL\n> > >                                 + buf.timestamp.tv_usec * 1000ULL;\n> > >\n> > > -   buffer->metadata_.planes.clear();\n> > > -   if (multiPlanar) {\n> > > -           for (unsigned int nplane = 0; nplane < buf.length; nplane++)\n> > > -                   buffer->metadata_.planes.push_back({ planes[nplane].bytesused });\n> > > +   if (V4L2_TYPE_IS_OUTPUT(buf.type))\n> > > +           return buffer;\n> > > +\n> > > +   unsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n> > > +   FrameMetadata &metadata = buffer->metadata_;\n> > > +   metadata.planes.clear();\n> > > +\n> > > +   if (numV4l2Planes != buffer->planes().size()) {\n> > > +           /*\n> > > +            * If we have a multi-planar buffer with a V4L2\n> > > +            * single-planar format, split the V4L2 buffer across\n> > > +            * the buffer planes. Only the last plane may have less\n> > > +            * bytes used than its length.\n> > > +            */\n> > > +           if (numV4l2Planes != 1) {\n> > > +                   LOG(V4L2, Error)\n> > > +                           << \"Invalid number of planes (\" << numV4l2Planes\n> > > +                           << \" != \" << buffer->planes().size() << \")\";\n> > > +\n> > > +                   metadata.status = FrameMetadata::FrameError;\n> > > +                   return buffer;\n> > > +           }\n> > > +\n> > > +           unsigned int bytesused = multiPlanar ? planes[0].bytesused\n> > > +                                  : buf.bytesused;\n> > > +\n> > > +           for (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> > > +                   if (!bytesused) {\n> > > +                           LOG(V4L2, Error)\n> > > +                                   << \"Dequeued buffer is too small\";\n> > > +\n> > > +                           metadata.status = FrameMetadata::FrameError;\n> > > +                           return buffer;\n> > > +                   }\n> > > +\n> > > +                   metadata.planes.push_back({ std::min(plane.length, bytesused) });\n> > > +                   bytesused -= metadata.planes.back().bytesused;\n> > > +           }\n> > > +   } else if (multiPlanar) {\n> > > +           /*\n> > > +            * If we use the multi-planar API, fill in the planes.\n> > > +            * The number of planes in the frame buffer and in the\n> > > +            * V4L2 buffer is guaranteed to be equal at this point.\n> > > +            */\n> > > +           for (unsigned int i = 0; i < numV4l2Planes; ++i)\n> > > +                   metadata.planes.push_back({ planes[i].bytesused });\n> > >     } else {\n> > > -           buffer->metadata_.planes.push_back({ buf.bytesused });\n> > > +           metadata.planes.push_back({ buf.bytesused });\n> > >     }\n\nI think the latter two cases can be just\n} else {\n  for (unsigned int i = 0; i < numV4l2Planes; ++i)\n      metadata.planes.push_back({ planes[i].bytesused });\n}\n\n\nWith the nit,\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n-Hiro\n> > >\n> > >     return buffer;\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 DE9CBBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 13:17:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A2746916A;\n\tMon,  6 Sep 2021 15:17:00 +0200 (CEST)","from mail-ed1-x529.google.com (mail-ed1-x529.google.com\n\t[IPv6:2a00:1450:4864:20::529])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B3F1D60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 15:16:58 +0200 (CEST)","by mail-ed1-x529.google.com with SMTP id g21so9511792edw.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 06:16:58 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"YGV84apj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=PuEvtPk6IDK5OLe6BH4EHVfsjpyiU9lLPbdGr6Xvies=;\n\tb=YGV84apjYDq1hsM9UT1G1Q7rgSDJk7aKrtCYSc+FEUxkrLZUChL8W2b6DhN7v/ZKq3\n\tIguHotcOcS4aQpuR88vyEAhjZRDAEmk1qyT04nQzK2WjjbClIJoKur9DmNcM7L0w3BJB\n\tygK4E7VPtE99tAeBC8nxQKuHD+hzJcgZQR52Q=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=PuEvtPk6IDK5OLe6BH4EHVfsjpyiU9lLPbdGr6Xvies=;\n\tb=CDluqJ8ysMFKqVTVSW0/vcLarMoMgtLPQga4kyYOBzwhc86GC9wi6fRXMWqqQXYRv7\n\tTudhk1Q3Ws/xSy6qqXDiy/kBCA6zPkICAI7Uei6nKePC5zBGFM226uQHA4H7Na1EQMkN\n\tKGzUZeUNgLYb1eJSlNRzr29hj8467Qx5Ss/7QrJguCRnYzX6FESc8s+fG6LlJEuljtfM\n\t6NG/ZJUUGk/i546sEaBkoC4NNXGmCFRD64k2lrKoLWR9b4X5mPqyYKQ01Ce7IGillhSl\n\tiLyw1fVNDdgyAyHtElQRnjSx0daMgfH8u4f0ajh/SO9wKD8qX+pSBkF1Uzce+hvFiTmv\n\tstWw==","X-Gm-Message-State":"AOAM531JIkQ0i2tx6la9tKQZyMBnL1vNCTipzRTDNamCCmaNVza0ky1R\n\t0an9vKSk2hvIY/llkHKEcmqYy7Uo+k3DQ0Pt1CvvMQ==","X-Google-Smtp-Source":"ABdhPJx/8QxiQRJsGdIUFUbD5BDI/NsW9pXgiRQi3YaSEuE3HJLtnhXzrBcshjqW9Kzddxeh+Ty2UJ1LCFuTT3rSTnU=","X-Received":"by 2002:a50:f1c6:: with SMTP id\n\ty6mr13055697edl.354.1630934218231; \n\tMon, 06 Sep 2021 06:16:58 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>\n\t<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>\n\t<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>","In-Reply-To":"<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 22:16:47 +0900","Message-ID":"<CAO5uPHO-0QoZkiCJEuQq4NK0_+z2GB3AXZ1XAmSdOXteNPLh+Q@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing 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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19453,"web_url":"https://patchwork.libcamera.org/comment/19453/","msgid":"<YTYaFdB7WaGL1AZS@pendragon.ideasonboard.com>","date":"2021-09-06T13:39:33","subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing buffer","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nOn Mon, Sep 06, 2021 at 10:16:47PM +0900, Hirokazu Honda wrote:\n> On Mon, Sep 6, 2021 at 8:58 PM Laurent Pinchart wrote:\n> > On Mon, Sep 06, 2021 at 09:22:56AM +0200, Jean-Michel Hautbois wrote:\n> > > On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > > > When dequeueing a buffer from a V4L2VideoDevice, the number of planes in\n> > > > the FrameBuffer may not match the number of V4L2 buffer planes if the\n> > > > PixelFormat is multi-planar (has multiple colour planes) and the V4L2\n> > > > format is single-planar (has a single buffer plane). In this case, we\n> > > > need to split the single V4L2 buffer plane into FrameBuffer planes. Do\n> > > > so, and add checks to reject invalid V4L2 buffers in case of a driver\n> > > > issue.\n> > >\n> > > What checks are those exactly ? The test on the dequeued buffer size ?\n> >\n> > Yes, and the test on the number of V4L2 planes.\n> >\n> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > ---\n> > > > Changes since v1:\n> > > >\n> > > > - Reduce indentation\n> > > > ---\n> > > >  src/libcamera/v4l2_videodevice.cpp | 53 +++++++++++++++++++++++++++---\n> > > >  1 file changed, 48 insertions(+), 5 deletions(-)\n> > > >\n> > > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > > > index 625d5da40337..0a7fbdb7e011 100644\n> > > > --- a/src/libcamera/v4l2_videodevice.cpp\n> > > > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > > > @@ -7,6 +7,7 @@\n> > > >\n> > > >  #include \"libcamera/internal/v4l2_videodevice.h\"\n> > > >\n> > > > +#include <algorithm>\n> > > >  #include <array>\n> > > >  #include <fcntl.h>\n> > > >  #include <iomanip>\n> > > > @@ -1664,12 +1665,54 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n> > > >     buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL\n> > > >                                 + buf.timestamp.tv_usec * 1000ULL;\n> > > >\n> > > > -   buffer->metadata_.planes.clear();\n> > > > -   if (multiPlanar) {\n> > > > -           for (unsigned int nplane = 0; nplane < buf.length; nplane++)\n> > > > -                   buffer->metadata_.planes.push_back({ planes[nplane].bytesused });\n> > > > +   if (V4L2_TYPE_IS_OUTPUT(buf.type))\n> > > > +           return buffer;\n> > > > +\n> > > > +   unsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n> > > > +   FrameMetadata &metadata = buffer->metadata_;\n> > > > +   metadata.planes.clear();\n> > > > +\n> > > > +   if (numV4l2Planes != buffer->planes().size()) {\n> > > > +           /*\n> > > > +            * If we have a multi-planar buffer with a V4L2\n> > > > +            * single-planar format, split the V4L2 buffer across\n> > > > +            * the buffer planes. Only the last plane may have less\n> > > > +            * bytes used than its length.\n> > > > +            */\n> > > > +           if (numV4l2Planes != 1) {\n> > > > +                   LOG(V4L2, Error)\n> > > > +                           << \"Invalid number of planes (\" << numV4l2Planes\n> > > > +                           << \" != \" << buffer->planes().size() << \")\";\n> > > > +\n> > > > +                   metadata.status = FrameMetadata::FrameError;\n> > > > +                   return buffer;\n> > > > +           }\n> > > > +\n> > > > +           unsigned int bytesused = multiPlanar ? planes[0].bytesused\n> > > > +                                  : buf.bytesused;\n> > > > +\n> > > > +           for (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> > > > +                   if (!bytesused) {\n> > > > +                           LOG(V4L2, Error)\n> > > > +                                   << \"Dequeued buffer is too small\";\n> > > > +\n> > > > +                           metadata.status = FrameMetadata::FrameError;\n> > > > +                           return buffer;\n> > > > +                   }\n> > > > +\n> > > > +                   metadata.planes.push_back({ std::min(plane.length, bytesused) });\n> > > > +                   bytesused -= metadata.planes.back().bytesused;\n> > > > +           }\n> > > > +   } else if (multiPlanar) {\n> > > > +           /*\n> > > > +            * If we use the multi-planar API, fill in the planes.\n> > > > +            * The number of planes in the frame buffer and in the\n> > > > +            * V4L2 buffer is guaranteed to be equal at this point.\n> > > > +            */\n> > > > +           for (unsigned int i = 0; i < numV4l2Planes; ++i)\n> > > > +                   metadata.planes.push_back({ planes[i].bytesused });\n> > > >     } else {\n> > > > -           buffer->metadata_.planes.push_back({ buf.bytesused });\n> > > > +           metadata.planes.push_back({ buf.bytesused });\n> > > >     }\n> \n> I think the latter two cases can be just\n> } else {\n>   for (unsigned int i = 0; i < numV4l2Planes; ++i)\n>       metadata.planes.push_back({ planes[i].bytesused });\n> }\n\nIn the multi planar case, the bytesused value is retrieved from\nplanes[i].bytesused, while in the single planar case, it comes from\nbuf.bytesused.\n\n> With the nit,\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> \n> > > >\n> > > >     return buffer;","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 350CBBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 13:39:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 98A906916C;\n\tMon,  6 Sep 2021 15:39:53 +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 ACA6960137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 15:39:52 +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 06D9F8AD;\n\tMon,  6 Sep 2021 15:39:51 +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=\"k0dD1SCb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630935592;\n\tbh=ZoZvFrQelUcbgn04qZN0+zQapWkRur6VfMljceg7k1M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=k0dD1SCbonh4O6YN94KPXKT4N9vGrd6bLkWm/WTZ6j9CaxTyPxB6x674NyRlpyeL5\n\tSD2s6igVjGsgGaYtM8QevOiBi0Rf2RYVlT4hVnDTxZQ1Jcgrs7fWEgilnUtBHjx9Rn\n\tzWD0pzg5BZsjGEIakLAWR7z6HA47B625Xm35Pq+g=","Date":"Mon, 6 Sep 2021 16:39:33 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YTYaFdB7WaGL1AZS@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>\n\t<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>\n\t<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>\n\t<CAO5uPHO-0QoZkiCJEuQq4NK0_+z2GB3AXZ1XAmSdOXteNPLh+Q@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAO5uPHO-0QoZkiCJEuQq4NK0_+z2GB3AXZ1XAmSdOXteNPLh+Q@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing 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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19455,"web_url":"https://patchwork.libcamera.org/comment/19455/","msgid":"<CAO5uPHMA2oG07=Nq_EZnxU24ykJ4-6ygd5qzzitsa4ij__7k_A@mail.gmail.com>","date":"2021-09-06T13:42:36","subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing buffer","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent,\n\nOn Mon, Sep 6, 2021 at 10:39 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Hiro,\n>\n> On Mon, Sep 06, 2021 at 10:16:47PM +0900, Hirokazu Honda wrote:\n> > On Mon, Sep 6, 2021 at 8:58 PM Laurent Pinchart wrote:\n> > > On Mon, Sep 06, 2021 at 09:22:56AM +0200, Jean-Michel Hautbois wrote:\n> > > > On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > > > > When dequeueing a buffer from a V4L2VideoDevice, the number of planes in\n> > > > > the FrameBuffer may not match the number of V4L2 buffer planes if the\n> > > > > PixelFormat is multi-planar (has multiple colour planes) and the V4L2\n> > > > > format is single-planar (has a single buffer plane). In this case, we\n> > > > > need to split the single V4L2 buffer plane into FrameBuffer planes. Do\n> > > > > so, and add checks to reject invalid V4L2 buffers in case of a driver\n> > > > > issue.\n> > > >\n> > > > What checks are those exactly ? The test on the dequeued buffer size ?\n> > >\n> > > Yes, and the test on the number of V4L2 planes.\n> > >\n> > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > > ---\n> > > > > Changes since v1:\n> > > > >\n> > > > > - Reduce indentation\n> > > > > ---\n> > > > >  src/libcamera/v4l2_videodevice.cpp | 53 +++++++++++++++++++++++++++---\n> > > > >  1 file changed, 48 insertions(+), 5 deletions(-)\n> > > > >\n> > > > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > > > > index 625d5da40337..0a7fbdb7e011 100644\n> > > > > --- a/src/libcamera/v4l2_videodevice.cpp\n> > > > > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > > > > @@ -7,6 +7,7 @@\n> > > > >\n> > > > >  #include \"libcamera/internal/v4l2_videodevice.h\"\n> > > > >\n> > > > > +#include <algorithm>\n> > > > >  #include <array>\n> > > > >  #include <fcntl.h>\n> > > > >  #include <iomanip>\n> > > > > @@ -1664,12 +1665,54 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n> > > > >     buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL\n> > > > >                                 + buf.timestamp.tv_usec * 1000ULL;\n> > > > >\n> > > > > -   buffer->metadata_.planes.clear();\n> > > > > -   if (multiPlanar) {\n> > > > > -           for (unsigned int nplane = 0; nplane < buf.length; nplane++)\n> > > > > -                   buffer->metadata_.planes.push_back({ planes[nplane].bytesused });\n> > > > > +   if (V4L2_TYPE_IS_OUTPUT(buf.type))\n> > > > > +           return buffer;\n> > > > > +\n> > > > > +   unsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n> > > > > +   FrameMetadata &metadata = buffer->metadata_;\n> > > > > +   metadata.planes.clear();\n> > > > > +\n> > > > > +   if (numV4l2Planes != buffer->planes().size()) {\n> > > > > +           /*\n> > > > > +            * If we have a multi-planar buffer with a V4L2\n> > > > > +            * single-planar format, split the V4L2 buffer across\n> > > > > +            * the buffer planes. Only the last plane may have less\n> > > > > +            * bytes used than its length.\n> > > > > +            */\n> > > > > +           if (numV4l2Planes != 1) {\n> > > > > +                   LOG(V4L2, Error)\n> > > > > +                           << \"Invalid number of planes (\" << numV4l2Planes\n> > > > > +                           << \" != \" << buffer->planes().size() << \")\";\n> > > > > +\n> > > > > +                   metadata.status = FrameMetadata::FrameError;\n> > > > > +                   return buffer;\n> > > > > +           }\n> > > > > +\n> > > > > +           unsigned int bytesused = multiPlanar ? planes[0].bytesused\n> > > > > +                                  : buf.bytesused;\n> > > > > +\n> > > > > +           for (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> > > > > +                   if (!bytesused) {\n> > > > > +                           LOG(V4L2, Error)\n> > > > > +                                   << \"Dequeued buffer is too small\";\n> > > > > +\n> > > > > +                           metadata.status = FrameMetadata::FrameError;\n> > > > > +                           return buffer;\n> > > > > +                   }\n> > > > > +\n> > > > > +                   metadata.planes.push_back({ std::min(plane.length, bytesused) });\n> > > > > +                   bytesused -= metadata.planes.back().bytesused;\n> > > > > +           }\n> > > > > +   } else if (multiPlanar) {\n> > > > > +           /*\n> > > > > +            * If we use the multi-planar API, fill in the planes.\n> > > > > +            * The number of planes in the frame buffer and in the\n> > > > > +            * V4L2 buffer is guaranteed to be equal at this point.\n> > > > > +            */\n> > > > > +           for (unsigned int i = 0; i < numV4l2Planes; ++i)\n> > > > > +                   metadata.planes.push_back({ planes[i].bytesused });\n> > > > >     } else {\n> > > > > -           buffer->metadata_.planes.push_back({ buf.bytesused });\n> > > > > +           metadata.planes.push_back({ buf.bytesused });\n> > > > >     }\n> >\n> > I think the latter two cases can be just\n> > } else {\n> >   for (unsigned int i = 0; i < numV4l2Planes; ++i)\n> >       metadata.planes.push_back({ planes[i].bytesused });\n> > }\n>\n> In the multi planar case, the bytesused value is retrieved from\n> planes[i].bytesused, while in the single planar case, it comes from\n> buf.bytesused.\n>\n\nAh, right. Thanks. I missed it.\n\n> > With the nit,\n> > Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> >\n> > > > >\n> > > > >     return buffer;\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 A02BBBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 13:42:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 540C66916A;\n\tMon,  6 Sep 2021 15:42:49 +0200 (CEST)","from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com\n\t[IPv6:2a00:1450:4864:20::52b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B07160137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 15:42:48 +0200 (CEST)","by mail-ed1-x52b.google.com with SMTP id z19so9571547edi.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 06:42:48 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"KECvze0m\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=kg5slebWsjVNenwyzBAfnlbWd/0ad4zlmZueoyIl2SA=;\n\tb=KECvze0mApuSU61ulcEKcGsqgiGp9M8me22sDyhvlenBRoFgyj55FBOaLcJ9oKAyBI\n\ttl2MUKOA7En5sjamUzfMMUJLlg94PzGaSF969umVz4I9yXsOWXuY8qFIYlF9w+O8qX0v\n\tJ5OtxqwMRSP6xCq8AEBoj/5OAxQj2f20IsVaY=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=kg5slebWsjVNenwyzBAfnlbWd/0ad4zlmZueoyIl2SA=;\n\tb=ifWy92ASSB4eCQF6TGE/oXGKahsbbNqNkfqos4yJRMSb+2nyZqozMIOVp2kJaRfFqT\n\tHDBAhrwMufRcNW7ePT66xEiO8ZZSqnV4xgEO+09+W+U/kdaDKqmRzIo2FURrKfi9C1OP\n\teCz2nIhjP6Ptkstl5OJ8QBaMve4EPv3yvkB9/mD0b5ZYQeWMl46n1/LwaDyBxL8m48m+\n\tVf8gKxIRUkhFr7AM9LSSDoOhKG2kWp9RRoIPBOLgb0cqLc3RZxLkjEtN5yPkOgbz3NYI\n\tM61Ga5E+tm12694OorGgoehRMStZSrsPfZDG6gIGDzsRiYSKr9S6z69U1+Ep2NAowXsf\n\tp9XA==","X-Gm-Message-State":"AOAM531D7jGm9l9aL6khGCN8dUsulmUfKKeglREN958PgCFG5M/cycWF\n\tVJBx0+XcHT1GtyQF/PItZRg9ZYMy7eWODbU8THg6QA==","X-Google-Smtp-Source":"ABdhPJxixlT371znpynHJyLF9zWPeTK26RZDlMCSCZvFrSbyIA85slOGhbBKXAZBDWre9TBMbGt507p5XGUwiO9D2rs=","X-Received":"by 2002:a05:6402:1385:: with SMTP id\n\tb5mr13099320edv.276.1630935767764; \n\tMon, 06 Sep 2021 06:42:47 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-15-laurent.pinchart@ideasonboard.com>\n\t<3e06e3d9-f94a-251f-0684-cc7bed688e53@ideasonboard.com>\n\t<YTYCXGI1sHAOyX84@pendragon.ideasonboard.com>\n\t<CAO5uPHO-0QoZkiCJEuQq4NK0_+z2GB3AXZ1XAmSdOXteNPLh+Q@mail.gmail.com>\n\t<YTYaFdB7WaGL1AZS@pendragon.ideasonboard.com>","In-Reply-To":"<YTYaFdB7WaGL1AZS@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 22:42:36 +0900","Message-ID":"<CAO5uPHMA2oG07=Nq_EZnxU24ykJ4-6ygd5qzzitsa4ij__7k_A@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 14/27] libcamera: v4l2_videodevice:\n\tSplit planes when dequeuing 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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]