From patchwork Tue Aug 2 16:01:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16911 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 6C48CBE173 for ; Tue, 2 Aug 2022 16:01:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B92C63312; Tue, 2 Aug 2022 18:01:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659456110; bh=3QqyrtdGN/a4hPej3PzAb26I1iG2MFzKEIVTjosDB0o=; 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=H6xoB4/aOT0fc2EOyb4GcfMkYshA/bZ6/qIMLHsQSIzB1HqVzepZiMiuQdR6OlxrY 2JSHLbJld7Y9eO3ulgfrY1oRgUMXaZjl13CYQ7X1Cu2mY+MbXd2fWrD5/c5KI2NRgN TJCKWzzvCMwyfMWzLJ1iMgcsKnOWwdcnjygNOO3c2f8xMdZrT1dPZ/U1kAcSZAX5jx pzTYSuD0FKYqfrXHE8TaqlpDPqrCCvuymPxfaUGO3i4ed+4H7m5o3AwhOY2abt7bV/ gDTCK5fJAUOAAP96IqMovChmcyaL4qm7d9BuWtIrE+HMYN3MF3TJ/0ZJLq2mDVzCi+ mKm6bu2hRN8jg== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 186F363312 for ; Tue, 2 Aug 2022 18:01:48 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 59D4E40005; Tue, 2 Aug 2022 16:01:46 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 18:01:31 +0200 Message-Id: <20220802160136.63075-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220802160136.63075-1-jacopo@jmondi.org> References: <20220802160136.63075-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/6] 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()); } /**