[{"id":14330,"web_url":"https://patchwork.libcamera.org/comment/14330/","msgid":"<X+Zjm2obxtiAvyDv@pendragon.ideasonboard.com>","date":"2020-12-25T22:11:39","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: Add the\n\tfromV4L2PixelFormat method","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sebastian,\n\nThank you for the patch.\n\nOn Wed, Dec 23, 2020 at 01:10:54PM +0100, Sebastian Fricke wrote:\n> Add the method to get the corresponding bayer-format from a given\n> V4L2-pixel-format. Uses the existing mapping table.\n> \n> Signed-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>\n> ---\n>  include/libcamera/internal/bayer_format.h |  1 +\n>  src/libcamera/bayer_format.cpp            | 14 ++++++++++++++\n>  2 files changed, 15 insertions(+)\n> \n> diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\n> index 4280b76b..a8060029 100644\n> --- a/include/libcamera/internal/bayer_format.h\n> +++ b/include/libcamera/internal/bayer_format.h\n> @@ -48,6 +48,7 @@ public:\n>  \tstd::string toString() const;\n>  \n>  \tV4L2PixelFormat toV4L2PixelFormat() const;\n> +\tBayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const;\n\nThis should be a static function as it doesn't access any instance\nmember.\n\n>  \tBayerFormat transform(Transform t) const;\n>  \n>  \tOrder order;\n> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\n> index c42792ff..f4f0e8ca 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -217,6 +217,20 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n>  \treturn V4L2PixelFormat();\n>  }\n>  \n> +/**\n> + * \\brief Convert a V4L2PixelFormat into the corresponding BayerFormat\n> + * \\param[in] v4l2Format The raw format to convert into a BayerFormat\n> + * \\return The BayerFormat corresponding to the V4L2PixelFormat parameter\n> + */\n> +BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const\n> +{\n> +\tconst auto it = v4l2ToBayer.find(v4l2Format);\n> +\tif (it != v4l2ToBayer.end())\n> +\t        return it->second;\n> +\n> +\treturn BayerFormat();\n> +}\n\nThe same thing can be done through the constructor that takes a\nV4L2PixelFormat argument. Could you explain why this function is needed\n? Is this related to the discussion Jacopo and I had on the addition of\na constructor taking a media bus code ?\n\nIf we want to take the route of an explicit static function, I believe\nwe should drop the corresponding constructor as providing both would\nhave little value.\n\n> +\n>  /**\n>   * \\brief Apply a transform to this BayerFormat\n>   * \\param[in] t The transform to apply","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 9C79EC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Dec 2020 22:11:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 254A1615AC;\n\tFri, 25 Dec 2020 23:11:50 +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 4B2B160525\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Dec 2020 23:11:49 +0100 (CET)","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 9FD3B18B7;\n\tFri, 25 Dec 2020 23:11:48 +0100 (CET)"],"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=\"fDKakld0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1608934308;\n\tbh=NKjyAf633Yc47Lk4JlO+LFBvVj2USENZRc2n8rwxu/M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fDKakld0jssRzGVmuesRw98uYEZUaFvrx115kWHcEa1t6rg3LAUnns9/7ZzrHE6Uu\n\tQOiQwYQcXIMQsgP6Kiavpvjzwz3Uu2hb+1IIxvdOEBlv9cKXU8Cp+dMpDQQZY8Ypxf\n\t6mGJF2XcPmJjeerTshVDEqjmU8gXWXzDx4bbZxzQ=","Date":"Sat, 26 Dec 2020 00:11:39 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sebastian Fricke <sebastian.fricke.linux@gmail.com>","Message-ID":"<X+Zjm2obxtiAvyDv@pendragon.ideasonboard.com>","References":"<20201223121055.14178-1-sebastian.fricke.linux@gmail.com>\n\t<20201223121055.14178-2-sebastian.fricke.linux@gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201223121055.14178-2-sebastian.fricke.linux@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: Add the\n\tfromV4L2PixelFormat method","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]