[{"id":32657,"web_url":"https://patchwork.libcamera.org/comment/32657/","msgid":"<173383811547.3135963.14630810186401562216@ping.linuxembedded.co.uk>","date":"2024-12-10T13:41:55","subject":"Re: [PATCH v1 5/6] Documentation: guides: pipeline-handler: Simplify\n\tformat collection","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2024-12-09 17:48:05)\n> I believe a simple range based for loop is easier to understand\n> here than `std::transform()`. Furthermore, using a for loop enables\n> the easy filtering of invalid pixel formats.\n> \n\nI agree, I find the std::transform() difficult to interpret.\n\nI prefer this - but it probably needs to be tested in the vivid pipeline\nhandler and updated on that tree too to keep these consistent.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-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(-)\n> \n> diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst\n> index 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> -- \n> 2.47.1\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 06FE9C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Dec 2024 13:42:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E03F367E87;\n\tTue, 10 Dec 2024 14:41:59 +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 6D72C618AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Dec 2024 14:41:58 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1710D752;\n\tTue, 10 Dec 2024 14:41:26 +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=\"D/hrr8ll\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733838086;\n\tbh=tqO5f1G03xfS1aozBTFUGvQPSFijyA38Vu9ACdDtlQs=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=D/hrr8llc700E0uTATcQft0EKZKa/iE89QMufdPcuUdb/zVRY7JUfJImpSXbSOgGF\n\tovvLxSe8l6EOuXOdlC1ogn2TFYQTuaNf9+ZX+YtlcbEEp7ciD3xlLQI1Nf08En7aYy\n\tYnyll/h6zS6CZvTYFbdMH8M4MuXTkBwr006Gmxmg=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241209174806.283905-5-barnabas.pocze@ideasonboard.com>","References":"<20241209174806.283905-1-barnabas.pocze@ideasonboard.com>\n\t<20241209174806.283905-5-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v1 5/6] Documentation: guides: pipeline-handler: Simplify\n\tformat collection","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 10 Dec 2024 13:41:55 +0000","Message-ID":"<173383811547.3135963.14630810186401562216@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]