Patch Detail
Show a patch.
GET /api/patches/13683/?format=api
{ "id": 13683, "url": "https://patchwork.libcamera.org/api/patches/13683/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13683/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210906225636.14683-16-laurent.pinchart@ideasonboard.com>", "date": "2021-09-06T22:56:22", "name": "[libcamera-devel,v3,16/30] libcamera: framebuffer: Allocate metadata planes at construction time", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "4fe6af6344a94c6fec381fcfa5d4e80e95c92a43", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13683/mbox/", "series": [ { "id": 2482, "url": "https://patchwork.libcamera.org/api/series/2482/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2482", "date": "2021-09-06T22:54:20", "name": "libcamera: Handle fallout of FrameBuffer offset support", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2482/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13683/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13683/checks/", "tags": {}, "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 7DFC4BE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 6 Sep 2021 22:57:41 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A349869176;\n\tTue, 7 Sep 2021 00:57:40 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 659A86917B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 7 Sep 2021 00:57:05 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F190A891;\n\tTue, 7 Sep 2021 00:57:04 +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=\"VhmXhv56\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630969025;\n\tbh=FQRh8jtBYRQJEcnoB04QAkbbvLALlkPZpcwtBAk8UnY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VhmXhv56SkWQwQhQ8L2VrvH8gFlpoONpUX/PQN/qCUC4M/q6Da2LvuaQVwxPpOECE\n\tRTqs9HHRHox1wrzjPKJujFYrUpmY69y1rujiBvoiXq8AHzDDrKEx0qVUc06rHQMknI\n\tSRwq1427i2m522/6d6zAwl0r1kn4iQff5+XyHcUk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 7 Sep 2021 01:56:22 +0300", "Message-Id": "<20210906225636.14683-16-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>", "References": "<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 16/30] libcamera: framebuffer: Allocate\n\tmetadata planes at construction time", "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>" }, "content": "The metadata planes are allocated by V4L2VideoDevice when dequeuing a\nbuffer. This causes the metadata planes to only be allocated after a\nbuffer gets dequeued, and doesn't provide any strong guarantee that\ntheir number matches the number of FrameBuffer planes. The lack of this\ninvariant makes the FrameBuffer class fragile.\n\nAs a first step towards fixing this, allocate the metadata planes when\nthe FrameBuffer is constructed. The FrameMetadata API should be further\nimproved by preventing a change in the number of planes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n---\nChanges since v1:\n\n- Return buffer with state set to FrameError on error\n---\n src/libcamera/framebuffer.cpp | 2 ++\n src/libcamera/v4l2_videodevice.cpp | 10 +++++-----\n 2 files changed, 7 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex e71c2ffae034..e4f8419a9063 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -210,6 +210,8 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n \t: Extensible(std::make_unique<Private>()), planes_(planes),\n \t cookie_(cookie)\n {\n+\tmetadata_.planes.resize(planes_.size());\n+\n \tunsigned int offset = 0;\n \tbool isContiguous = true;\n \tino_t inode = 0;\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 281f3f13fc9c..81209e485c24 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1675,7 +1675,6 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\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@@ -1705,8 +1704,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\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\tmetadata.planes[i].bytesused =\n+\t\t\t\tstd::min(plane.length, bytesused);\n+\t\t\tbytesused -= metadata.planes[i].bytesused;\n \t\t}\n \t} else if (multiPlanar) {\n \t\t/*\n@@ -1715,9 +1715,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\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\t\tmetadata.planes[i].bytesused = planes[i].bytesused;\n \t} else {\n-\t\tmetadata.planes.push_back({ buf.bytesused });\n+\t\tmetadata.planes[0].bytesused = buf.bytesused;\n \t}\n \n \treturn buffer;\n", "prefixes": [ "libcamera-devel", "v3", "16/30" ] }