From patchwork Wed Aug 3 11:26:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16946 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B0AEDC3272 for ; Wed, 3 Aug 2022 11:26:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75DB063317; Wed, 3 Aug 2022 13:26:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659526014; bh=0L61/HL1fLWRMH3JFmzeF9mO5Eyay1B9vOrN8YAy79s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=AaIkFbjPRsAtc3NGpqmJEG8uTv1zkVGGeFmkdsRyRKg/z3NhbxchBi0inNf0N7ymt 0hCtxFazT9m2ZBrLw9ZhO2sYASQI9x3w8793zMdcpVgHwt3ZneF+24GQlb6AXgqnLB hJT+LpsIhQXMNixBgwd1EqQNWSins0BdoHzvB8bOuU2fovAmco4zOMaXhIJndo/ude Xes5tMOfl1Hk6c/8DAAJL4rTru/cmlsVw///laKjxPN6fMqY/5rL8CjGM6xVGh44Ix ez3BdHMa014f8YINKV2Tuw26ryopBhtD8Ee6HS+G2RqVitgvhK4OsRRimoOpsTy0hs vE5hswWK0kglQ== Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D04746330F for ; Wed, 3 Aug 2022 13:26:53 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id C1D561BF20A; Wed, 3 Aug 2022 11:26:51 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 13:26:33 +0200 Message-Id: <20220803112640.30402-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220803112640.30402-1-jacopo@jmondi.org> References: <20220803112640.30402-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 1/8] libcamera: formats: Reimplement V4L2 PixelFormatInfo::info() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: jozef@mlich.cz, Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The PixelFormatInfo::info(const V4L2PixelFormat &format) function returns the PixelFormatInfo associated with a V4L2 pixel format. As the pixelFormatInfo map is indexed using PixelFormat and a V4L2 format can easily be converted to a PixelFormat, simply return the info() function overload instead of maintaining two similar implementations of the same function. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/formats.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 283ecb3d89d8..53207b734143 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -987,22 +987,14 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format) } /** - * \brief Retrieve information about a pixel format + * \brief Retrieve information about a V4L2 pixel format * \param[in] format The V4L2 pixel format * \return The PixelFormatInfo describing the V4L2 \a format if known, or an * invalid PixelFormatInfo otherwise */ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) { - const auto &info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(), - [format](auto pair) { - return pair.second.v4l2Formats.single == format || - pair.second.v4l2Formats.multi == format; - }); - if (info == pixelFormatInfo.end()) - return pixelFormatInfoInvalid; - - return info->second; + return info(format.toPixelFormat()); } /**