{"id":22266,"url":"https://patchwork.libcamera.org/api/1.1/patches/22266/?format=json","web_url":"https://patchwork.libcamera.org/patch/22266/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241209174806.283905-5-barnabas.pocze@ideasonboard.com>","date":"2024-12-09T17:48:05","name":"[v1,5/6] Documentation: guides: pipeline-handler: Simplify format collection","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4a5330aa8255f5979ca36242f553b52c2257a4fd","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22266/mbox/","series":[{"id":4869,"url":"https://patchwork.libcamera.org/api/1.1/series/4869/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4869","date":"2024-12-09T17:48:01","name":"[v1,1/6] Documentation: guides: pipeline-handler: Fix camera creation","version":1,"mbox":"https://patchwork.libcamera.org/series/4869/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22266/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22266/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 D3C1CBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Dec 2024 17:48:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 62CE167E78;\n\tMon,  9 Dec 2024 18:48:20 +0100 (CET)","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 AC47867E70\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Dec 2024 18:48:12 +0100 (CET)","from pb-laptop.local (185.221.143.90.nat.pool.zt.hu\n\t[185.221.143.90])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 04E8E352\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Dec 2024 18:47:40 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eH1YHlrB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733766461;\n\tbh=4VZNf5jdzfDC7xoWfALBPaWKz9TzBRsZDhpukgxGsAw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=eH1YHlrBkxEezK1zEeIvopWseHxfSFc31fjo740v25dMayluQsX+Efn4XKDihLN6V\n\tIGivJw2ksdxYv6FKeSVwIJk0Gf1W5O51nfH+eGXDgwxryuFwyIsOgCX5chYSrnz+zu\n\tTU2ppuiLOUBuj2qPFXeEbc8/4snMUM4CejuhEek0=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1 5/6] Documentation: guides: pipeline-handler: Simplify\n\tformat collection","Date":"Mon,  9 Dec 2024 18:48:05 +0100","Message-ID":"<20241209174806.283905-5-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.47.1","In-Reply-To":"<20241209174806.283905-1-barnabas.pocze@ideasonboard.com>","References":"<20241209174806.283905-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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>"},"content":"I believe a simple range based for loop is easier to understand\nhere than `std::transform()`. Furthermore, using a for loop enables\nthe easy filtering of invalid pixel formats.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n Documentation/guides/pipeline-handler.rst | 18 +++++++-----------\n 1 file changed, 7 insertions(+), 11 deletions(-)","diff":"diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst\nindex b65145e3a..a798733db 100644\n--- a/Documentation/guides/pipeline-handler.rst\n+++ b/Documentation/guides/pipeline-handler.rst\n@@ -827,9 +827,7 @@ To generate a ``StreamConfiguration``, you need a list of pixel formats and\n frame sizes which are supported as outputs of the stream. You can fetch a map of\n the ``V4LPixelFormat`` and ``SizeRange`` supported by the underlying output\n device, but the pipeline handler needs to convert this to a\n-``libcamera::PixelFormat`` type to pass to applications. We do this here using\n-``std::transform`` to convert the formats and populate a new ``PixelFormat`` map\n-as shown below.\n+``libcamera::PixelFormat`` type to pass to applications.\n \n Continue adding the following code example to our ``generateConfiguration``\n implementation.\n@@ -839,14 +837,12 @@ implementation.\n    std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =\n            data->video_->formats();\n    std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n-   std::transform(v4l2Formats.begin(), v4l2Formats.end(),\n-          std::inserter(deviceFormats, deviceFormats.begin()),\n-          [&](const decltype(v4l2Formats)::value_type &format) {\n-              return decltype(deviceFormats)::value_type{\n-                  format.first.toPixelFormat(),\n-                  format.second\n-              };\n-          });\n+\n+   for (auto &[v4l2PixelFormat, sizes] : v4l2Formats) {\n+           PixelFormat pixelFormat = v4l2PixelFormat.toPixelFormat();\n+           if (pixelFormat.isValid())\n+                   deviceFormats.try_emplace(pixelFormat, std::move(sizes));\n+   }\n \n The `StreamFormats`_ class holds information about the pixel formats and frame\n sizes that a stream can support. The class groups size information by the pixel\n","prefixes":["v1","5/6"]}