From patchwork Thu Nov 10 14:45:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 17766 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 8736DC3285 for ; Thu, 10 Nov 2022 14:46:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E65F56307F; Thu, 10 Nov 2022 15:46:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1668091564; bh=7XAMEwB+kGGG0KsM65uR/xgA8tfU2IrSJ/iTMvN5CvY=; 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=SoMeucCBBjDgNfpb2J/U/M6/J8QltYcQwsj9OBvJtKY8CE4Ro4e4r+IduXnSu6WU9 oJHG/fE8CbPzMPh0xWELyjis86KN2kkKoOHbup+BMz01gS0AIZpFRTlOnwHbm2YkrZ gsNIc5iD4hSUlh5gnxYgWWc/7m9SDomaGAlAEvMLkhKFHjcakgny3w7eOts+NXwP5J az8Jl4rMrkVq4JIWEaKBHo0sSqYPtpXVGtgIMSDwq+RafzzcAFfvokVOjWvfwpjdru o1DAOBGgQW596tACFv+yFl+q3vEV9FizG64Cq0FxRrFMX19TFP2sskM43I1DDn3ww+ aL0ZQVRIUT58g== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C90E86307B for ; Thu, 10 Nov 2022 15:46:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="hmTHNnP3"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id v1so2549349wrt.11 for ; Thu, 10 Nov 2022 06:46:03 -0800 (PST) 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=VyI3v9GDjJiklg6l9N/VsNz/O4lNh0mKH20mHfn4OpM=; b=hmTHNnP3jj0dzQSAVvUwxn+jvtS9sYr8O7/2BHvJyXGUFzg/SA7EglGw09cH/Zm/HK NzCv0kxpLBJf8O78V/pMZQSgdP0kcGxvKaSWr0I1csowip4Bs1fsDiKGPfajG+c4KNyl t7z5YWyZlhiSIeeRaySsrkKkc+QOucei0A8V416COZiZDlL8Mkn8Xxc3AwQ05H/HDH8/ 8JYunNHIfMnQoNNsbzVKOuQrUjZMdP4Ws8I2R3P5oGXrV68UrGe+ci6kycvPj/qPRLhA 99XJcyiEPRk114ic9UzLMT+yiIqrgb6phfYz2DNcqUEDac5HINSkYe04cKoZhVBxHzAb cNtg== 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=VyI3v9GDjJiklg6l9N/VsNz/O4lNh0mKH20mHfn4OpM=; b=UOuibCbxCc/P2JYWVkeryAgT7yW6q49nPMpb3bEiJSSoJCi+0yc4hZ7k/RViBLrHU+ PU3pZ8Du7U4necV/5dkaJCPLK4wFOvXvHwI05VevEIfvVBz7IcxrrAdMKhfyim1jAHir ItE7kPSPZmPdxZPrxJKjx2dP4vEm1EKS5aXxQIZ0p3gg52C1TpFkXI3pH4CLMka4/741 LXHh8AFLJgPgL4vN/FZyuj6tTIJnJ0m7GpiVAp8f0OVYuAogczPyKbdrEi7B36zsqxyr KIqo6NU/yKmr/i2FycoHSWfqjnXhMfMty+82/eQleWBFeYmdpB04HSAkfmv+chmPqkNp RTPg== X-Gm-Message-State: ACrzQf1FjJDmdGPEpN2Y7ZsMhhGqWojg7McHJskSetei28VU+pGDYGGa 19fyM5TAYo9PaS4gQ9KtfpJrlCNPjI98uA== X-Google-Smtp-Source: AMsMyM6uRS/3Flla60Wuoop8WRyQuDLrYOdJbgcuq44BgO+rC+hZaAdIjoVNa65xTH6mplKbulfNtQ== X-Received: by 2002:a5d:448d:0:b0:235:98b:6145 with SMTP id j13-20020a5d448d000000b00235098b6145mr41260843wrq.421.1668091563088; Thu, 10 Nov 2022 06:46:03 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id u24-20020a7bc058000000b003b476cabf1csm5249759wmc.26.2022.11.10.06.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 06:46:02 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Nov 2022 14:45:51 +0000 Message-Id: <20221110144556.7858-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221110144556.7858-1-david.plowman@raspberrypi.com> References: <20221110144556.7858-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] 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 Reviewed-by: Jacopo Mondi --- include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 78ba3969..3601dccb 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() 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..fdbc4af1 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -226,6 +226,17 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode) return it->second; } +/** + * \brief Retrieve the media bus code corresponding this this BayerFormat + * \return The corresponding media bus code, or zero if none was found + */ +unsigned int BayerFormat::toMbusCode() const +{ + auto it = std::find_if(mbusCodeToBayer.begin(), mbusCodeToBayer.end(), + [this](const auto &i) { return i.second == *this; }); + return it != mbusCodeToBayer.end() ? it->first : 0; +} + /** * \fn BayerFormat::isValid() * \brief Return whether a BayerFormat is valid