From patchwork Mon Jul 11 15:37:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16590 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 D8E75BE173 for ; Mon, 11 Jul 2022 15:38:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BA4A6331A; Mon, 11 Jul 2022 17:38:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553902; bh=a5Z1rYPGczQYT6xgZPRYsVxkVJdAn3pV2eDdAkEWDyU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XErmTx+F2CC7qVQINum/n4tCqNlnlGuRSIUxL3xkQ7Qmne5HoUj1xqE9OxmuKmc66 q65/BQs0LKhxDPkzEI57dao8KDLZIcuaf87GRPtruvLpShiPm20R8Fldp0RT6rlkX+ YceCYk4sK3VgoxyrSh/WYamQP+3eHlKXGA6u4X/W9Re9avw2DvNPHcr58TrPC19zKV SrUN1XEXV3VciRUckOrJ0wQ4i0e+r0NaRa18iKtFvrXZ/xOc3//eyFVxu8l1nQb3UA agXzZhLSxZfK0DpRysETW/dO35ew/Vp80WOt7spR1wGis40JorQzpr2wdeTOyCTERq Xf2rYdNxceOzQ== Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 530E462752 for ; Mon, 11 Jul 2022 17:38:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WlcH/H0i"; dkim-atps=neutral Received: by mail-pf1-x434.google.com with SMTP id y9so5063039pff.12 for ; Mon, 11 Jul 2022 08:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a7p2TIqTwzVE60rzD3Z9ONOdYkhJcRYhYYnscTnx/hg=; b=WlcH/H0iUKJHQ4s0AlZ3sxPTG7NW7ZciDgWpd/TmgeJTRiMeKImPTYgjaWci6vLoAM oKOdZnhLtLY0XOI4c1L1KuIdky/S2Z6cD/do9Hal2ctuttJSZ11dQiWhYaR8NaacsVGU CNZ+5yZsAdXRZBJArZ/NrWmpG+0JYD0PRvPUltIF3CnK9W3JnukQg7VRzAxs9ismdbn4 CbWJ8CqFxAVQI2LpNORdtC5NyenibI35Pz+N9P1LxFr496khEzip5Pwl6KsEYG11N/9I 0fdyqJhJVzona5oM3rWREuwOHVSUDEEJC9+BKTfM9VAFg4b+WY8Nb+s9kcMcDi8QM+iF Ounw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a7p2TIqTwzVE60rzD3Z9ONOdYkhJcRYhYYnscTnx/hg=; b=nv4oGK1HutyI/QXpP+I8iOtWdejmaxRY1yDZU57HwXVGrxKX/9zabJoOm1hQB2PvVh vxSNdIs8Oo6zbGX5NJCpGsBvI0PL/793x8kCAEJxf5WUm1+C4kmBEOMYRKd8h23d2EXz pJCH1FHsJPeOegaEx3EEHxSyZRBcpYsgP2wIhQCimVR5OUWIik80AcyboXzeuOs8kS18 N3nWBqdS4x54ibDS+C8MaxV+lLMVB+G18e1/Dwrc0pTF1jx4dZvdR00hG4IiXDIXhCOz eiMYvYAsTKq5CY3WuYn11dVbRUf7U3EtvBfe7f9p0CsX1RMkLCbFXJY0w7CfhrwWQT5Q FytA== X-Gm-Message-State: AJIora9Wvbl7rS2nmRlLeNtARnGQGCBOJZtE59JejR+DSYgMFN1drWQO 4Y/gWRpT/OywdHZIFWOd7zVGcIenAVs= X-Google-Smtp-Source: AGRyM1v1GHZXFKFFjgOZX/Z62qAKhXAs1XzG/87E6R7i0inlz1z7Q6nG+MSWlAxwjKldtWy445/Fxw== X-Received: by 2002:a63:f809:0:b0:415:f224:2f61 with SMTP id n9-20020a63f809000000b00415f2242f61mr6927969pgh.577.1657553899748; Mon, 11 Jul 2022 08:38:19 -0700 (PDT) Received: from localhost.localdomain ([103.124.170.70]) by smtp.googlemail.com with ESMTPSA id u18-20020a17090a891200b001ef87123615sm4891268pjn.37.2022.07.11.08.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:19 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:09 +0530 Message-Id: <20220711153711.36679-4-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711153711.36679-1-rishikeshdonadkar@gmail.com> References: <20220711153711.36679-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/5] gstreamer: Convert from GStreamer colorimetry to libcamera ColorSpace 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: Rishikesh Donadkar via libcamera-devel From: Rishikesh Donadkar Reply-To: Rishikesh Donadkar Cc: Rishikesh Donadkar , nicolas.dufresne@collabora.com, vedantparanjape160201@gmail.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add map colorimetryToColorSpace that maps the GStreamer colorimetry to libcamera ColorSpace and the function colorspace_from_colorimetry() to convert from gstreamer colorimetry to libcamera colorspace using the map. The obtained colorspace form the conversion will be applied to the colorSpace field of the StreamConfiguration. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index a2d9b64d..5b3bfd70 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -51,6 +51,12 @@ static const std::vector> ColorSpaceToColorim { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 }, }; +static const std::map colorimetryToColorSpace = { + { GST_VIDEO_COLORIMETRY_SRGB, ColorSpace::Srgb }, + { GST_VIDEO_COLORIMETRY_BT709, ColorSpace::Rec709 }, + { GST_VIDEO_COLORIMETRY_BT2020, ColorSpace::Rec2020 }, +}; + static GstVideoFormat pixel_format_to_gst_format(const PixelFormat &format) { @@ -117,6 +123,18 @@ colorimetry_from_colorspace(ColorSpace colorSpace) return colorimetry_gst_string; } +static std::optional +colorspace_from_colorimetry(const gchar *colorimetry) +{ + std::optional colorSpace; + auto iterColorSpace = colorimetryToColorSpace.find(colorimetry); + if (iterColorSpace != colorimetryToColorSpace.end()) { + colorSpace = iterColorSpace->second; + } + + return colorSpace; +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) {