[{"id":25812,"web_url":"https://patchwork.libcamera.org/comment/25812/","msgid":"<20221117103253.f2dkhyvpplba2ssn@uno.localdomain>","date":"2022-11-17T10:32:53","subject":"Re: [libcamera-devel] [PATCH 1/6] libcamera: bayer_format: Add\n\ttoMbusCode method","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi David,\n\nOn Thu, Nov 10, 2022 at 02:45:51PM +0000, David Plowman via libcamera-devel wrote:\n> This makes it easier to perform transformations on Bayer type mbus\n> codes by converting them to a BayerFormat, doing the transform, and\n> then converting them back again.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\n\nExtending the BayerFormat class with an mbusCode_ class member would\navoid the loopup.\n\nAs we have other methods that performs lookups already I can live with this.\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n\n> ---\n>  include/libcamera/internal/bayer_format.h |  1 +\n>  src/libcamera/bayer_format.cpp            | 11 +++++++++++\n>  2 files changed, 12 insertions(+)\n>\n> diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\n> index 78ba3969..3601dccb 100644\n> --- a/include/libcamera/internal/bayer_format.h\n> +++ b/include/libcamera/internal/bayer_format.h\n> @@ -47,6 +47,7 @@ public:\n>  \t}\n>\n>  \tstatic const BayerFormat &fromMbusCode(unsigned int mbusCode);\n> +\tunsigned int toMbusCode() const;\n>  \tbool isValid() const { return bitDepth != 0; }\n>\n>  \tstd::string toString() const;\n> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\n> index f27cc166..fdbc4af1 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -226,6 +226,17 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode)\n>  \t\treturn it->second;\n>  }\n>\n> +/**\n> + * \\brief Retrieve the media bus code corresponding this this BayerFormat\n> + * \\return The corresponding media bus code, or zero if none was found\n> + */\n> +unsigned int BayerFormat::toMbusCode() const\n> +{\n> +\tauto it = std::find_if(mbusCodeToBayer.begin(), mbusCodeToBayer.end(),\n> +\t\t\t       [this](const auto &i) { return i.second == *this; });\n> +\treturn it != mbusCodeToBayer.end() ? it->first : 0;\n> +}\n> +\n>  /**\n>   * \\fn BayerFormat::isValid()\n>   * \\brief Return whether a BayerFormat is valid\n> --\n> 2.30.2\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 9FBEABE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Nov 2022 10:32:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 587976309B;\n\tThu, 17 Nov 2022 11:32:56 +0100 (CET)","from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::224])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CD7761F34\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Nov 2022 11:32:54 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 1B197E0014;\n\tThu, 17 Nov 2022 10:32:53 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1668681176;\n\tbh=b/ms+QY/bQyxFBlAv5Hueq+dWRU8a59enLfrBTHeBNY=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=X3C74nMPA51HjjsGzRiepDWnckYINfAuRjFsj3j4vI995zGe9S/v28zIOvm8mDOwg\n\t9Xizs9XS1LRcmGdXW52qmpBodWU2WIEplZ9si5oNpIXuoFWOqFuJCVdwrAUaQF7oIf\n\tlkCnPDH4+HLPIttuHFES2cAJCex2MZV9RRY4pykjdnm6qM4cIfEvHWiiU82WmZRwry\n\tuEksDiw+0apOOewQZSSrFThXKPEX6SWJp/Dm5bAtud9MgY0df49Sa116ickUH/Grp5\n\tAO/i5N97AMu6KBP9D8zU1bsN0ItRBNJU1g/t/nKguyqnRgLe1OBgtEFuYTvGALgU+b\n\tN65nc4NGVL5PQ==","Date":"Thu, 17 Nov 2022 11:32:53 +0100","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20221117103253.f2dkhyvpplba2ssn@uno.localdomain>","References":"<20221110144556.7858-1-david.plowman@raspberrypi.com>\n\t<20221110144556.7858-2-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221110144556.7858-2-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 1/6] libcamera: bayer_format: Add\n\ttoMbusCode 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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]