[{"id":35448,"web_url":"https://patchwork.libcamera.org/comment/35448/","msgid":"<933a58de-c6ea-4661-b209-3fd100f09c37@ideasonboard.com>","date":"2025-08-15T12:21:05","subject":"Re: [PATCH v2 1/8] libcamera: v4l2_videodevice: Avoid repeated calls\n\tto FrameBuffer::planes()","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 08. 15. 13:33 keltezéssel, Laurent Pinchart írta:\n> The V4L2VideoDevice::dequeueBuffer() calls buffer->planes() multiple\n> times. Store the planes array in a local variable to make this more\n> efficient.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   src/libcamera/v4l2_videodevice.cpp | 9 +++++----\n>   1 file changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 5b3530b4e542..ba1889a939cb 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1909,9 +1909,10 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>   \t}\n>   \tmetadata.sequence -= firstFrame_.value();\n>   \n> +\tconst std::vector<FrameBuffer::Plane> &framebufferPlanes = buffer->planes();\n>   \tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n>   \n> -\tif (numV4l2Planes != buffer->planes().size()) {\n> +\tif (numV4l2Planes != framebufferPlanes.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> @@ -1921,7 +1922,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\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> +\t\t\t\t<< \" != \" << framebufferPlanes.size() << \")\";\n>   \n>   \t\t\tmetadata.status = FrameMetadata::FrameError;\n>   \t\t\treturn buffer;\n> @@ -1938,12 +1939,12 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>   \t\t\t\t       : buf.bytesused;\n>   \t\tunsigned int remaining = bytesused;\n>   \n> -\t\tfor (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> +\t\tfor (auto [i, plane] : utils::enumerate(framebufferPlanes)) {\n>   \t\t\tif (!remaining) {\n>   \t\t\t\tLOG(V4L2, Error)\n>   \t\t\t\t\t<< \"Dequeued buffer (\" << bytesused\n>   \t\t\t\t\t<< \" bytes) too small for plane lengths \"\n> -\t\t\t\t\t<< utils::join(buffer->planes(), \"/\",\n> +\t\t\t\t\t<< utils::join(framebufferPlanes, \"/\",\n>   \t\t\t\t\t\t       [](const FrameBuffer::Plane &p) {\n>   \t\t\t\t\t\t\t       return p.length;\n>   \t\t\t\t\t\t       });","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 8BE9DBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Aug 2025 12:21:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B4326924E;\n\tFri, 15 Aug 2025 14:21:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DD42E61443\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Aug 2025 14:21:09 +0200 (CEST)","from [192.168.33.21] (185.221.141.188.nat.pool.zt.hu\n\t[185.221.141.188])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9089C56D;\n\tFri, 15 Aug 2025 14:20:14 +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=\"BLvC/Iyy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755260414;\n\tbh=hYaanug5/0snCMQNuTUsAtcp2zhV0rhOFGLL7fc9CaQ=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=BLvC/IyyfzlUquq0P+ONJFE+xnKDvduTLhytc91sxLTdZx3teYaJwRZAn9w0VYqyZ\n\t0iC04+Rg8G6t0HFDIwuo2mBraUOgm0Yi4BndRkqXqIBOHh8ODQ8Gkbz3CH7IERZgLz\n\tK/rs4/Vy+hg6UKMUE1UEJhfm2Ga9Dc3izcwfD3wM=","Message-ID":"<933a58de-c6ea-4661-b209-3fd100f09c37@ideasonboard.com>","Date":"Fri, 15 Aug 2025 14:21:05 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 1/8] libcamera: v4l2_videodevice: Avoid repeated calls\n\tto FrameBuffer::planes()","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"=?utf-8?q?Daniel_R=C3=A1kos?= <daniel.rakos@rastergrid.com>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-2-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250815113400.20623-2-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":35516,"web_url":"https://patchwork.libcamera.org/comment/35516/","msgid":"<z3g57nx2dvj3xqffrn74by3pzgm4ik36pdc55j3xcs2wn54j6g@z3lo5gyjpi2x>","date":"2025-08-19T15:19:07","subject":"Re: [PATCH v2 1/8] libcamera: v4l2_videodevice: Avoid repeated calls\n\tto FrameBuffer::planes()","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Laurent\n\nOn Fri, Aug 15, 2025 at 02:33:53PM +0300, Laurent Pinchart wrote:\n> The V4L2VideoDevice::dequeueBuffer() calls buffer->planes() multiple\n> times. Store the planes array in a local variable to make this more\n> efficient.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 9 +++++----\n>  1 file changed, 5 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 5b3530b4e542..ba1889a939cb 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1909,9 +1909,10 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \t}\n>  \tmetadata.sequence -= firstFrame_.value();\n>\n> +\tconst std::vector<FrameBuffer::Plane> &framebufferPlanes = buffer->planes();\n>  \tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n>\n> -\tif (numV4l2Planes != buffer->planes().size()) {\n> +\tif (numV4l2Planes != framebufferPlanes.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> @@ -1921,7 +1922,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\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> +\t\t\t\t<< \" != \" << framebufferPlanes.size() << \")\";\n>\n>  \t\t\tmetadata.status = FrameMetadata::FrameError;\n>  \t\t\treturn buffer;\n> @@ -1938,12 +1939,12 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \t\t\t\t       : buf.bytesused;\n>  \t\tunsigned int remaining = bytesused;\n>\n> -\t\tfor (auto [i, plane] : utils::enumerate(buffer->planes())) {\n> +\t\tfor (auto [i, plane] : utils::enumerate(framebufferPlanes)) {\n>  \t\t\tif (!remaining) {\n>  \t\t\t\tLOG(V4L2, Error)\n>  \t\t\t\t\t<< \"Dequeued buffer (\" << bytesused\n>  \t\t\t\t\t<< \" bytes) too small for plane lengths \"\n> -\t\t\t\t\t<< utils::join(buffer->planes(), \"/\",\n> +\t\t\t\t\t<< utils::join(framebufferPlanes, \"/\",\n>  \t\t\t\t\t\t       [](const FrameBuffer::Plane &p) {\n>  \t\t\t\t\t\t\t       return p.length;\n>  \t\t\t\t\t\t       });\n> --\n> Regards,\n>\n> Laurent Pinchart\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 1E93BBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Aug 2025 15:19:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57123692D5;\n\tTue, 19 Aug 2025 17:19:13 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4692C692CA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Aug 2025 17:19:11 +0200 (CEST)","from ideasonboard.com (mob-5-90-52-92.net.vodafone.it [5.90.52.92])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D813E1F0E;\n\tTue, 19 Aug 2025 17:18:12 +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=\"YKwbPBTx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755616693;\n\tbh=x2IWp6KhuteRzq4dWxEiOnGaqyAVbeoUlli2UGoHkA8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YKwbPBTxOwbpD0Is3q0aPhn915pIsAsjiCiyPmiKnIxBIUesCqy2KsEMmJTEaiidA\n\tnNVgpAplyOT60tfnhXwnlsDisi2Jz79htz1JJigW93pqfD4ypuJJHmF3ZdhqugHiCI\n\tIwIe0LQ5WVXeDUnmvB5HQb7pgZ2uthyLjE3abPYg=","Date":"Tue, 19 Aug 2025 17:19:07 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Daniel =?utf-8?b?UsOha29z?=\n\t<daniel.rakos@rastergrid.com>","Subject":"Re: [PATCH v2 1/8] libcamera: v4l2_videodevice: Avoid repeated calls\n\tto FrameBuffer::planes()","Message-ID":"<z3g57nx2dvj3xqffrn74by3pzgm4ik36pdc55j3xcs2wn54j6g@z3lo5gyjpi2x>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250815113400.20623-2-laurent.pinchart@ideasonboard.com>","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>"}}]