From patchwork Thu Nov 3 10:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 17750 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 469BAC3285 for ; Thu, 3 Nov 2022 10:40:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75A7163080; Thu, 3 Nov 2022 11:40:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1667472035; bh=PPn+BaSabQ56UJEYn4f/uNz4wcJVOI+k1B0UOdn8sHU=; 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=pJgnHzzEmI+ML/YXjg5SiqbuMUMIsozO6kZ+34Pz2qMSqEOB/H/xlQNSLjO1JTG1M Q+4SGe/aazUQiAf843jQcHv5dtyu8pAa9EXmKqo5F8IHblsLQvTXUCeOlM/N8b4mFR 9ojiENXdB9F13PZYOdRo+EgC4EB0YVtSGkAZYivuylz5sA//W2V3RTdPioeXUovy3J WjNbmyAfs5QMYyu9EIeZsEChOtSqnuy6YHHfSdjYSkgAyzzqa4WCw+svMTy3Evqffn pyjQeNm0u2sLAQP7IXulpi3HcoZ3HblTrX6uiIP1rQttJzjRtyFrkRf6kWjz7mRko8 gsVTyTK1Jo0zw== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 872E763037 for ; Thu, 3 Nov 2022 11:40:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ila0xqbC"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso914506wmo.1 for ; Thu, 03 Nov 2022 03:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+brAMRKPod66CqD4qVrWYNSEjZMifCSp+0eKyFT0UZY=; b=Ila0xqbClBgK5QEI4YXp8HnDhKcRn40pOhm2acnsb8t4TPR+a7ukePjTUUYrRiX1oS VuOw47mHvHcn0f0sWawz3zagsgNV8aPK0sRmVBMuAP5PZoCzm9993pl0oj/KnnaFc8nf NJv8jSeLulwD2FOkSQYgU7jf88G7AJBZYj8fswlwqxZZirE9KoAOIBsvD9gAfe2Q6j9T TqGaa2ZlFAy44xMof6eDqpB2opJliwZ4MTiPG0KWwz+36TjJBqJ1ciOsCMwKF0BaQtec mtK2j0FSXwf3b2NhBegHMhZAFlk5UfppLjy2rc1TmJpwMmu1wqSRmERGvWig+1nyG8aZ lvRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+brAMRKPod66CqD4qVrWYNSEjZMifCSp+0eKyFT0UZY=; b=WIBsHJzV/Z7SpcNdxH1jluepGaTQJkFWuiqcc+YoASiqXwHcq3XsaIHTa2NfO/aVXc vi++Jc80L4ZL/Vn35AZB9DnTqjtQVcsBdLMyfgxRiQ5ltPVS8s3xqS5QDF1cKMMHzsNT 7hyi5ksSQA77MsjYwU4JwNqhwhtL2SDnuPYn9Rdy0UhzectU13ogqgsomGOUkatsL0fx BT0hdikRYSRD4k5eBwSg80o6624Z8FTpyUrC9lxkK1pC4oZ1LsFACAMHdY5lpPY8Hq43 CFyo1pwVAuRbybEiE9pGZizGJMkF+SK/h0w6nvP5utiqst5aocuyDM+qJco0/d05cGEn 8Zaw== X-Gm-Message-State: ACrzQf04Yc5R9WDmeBY26vB1lc+a8JgT8ThVF5qAYqXvghrURkDLVewK BqmMk32DajiGjpeTdkpZUo9DfEbgnDScPQ== X-Google-Smtp-Source: AMsMyM57U7R5FqeLGyieu8PDE9O+XpM4+Q8NCT+wsxKNwgF5Hy2W0HfTJCZ5yVScpJ3yLCIaZFIxYw== X-Received: by 2002:a05:600c:500e:b0:3cf:89c5:c233 with SMTP id n14-20020a05600c500e00b003cf89c5c233mr2825163wmr.28.1667472032836; Thu, 03 Nov 2022 03:40:32 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id f15-20020a5d50cf000000b0022e36c1113fsm516363wrt.13.2022.11.03.03.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 03:40:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Nov 2022 10:40:26 +0000 Message-Id: <20221103104027.4197-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221103104027.4197-1-david.plowman@raspberrypi.com> References: <20221103104027.4197-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/2] libcamera: bayer_format: Add toMbusCode 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This makes it easier to perform transformations on Bayer type mbus codes by converting them to a BayerFormat, doing the transform, and then converting them back again. Signed-off-by: David Plowman --- include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 78ba3969..09f756c4 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -47,6 +47,7 @@ public: } static const BayerFormat &fromMbusCode(unsigned int mbusCode); + unsigned int toMbusCode(bool &valid) const; bool isValid() const { return bitDepth != 0; } std::string toString() const; diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index f27cc166..a03c58c0 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -226,6 +226,18 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode) return it->second; } +/** + * \brief Retrieve the media bus code corresponding this this BayerFormat + * \param[out] valid Set to true if a matching media bus code was found, else false + */ +unsigned int BayerFormat::toMbusCode(bool &valid) const +{ + auto it = std::find_if(mbusCodeToBayer.begin(), mbusCodeToBayer.end(), + [this](const auto &i) { return i.second == *this; }); + valid = it != mbusCodeToBayer.end(); + return valid ? it->first : 0; +} + /** * \fn BayerFormat::isValid() * \brief Return whether a BayerFormat is valid