From patchwork Wed Aug 3 10:38:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16927 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 31595BE173 for ; Wed, 3 Aug 2022 10:39:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E70B261FAE; Wed, 3 Aug 2022 12:39:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659523140; 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: From; b=s6t+0VEwbv0dD6O+nRdgTYEsrcKXTseFilbGDpUkJAhFNpDWkZjQApQscExEmCtjw W7N4ByDd3A+1dndInzU/QfSDl6Os199UImQ4PvF64DWwQSkOtLDm/wEcQmmF3k2D2z dqb3m+0Xruzin+lhEwteDLd9UFVWxax3jUzYtaUAB44tY7Rt0wHocxThfk0f/nT1Bk 88fTclBTmXN6TRaEk91I46Tp/3saoPvc4Hur5SYZ/tftt2+8kvatEXmSxXOqhlVx2s bLmIWFjfE5LiYsqSHuJ8fdHvrHekDWOAy2IeJ3kaR2JKEW/qNlxmER+Sbu9/KPNxI+ yqsECc58Fqpnw== Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9976A63316 for ; Wed, 3 Aug 2022 12:38:58 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 700171C0006; Wed, 3 Aug 2022 10:38:57 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 12:38:43 +0200 Message-Id: <20220803103849.26144-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220803103849.26144-1-jacopo@jmondi.org> References: <20220803103849.26144-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/7] 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 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()); } /**