From patchwork Tue Jul 12 05:56:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16595 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 1A67BBD1F1 for ; Tue, 12 Jul 2022 05:56:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BBB763312; Tue, 12 Jul 2022 07:56:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657605379; bh=H7p48Uln+GR1zWvt2EVlJ9+Ivc7LakNdSODfRW9BX8I=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=oCgKmIVEM23uX4wwSDQrHGt4S+fcrTUu7ByEO13hGsaxuG4yQfkg1ONDpbcjVA36O p81wVOQ91sh5ZJct2HsbJF2/H1xj04A5AdZZ1pfjvF7KkdZ39tax07HOK/glYGsRpB P3J0pyhu0uO36WTZtqoVuahN87cNCLwVDt8RmzvlG56RRiX0CPkl8P3yaEJbOU9lXs R98vDLAgS4tS9VF2lB6KsluV78SlwJESVFAw8Ko/UwWANCRc8HV7OAafpTIQnC0yUF G/C6C4jQYOpw5/lgDblRSiBhbZP0tFuNn6qtXje2GFILIjCDjhXPVp9Rt/QmPCH/kV J5FEO7TKIUTUQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C5F361FAF for ; Tue, 12 Jul 2022 07:56:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fArwARRT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:b3fb:3712:29bf:7855:376e]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C5D2C30B; Tue, 12 Jul 2022 07:56:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1657605377; bh=H7p48Uln+GR1zWvt2EVlJ9+Ivc7LakNdSODfRW9BX8I=; h=From:To:Cc:Subject:Date:From; b=fArwARRTiYWvRTPFonqwDQeteA49+Ne0pLma5+XtvWG01Wj50CLX3CnBXFiTZ50Nb IAfnxDrzTtc+Je6TfgTpVHzzmWwRRDW26e3vSEu7ShnkaHm003IfJHZf0AuuOHsdd0 1dNIwt/fug/DVypGPsKEaMd7Dfcf7xedgG8FyCUU= To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Jul 2022 11:26:09 +0530 Message-Id: <20220712055609.14910-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: ColorSpace: Helper to check for standard colorspaces 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Cc: rishikeshdonadkar@gmail.com, nicolas.dufresne@collabora.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide a convenience helper to check is the given colorspace belongs to a set of standard colorspace or not. Signed-off-by: Umang Jain --- include/libcamera/color_space.h | 1 + src/libcamera/color_space.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h index 086c56c1..43786d2a 100644 --- a/include/libcamera/color_space.h +++ b/include/libcamera/color_space.h @@ -59,6 +59,7 @@ public: std::string toString() const; static std::string toString(const std::optional &colorSpace); + bool isStandardColorSpace(); }; bool operator==(const ColorSpace &lhs, const ColorSpace &rhs); diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp index 895e5c8e..004346f5 100644 --- a/src/libcamera/color_space.cpp +++ b/src/libcamera/color_space.cpp @@ -212,6 +212,37 @@ std::string ColorSpace::toString(const std::optional &colorSpace) return colorSpace->toString(); } +/** + * brief Checks whether the colorspace is a standard colorspace or not + * + * This is convenience helper to check whether the given colorspace is + * a standard colorspace or not. + * + * \return True if it is a standard colorspace, false otherwise + */ +bool ColorSpace::isStandardColorSpace() +{ + bool isStdColorSpace = false; + + static const std::vector stdColorSpaces = { + ColorSpace::Raw, + ColorSpace::Jpeg, + ColorSpace::Srgb, + ColorSpace::Smpte170m, + ColorSpace::Rec709, + ColorSpace::Rec2020 + }; + + auto it = std::find_if(stdColorSpaces.begin(), stdColorSpaces.end(), + [this](const auto &item) { + return *this == item; + }); + if (it != stdColorSpaces.end()) + isStdColorSpace = true; + + return isStdColorSpace; +} + /** * \var ColorSpace::primaries * \brief The color primaries of this color space