From patchwork Wed Dec 23 12:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 10698 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 A1FBDC0F1A for ; Wed, 23 Dec 2020 12:11:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 717AC60529; Wed, 23 Dec 2020 13:11:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X3r3K2iZ"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CABF460527 for ; Wed, 23 Dec 2020 13:11:15 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 3so5942526wmg.4 for ; Wed, 23 Dec 2020 04:11:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CAC/Tm4ejwSsZarJXbXK7kFPNNrqy+c4VbTAK8m4opA=; b=X3r3K2iZ3OVSKqVI/+okq46QaI1r0BtFYNCvhlZ1r6NxCP16cwEqYuqvewyph2vxfc TYSEjDQtXzeEJNg8lR3pKwiYhuqZZd2hkwdUnhsImQcSBSWMbhRR+bKrxr0LitL6GvV8 KHDfmEg90543mli2QPFfF68WdprYGq6YV88HGR5RzfPu8YmpFw1ukz66P2KsvYM2onzn Lk5g8DSBPF5X6tRpj0/VnZyKS/fSlyRi9szQa4g0elgEtACec2EWRedblVtMJWD7aTa8 Llz/fVURWRcqXofI0d5VmKq5FFRfvrkHJpbspfEDUDmwSEhQcvR3w+++kyiTdvw4OcNa HXfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CAC/Tm4ejwSsZarJXbXK7kFPNNrqy+c4VbTAK8m4opA=; b=f/ikVA5JbXv69MAKDGWo8odgggW1s9Jz5ixxpasaucjcbyGrI73Q50IprLZxcAV4g8 wmfsb/3oiAJ64Y1v5Mj6QpMuJDVXJBnB1GEMuhlCye0ITvkFpRezVUVx1REcyfVjnCB9 YIsrK1TBylMMmMfI+NEUMLcUURHx/3Bxfx4Iq4wH0+6t45BkHCT5OzSbmDbVUnrS/cdY h+4geNMskfxStU1eFndChWVCTRTF2QdNO+5lcrb2qcTSaev4wsHOxQjHzASIOhBxVXRM McpU8eWMsUt7IYHC6Ebu8GBZcdtKik3h7NQYRbxn7rOAwTRUYFqSPra8SeExr1ILROzM n/DQ== X-Gm-Message-State: AOAM531ndF1rFtAXVOEYxGWmp0Hb6oOMwObuYdFTbc1F5d/ZZPLNYHUe 5fPgvGtr/Axl2QWIUJt7WaD9dnrHIlWQpw== X-Google-Smtp-Source: ABdhPJxlj+iyaahbanRyrcrfryl88G27i0+JlsiGf0v4o6Ouhn2ebpTutKxSzYvM1joxZ50aGBpmFQ== X-Received: by 2002:a1c:6a10:: with SMTP id f16mr26279242wmc.106.1608725475651; Wed, 23 Dec 2020 04:11:15 -0800 (PST) Received: from basti.fritz.box (p200300d1ff2be200e1a8f8b471c12212.dip0.t-ipconnect.de. [2003:d1:ff2b:e200:e1a8:f8b4:71c1:2212]) by smtp.gmail.com with ESMTPSA id u6sm36787733wrm.90.2020.12.23.04.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:11:15 -0800 (PST) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Dec 2020 13:10:54 +0100 Message-Id: <20201223121055.14178-2-sebastian.fricke.linux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223121055.14178-1-sebastian.fricke.linux@gmail.com> References: <20201223121055.14178-1-sebastian.fricke.linux@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: Add the fromV4L2PixelFormat method 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 the method to get the corresponding bayer-format from a given V4L2-pixel-format. Uses the existing mapping table. Signed-off-by: Sebastian Fricke --- include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 4280b76b..a8060029 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -48,6 +48,7 @@ public: std::string toString() const; V4L2PixelFormat toV4L2PixelFormat() const; + BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const; BayerFormat transform(Transform t) const; Order order; diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index c42792ff..f4f0e8ca 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -217,6 +217,20 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const return V4L2PixelFormat(); } +/** + * \brief Convert a V4L2PixelFormat into the corresponding BayerFormat + * \param[in] v4l2Format The raw format to convert into a BayerFormat + * \return The BayerFormat corresponding to the V4L2PixelFormat parameter + */ +BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const +{ + const auto it = v4l2ToBayer.find(v4l2Format); + if (it != v4l2ToBayer.end()) + return it->second; + + return BayerFormat(); +} + /** * \brief Apply a transform to this BayerFormat * \param[in] t The transform to apply