From patchwork Mon Nov 21 15:44:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 17823 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 8BC74BE08B for ; Mon, 21 Nov 2022 15:44:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 579A86331A; Mon, 21 Nov 2022 16:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669045470; bh=QeE2XrkMAXBq+xIM6/xevcr7Oh2p3OxWkukLjNSxJy0=; 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=dxA1cyVSg/zweQUFx+YYsoAgyVuf0v4nIJ3toXEg9Jcc23LEvKvxy7FaQrA3n8/F/ ksqlVOCPQj1kae8lnMf8DRK/Rdv9jmUR0amaPZlGx/IV50kUpbcSVDmsfWfRr54ca3 ml4zpMGGa3svUwSpUVrmxujN5f0dOf75TbB+HWlxUlHiHuWXOP1FyeZj8PLVFujiir Q8Yjd9+dVlki4VFeHBdJjRHqMDoF6MkmbruuwwgiL3J/gFg0Q1Np+rE3WDVE7e2SgC zxHVSTQKjfglFa6qkjeYMxZgtwNLn5Jf5tZUEjPJtvlJ5t9GEIBoUajKIDRXfedVHn K/yazX600qYng== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CFD3E6331C for ; Mon, 21 Nov 2022 16:44:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SehATThx"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id s5so3250814wru.1 for ; Mon, 21 Nov 2022 07:44:27 -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=sEHYM3NRf6pMdIrl/YwUGcydrfNxZgsax8Tl7eXR3Tw=; b=SehATThxw9vxrhAuyH7ysnmC28L3/sknBySspmz29B6DqXBQCaWXJTIFU7c2+Y7vKr g6jkQa6FZ8GPDEB/nERMAG14TXF7TH0TL7k94Oc5HZMcVUtV8kAvv5BuOngfKBxMgPEV 2JLEjCxzpT9/02XmFM9Z/Q0noBFplJI3oynSlrXErJCYRdrbf9vk/FDiNWE4TDDyTakL ezTe/EEEm+WQUj+FZPTlUwdW3I17GgWvJyjT9KX8aCyEi99WcntK8x4wDoMvFSubGVz/ LttiR9gzxr7/CQs5kr964ohqDywX6F2ZpiIbyzREMIFDcd5v5b5JTaU4jflwxgMl2lwH WO8g== 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=sEHYM3NRf6pMdIrl/YwUGcydrfNxZgsax8Tl7eXR3Tw=; b=4LuNeCJEE5QkxgIIrnrp/EMIwYX3SCqN5u3iFGbw+Kh5IwxsNWOQ1SmQFhVjtSfdFq iY3AXMuFvollExL1o5x0gN1Z35XL5Qza6xyHnNDlNbEuRQoQPeuNUo4Mu3KRDh0CogLx JJtAA8LnTPo8pDu5OO2F/zI+6Z2rtlN9IP2yLl2m8is4coGfeyY9MUB/vS6PFxZeFtDk nzwj7Ts4aTslCUsot66qXakWrBoHnuTNPjJ9QVcVbUFTgB1xgG9xa0kIzpO/HaRdcFHT DvxvcBKOSLbJmalW1hDbPVze7/SFUr/Y2UkCAmk31qofI0gtyFEd4iWT0Xnl+hpRch2b R+Kw== X-Gm-Message-State: ANoB5pmQ7VO4y+38Lzi/gsFTOMoTu5C0pMDhEPZ75nV39x6akM86vJ7T S8cQ9cup6ARenjtG2dGYo7xZl0pgAoxaJg== X-Google-Smtp-Source: AA0mqf6zQnJqzgf/nomMAwRoqEhDmCE+X6/J2RNtRHIuS3sHPGcjZNqD95LoFnKvoBz/TO93FmucYQ== X-Received: by 2002:adf:ebc6:0:b0:241:c6d8:be83 with SMTP id v6-20020adfebc6000000b00241c6d8be83mr3671748wrn.454.1669045466951; Mon, 21 Nov 2022 07:44:26 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id t11-20020adff60b000000b0022e035a4e93sm11742257wrp.87.2022.11.21.07.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 07:44:26 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Nov 2022 15:44:17 +0000 Message-Id: <20221121154421.11732-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121154421.11732-1-david.plowman@raspberrypi.com> References: <20221121154421.11732-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/5] 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