From patchwork Fri Oct 22 14:39:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14260 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 E71BBBDB1C for ; Fri, 22 Oct 2021 14:40:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89E7668F5F; Fri, 22 Oct 2021 16:40:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jET7vTux"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D10346023B for ; Fri, 22 Oct 2021 16:40:13 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id z11-20020a1c7e0b000000b0030db7b70b6bso3665019wmc.1 for ; Fri, 22 Oct 2021 07:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mi1BmveZO0MDVL5rAfXrj96e0ld5nDzmh+AbmduPjhM=; b=jET7vTuxFjUYaUUm/WFUJNSVo+SB7CcF4uLj/nZdhepNpmiKs8DurCm9Pdk/V/xGfH bgfwKCesbcx0b3JlXUdRoI1DG5T2RyBNIYYGZXDXvqjyaimiVmDa/tXQE1tB5vS4hFpz w+qCQPd0y1xNjUPcbEotBMIAt1ph694e5dPxELpkQPyFiUnvRaMhREQB5f/jnVbnma8C HK9gkvGByCVOPnNS9qq5RbTcmAYgn1cqElm4fir43FLxDj5nmdLUKdb/qIUvTEyoNNCn VKdgGD4C5kmS4+vml8EBHBAa56Ji8Lu2gCaoA9N4yi2/2goVqslZjLIVKJC13/A+a0cr RD3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mi1BmveZO0MDVL5rAfXrj96e0ld5nDzmh+AbmduPjhM=; b=CxqMXas//3DiU5wNTGSbWIIUHqetcedK3QdjyNsVp/s5snYbhTrjvtiHnZCK5XZxIv xjtIbp1Z13dL/CU3PM0Vn4XTBOzx56KzL6U/t3Yix4coX+3EceORI0rzdi57ofjlKO9c +wSKrKJjSp1OepGv/jk/5i5MTEO49ebphcKJSwkHExbH7j7QhLfyt4WKvi8+o6vjuCos F4wNzR3EFyo9kLU7XyACIRBQ+Uzk6e9ZRNiY0hWUiQdONF0VCO1T3+dLT0m5e99/ouo9 TQt71PE5sym5Eo8AnIYEssW0B/pMi1F0NuhLuWch6H+X2Cgvtf6jAfIooCkA8zCy2g/d 7PtA== X-Gm-Message-State: AOAM532HAKocxZsjx8ML4JTHPtO0SXbWfJRS0hfgvBZwf6nH3AUYFopd DNzwXkQ/fWg/PhZZ+La2QGH38OmvoY4oEUI7 X-Google-Smtp-Source: ABdhPJzj1e0J7sS9TmES0mGZ8M8uEpC9UAJcB6MFnydQuK4efryMW6v9j2r1ShnEXhCvXe10mdP5Qw== X-Received: by 2002:a05:600c:3b88:: with SMTP id n8mr119428wms.93.1634913613400; Fri, 22 Oct 2021 07:40:13 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f00d:ddf0:61b0:a4cd]) by smtp.gmail.com with ESMTPSA id r205sm8577878wma.3.2021.10.22.07.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 07:40:12 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Oct 2021 15:39:02 +0100 Message-Id: <20211022143907.3089419-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022143907.3089419-1-naush@raspberrypi.com> References: <20211022143907.3089419-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/6] libcamera: bayer_format: Add a toPixelFormat() helpers to the BayerFormat class 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a BayerFormat::toPixelFormat() member function to convert a BayerFormat to a PixelFormat type. This conversion uses the existing bayerToV4l2 conversion table. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- include/libcamera/internal/bayer_format.h | 3 +++ src/libcamera/bayer_format.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 723382d4168d..247a60cf0e36 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -10,6 +10,8 @@ #include #include +#include + #include "libcamera/internal/v4l2_pixelformat.h" namespace libcamera { @@ -50,6 +52,7 @@ public: V4L2PixelFormat toV4L2PixelFormat() const; static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format); + PixelFormat toPixelFormat() const; BayerFormat transform(Transform t) const; Order order; diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 11355f144f66..c662ba36604c 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -269,6 +269,19 @@ BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) return BayerFormat(); } +/** + * \brief Convert a BayerFormat into the corresponding PixelFormat + * \return The PixelFormat corresponding to this BayerFormat + */ +PixelFormat BayerFormat::toPixelFormat() const +{ + const auto it = bayerToV4l2.find(*this); + if (it != bayerToV4l2.end()) + return PixelFormat(it->second); + + return PixelFormat(); +} + /** * \brief Apply a transform to this BayerFormat * \param[in] t The transform to apply