From patchwork Mon Jul 11 15:37:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16588 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 71811BE173 for ; Mon, 11 Jul 2022 15:38:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33CD563314; Mon, 11 Jul 2022 17:38:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553895; bh=Zl+9vM7+8kBDEy6q+NzqQN+ttnRwn2yb/D3tfz014G8=; 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=avc8lhXV6jZRSLuAOgjuw5BiFefIii1434x49lZyb96NO7tp9kGLX0S5dpMrmw7UL Ws5RQ/qxkmX2gglKjGY3NRUEqa2rZiGOwinT83K2maY3/3+z6BIGdbF8UdgfQdswfl yJ754XMgVnVyhSjl2vQK6+JEfFJzX1+yPlbrNWd0rua61LKsimOjHeyA244Z1dy/JD o+ZDNShowE+tDO8tEPrUmjrXfGCFRWB9K2NfkVc1zFi+YNQZCIZxItis68tjwVAEJF 48CrvzkQmKgZawCIxNSpTA3rWPb/txw9gNKJURL2WCDuML/z1E4rH9HoTeKPA+4hhd Kaae+kBMmblhg== Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D232E62752 for ; Mon, 11 Jul 2022 17:38:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KcH7gjsf"; dkim-atps=neutral Received: by mail-pl1-x630.google.com with SMTP id r1so4732806plo.10 for ; Mon, 11 Jul 2022 08:38:13 -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=NS5pu0DCGUGMfH4dnx5Vf+qPgIETX9SXZ9Vco7I7X2A=; b=KcH7gjsfr7uM6VTzACZ7CdjFTk3i+yOAPn8NLwi/loddjV1k/UH1WHJuIgeBxO0pYu A/NHdxRClFbZiJj/BUZOqn4Ohpwv6XiKncNPMvOofaQ7W2fzWMyg4t07wNaU0HEJZtL5 nxLKWptu69TLWNusue4A0WAc99ZGBiDk/x7TXqZ/tSx5b9j9pCAqxDKNiIEB4aMRb3n1 zqpf9F3bca/L3WuKmalAM7xPfYwKIiQI/AstC4OclcXzngM5EJ9BUrPVGrtbZ84Zonym UQUuwoLAu1zU6O4tAXjX4OvF97Uc4v+52MvgGocItmxGDRHcCmfOAtARjhll14qMwAlt WJ5A== 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=NS5pu0DCGUGMfH4dnx5Vf+qPgIETX9SXZ9Vco7I7X2A=; b=VtJvOUjh+Oc1s9dQSD16x/NORHyvll1Uo5j99ABOqbvInDtP2CtcPEksDnrlWIE+F8 mSORXUWk1/8oLM+OfSFG8N8q9DY+7lN0fgGQ9ON4EuDJF55X8wlzHDgoLIfbLMSHQ+3e BuhkO3cH0LDq4cuV4jPOuUjVICZdvoe1jauy4pcITYyHIZmyZOMz3xCrJkJC1wTJsgsR whjA9n7OWfVtlSYXfQhQmGFLJ/uQPzSOqBnKh4ltfqEgmQ0gvreNcY4zoJ7/qunTWiKZ M3Jpsxw1EMS9dUoGZdcDYDNjGnmgN0yCseC26+F6XHjyfOwL0aR9jLgGxPFpAZCQ1hWR iygA== X-Gm-Message-State: AJIora//42358+/hRgO900OIMIEpjrpomA6JRGsy0+4ebRNmOAJMsraJ Q4GtdbKSDDEaFl+fwoRi/LZKP5KIrqw= X-Google-Smtp-Source: AGRyM1tQZSUGmO5mRu/V3HSZGc1ogfTSkE09uOhMRqxfYI1SCRIpLuiCaDxeACuX8QPl+FWcIIG/AQ== X-Received: by 2002:a17:902:c952:b0:16c:1cdd:9077 with SMTP id i18-20020a170902c95200b0016c1cdd9077mr19492012pla.168.1657553892227; Mon, 11 Jul 2022 08:38:12 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:12 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:07 +0530 Message-Id: <20220711153711.36679-2-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 1/5] gstreamer: convert from libcamera colorspace to GStreamer colorimetry. 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" Libcamera StreamConfiguration class has colorSpace attribute, which holds the colorspace that is being applied to the camera after the validation of the camera configuration. Add a std::map that will map libcamera colorspace to GStreamer colorimetry and find the colorimetry corresponding to the colorspace that is being applied to the camera.If the colorimetry is found, the helper function libcamera_colorimetry_to_gst_string() will take in a std::string representation of colorimetry and convert it into G_TYPE_STRING so that it can be pushed into the caps. No need to check if the colorimetry if found is valid as we are working with known predefined colorimetry. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index c97c0d43..43837602 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -45,6 +45,12 @@ static struct { /* \todo NV42 is used in libcamera but is not mapped in GStreamer yet. */ }; +static const std::vector> ColorSpaceToColorimetry = { + { ColorSpace::Srgb, GST_VIDEO_COLORIMETRY_SRGB }, + { ColorSpace::Rec709, GST_VIDEO_COLORIMETRY_BT709 }, + { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 }, +}; + static GstVideoFormat pixel_format_to_gst_format(const PixelFormat &format) { @@ -87,6 +93,30 @@ bare_structure_from_format(const PixelFormat &format) } } +static gchar * +libcamera_colorimetry_to_gst_string(const std::string &colorimetry_str) +{ + gchar *colorimetry_gst_string = (gchar *)colorimetry_str.c_str(); + return colorimetry_gst_string; +} + +static gchar * +colorimetry_from_colorspace(ColorSpace colorSpace) +{ + gchar *colorimetry_gst_string = nullptr; + + auto iterColorimetry = std::find_if(ColorSpaceToColorimetry.begin(), ColorSpaceToColorimetry.end(), + [&colorSpace](const auto &item) { + return colorSpace == item.first; + }); + if (iterColorimetry != ColorSpaceToColorimetry.end()) { + const std::string &colrorimetry_string = iterColorimetry->second; + colorimetry_gst_string = libcamera_colorimetry_to_gst_string(colrorimetry_string); + } + + return colorimetry_gst_string; +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) { From patchwork Mon Jul 11 15:37:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16589 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 292E3BE173 for ; Mon, 11 Jul 2022 15:38:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E1CC963317; Mon, 11 Jul 2022 17:38:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553898; bh=S+pMnG9qArCipiVzmsCS00FAuvLtVCHo8cfZuFnUdyM=; 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=brGjidRmZB0qpZWaflSPrK9opGYaRe3vJ93dtxDQUsnzb+xQD0700gfh8n8BgnhVj 7Up9T9cWSYmJEm3NA+QLQpHnzVaYnBwxf6wCHRbiFOnAVMFj7S0R/YTZgFEACov7Qc D4YefBkBMaljYQ5QCdV29/fq/WsA+fgRXOWcgMw3RWG54oIxthFGEJPJ9M2uNWOp1t UK0bi3PiGvJI9GI48u7J41QgZbhjony8JT/OVBkrV3axZ7qDXGVOwpqbTQHkFIMQ6w PHP6/vZS/ukjwfVgh0GaFv90WTjkQNHLZWDGPZ8/9MIz9YFQzRYTrxGKHZPGkMK/5p 2sHujNZu/LnHw== Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDACE62752 for ; Mon, 11 Jul 2022 17:38:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L1hxUZhf"; dkim-atps=neutral Received: by mail-pf1-x42d.google.com with SMTP id l124so5078270pfl.8 for ; Mon, 11 Jul 2022 08:38:17 -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=T7FcClSDovKV4o5TX4pXqGgDSXUR6G3jMCCkLVzbUmA=; b=L1hxUZhfPy+xVk3duC1bwnV/8nCYaf4b5clx/0LQiYi2aJwkCRYFb7LySsVOJcmfIX 64kCMfECmNvk/uB6L+n/TSHOZYdfuwFd2Vl05r8QQRD1HvXdCOGAeklKsz2LWvNs0Otk Gxp8/OyUHDJUGSc12nlo6PFerdZOBNNyusZ5pM1yqDGna8fpsMXxdtMU3UsrR3OZCKKW NyO69loBFkMoLXNGs2B78fZXWBVWT77+gCcQ1lfr9VZFpX0AtngzU1MMkryCmsGj1UdC LX5+A4xWnCeFHE3szA5qLgPj/JpGx4gL685248MagijeN6iXi2aXjimpExLuEuTK98Ga bKlA== 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=T7FcClSDovKV4o5TX4pXqGgDSXUR6G3jMCCkLVzbUmA=; b=xVSVJ3tGn8YIajvyTcr3uU/NA2JB4lomy68PMup4Y6ihrRquTRnQhu1+IixRVbfcg5 MA8lV9L7k2G9VtDT/rfS3RwWxqP+Mhd68pErEcBTPUsBRr/bk5WrPGFr3pB2BnVyUZP9 aixCp/54sAlZ1Hzf5z5Q3ZT9nDGB/Hk1X/VSbj4nBhbPgPE7PAS7HSewqfr8e7ghD6Pl vasXqBH4ZEEPLlBnIESlJGQtfZI7ehXf2aBX+l8pdDDgfdi5QgdSvlGNpnFYAz54Sb7h b4QPeCbV2fn61ITdhCbUX3OZRE9IVu0mREGQPFfwGFS1PRoN1rGdumeZCUiyDk+v4a42 +p+Q== X-Gm-Message-State: AJIora+sInSpC8MSHzUCSMu7U1MXy/qDEqwwPYcIAcjcaeMJxw9qV0Yk 6TwI6YztQw7CL+XKmRHdE2QgalgYL6Q= X-Google-Smtp-Source: AGRyM1uAJq2JW8o5SFvVhNFjj0Fl3viJchCyhsLuGjZOpq5y8whYXZb4vaSC9kHrYp2Qd5lvvD3oWA== X-Received: by 2002:a63:385d:0:b0:415:df85:4b73 with SMTP id h29-20020a63385d000000b00415df854b73mr10049165pgn.179.1657553896258; Mon, 11 Jul 2022 08:38:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:08 +0530 Message-Id: <20220711153711.36679-3-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 2/5] gstreamer: Update the obtained colorimetry in caps. 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" If the colorspace is set in the StreamConfiguration, convert the libcamera colorspace to GStreamer colorimetry using the function colorimetry_from_colorspace() which will take in the ColorSpace value and return the gst string representation of the colorimetry. If the colorimetry corresponding to the colorspace set in the StreamConfiguration is not available in GStreamer remove the field colorimetry from the caps structure if present. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 43837602..a2d9b64d 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -164,11 +164,24 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg { GstCaps *caps = gst_caps_new_empty(); GstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat); + gchar *colorimetry = nullptr; + std::optional colorspace = stream_cfg.colorSpace; gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, "height", G_TYPE_INT, stream_cfg.size.height, nullptr); + + if (colorspace) { + ColorSpace colorspaceValue = colorspace.value(); + colorimetry = colorimetry_from_colorspace(colorspaceValue); + if (colorimetry) + gst_structure_set(s, "colorimetry", G_TYPE_STRING, colorimetry, nullptr); + else + gst_structure_remove_fields(s, "colorimetry", nullptr); + + } + gst_caps_append_structure(caps, s); return caps; 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) { From patchwork Mon Jul 11 15:37:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16591 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 5F5A2BE173 for ; Mon, 11 Jul 2022 15:38:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FCCC6331D; Mon, 11 Jul 2022 17:38:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553908; bh=crWHhz3Z/TyJBTdD9UfIlmkwgS1bUHOkBd+HziOtpWg=; 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=AxVM/KLSwUn3DXMnm5ueseAgHdpu0EQzUfSFJ75zK9vJ9RLiBO6xay5JQIbu7MQtY Wx6kt3B4wOgYIeiy+NxrR/DWiVpJ0DBjOUc3EDt+oQNoAlCZ0OnGeToQPiSSB5m74a lDjqP625lHqCkzQ1nJxx3mYLNUzM+dv/6ZNytx/SGH2Pkm8LKKih+07zntEV6sYZ0A eQh9Z8YxIQIB+tee1tQsfrCLOEnwgYoi2LUf7vyOc30gZRWx6ga62mLKohJO8uc0ac Md3qatH8JiBkUij4yWrtXLFLwhekMv/DmG/xar6cnS3DAdM5goFWj7deklodnXtzm5 b5IR5rYa9i1kQ== Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DC176330B for ; Mon, 11 Jul 2022 17:38:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EtfxjAAQ"; dkim-atps=neutral Received: by mail-pg1-x530.google.com with SMTP id 72so5088677pge.0 for ; Mon, 11 Jul 2022 08:38:27 -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=74dT/n8SbP1yPRYZvYWmschUwxbjdspMpv5yNwnz6tw=; b=EtfxjAAQsqXaQBBt+mDvLIAKURueW3GtVSjYo4a76P4yPjgAglXkWeaT3QRqW1zIhr hD6a4wklfQn9m9KiPCkQb2GSPvMjC4CDTmzm7SRJ6dXbk+FS5maivXtRQdcpFCvmuU0N 8LI+k4PRL2PVn85jito41+pm0iSVZ09/OkpTkpcyLKT6Sk4VsI/obPsNLoOIti7sOUJF i0wGWqktmS+/5fAYqv4m1m5lCI3TVddt1IOljyw7qH/qv5Eg/XufDOQDVuqF2IOGzp8J BQggEGoumKsI8NNUuSxdbYs88Rp/Edgqs/ozHGbAm/o9e386yOCmHi6hN3fiYJQs1nrf wAAw== 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=74dT/n8SbP1yPRYZvYWmschUwxbjdspMpv5yNwnz6tw=; b=5vHUrwfysKMAugsjQK6UqRyGu8+sGzKZgvvwBtGAvFlTuG9182SEGIWwQoDxd2W/u5 TydYqsK9zEcA0AQ8zIP8hvh0KfWv2J7VyesKTTfbxIh8FbEw0k2jpgcQPXM10f60zFF7 nbQzQPFAwdAoqQJgqXAtjkDJgOuxVlFHGOxnfzHkRYM8C5rXv01v+yzfafL4o5z+5Oos KUF8GovhbWXxQfTKz2rpYhi5tRpWAfart/MueydW+PA7e8wvNlt7ebGRWZOqPcPCc+e7 ve2i4U+CSJeLdIzlYpU475Ywu1cNMqlrCj3JFRIaonTVnSvBSfp0AJABbh0zvKIsYNOj MHwQ== X-Gm-Message-State: AJIora/cu2rB9PsX8titFGEMnzvo3fcCx4uT7LnvFzRt81loB2PNLdeP TlXJ+4J0sRKKnr0S/DeW/d/lxzRfVr8= X-Google-Smtp-Source: AGRyM1ufZNF84vi8NQYBdFGlUsE5/yew/InDOvnVvtCpK2Wx8xX5RPUWEV6qpto9s2P/hrTKiblqkQ== X-Received: by 2002:a63:4b20:0:b0:401:ae11:2593 with SMTP id y32-20020a634b20000000b00401ae112593mr16814568pga.375.1657553905289; Mon, 11 Jul 2022 08:38:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:10 +0530 Message-Id: <20220711153711.36679-5-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 4/5] gstreamer: Configure the colorSpace in the Stream configuration. 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" Get the colorimetry if requested in the gstreamer pipeline and convert it to colorspace using the function colorspace_from_colorimetry() Set the colorspace as a result of conversion in the StreamConfiguration. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 5b3bfd70..b3fc9ff4 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -278,6 +278,14 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg, g_critical("Unsupported media type: %s", gst_structure_get_name(s)); } + /* Configure colorSpace */ + if (gst_structure_has_field(s, "colorimetry")) { + const gchar *colorimetry_in_caps = gst_structure_get_string(s, "colorimetry"); + std::optional colorSpace = colorspace_from_colorimetry(colorimetry_in_caps); + if (colorSpace) + stream_cfg.colorSpace = colorSpace; + } + gint width, height; gst_structure_get_int(s, "width", &width); gst_structure_get_int(s, "height", &height); From patchwork Mon Jul 11 15:37:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16592 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 CD146BE173 for ; Mon, 11 Jul 2022 15:38:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8F1BC6330F; Mon, 11 Jul 2022 17:38:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553913; bh=kULF7VbtYaBkYNMW7DM8pQM1bmJ1OtrgmprKdtBkR1M=; 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=oHVdDBHv4nSSPlTC/bW2wAMIrAh3XGBTyDd9KnE80bAtFh+h2P8oOFR9EtDZ3WMU2 5Y9MfT9vEFhSVXCiKe6WAPGmzV55H7O+AnyAWpMHeQ0d2jx4sagYbiUx7pPe+EBtgD NIlPhbIqNCEy98OgD0FkaeVD3hqylPOkBMYQToNbXFszXBOrtHXP/jE6TU+tj4BZK/ asVMEtojr84TqW50J8EWWe5BwahuokIQ3KgY7C+/B4Hnb99VQEfM528AernrfuvOHy x6chcIw2tn+ciV+hgi0FZSrmnwHQCD6+ZkjuFYTla967VvecECu145/JTEGEvduwy/ z9TIqaBbg5Ang== Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 247506330B for ; Mon, 11 Jul 2022 17:38:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JBFNrrpg"; dkim-atps=neutral Received: by mail-pl1-x632.google.com with SMTP id z1so4758503plb.1 for ; Mon, 11 Jul 2022 08:38:32 -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=OaNc6z+asGLANI8tRcf6ua0YOq+0JYVVlhWAGFupSDY=; b=JBFNrrpgpoTJDZgARMKOkt68W8MQBXcna5bBPf41U7yQwYocH3brC6XbDe2l4m5fL4 hArYGmLU/WgUlYol+j6CyaQXIByRlpmY8QsOea6plHN0xbIEcMni80VcHM4psSbyccSB 5LtJzwjHD6dOkc1WCltmW6/Pkp7OHaaI46owtHcNsrSLDYuaE2j3eTzTF2Cy3XTQNJBl E55hFcjbifpKvix6eAwcdXt41XwJDdZjy0TD7eY7adNp6UHaJQdyN3swEAkrytoGliPR b39Hnmf/rwdkmkKeIhH43l9sZf+vm7GnmVaI+xt11WyHtP9j+ovk8nKe829OChApXp+9 4iag== 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=OaNc6z+asGLANI8tRcf6ua0YOq+0JYVVlhWAGFupSDY=; b=3vOr6LqZzJvG4N5Tg34x3SpwG/MV0Hn9phqWpBi6Ij6ZbNsU8WEvrSVK1XzW7xKTHa oXykKzKYXML+NEaNJG5JxfiVb1PxTBFAQrxY61e5c0hB6Rk1jrFl0QrMeCov4o59Y/QN WQlcoEiOr0eD40pc5RMeJVpDZpxr6ivEdBnO9rXg9jPqDkzLx3Hyc6h9kOrg4QaAsJ8o byuTaXxAy/V7LyXmWTMgYq7k/Oq0er9WNMaEP83GvqH4cMezAjO1H3Mf/+bfEPvQMm83 95fuddHDWluHHiYjJZLNf/lzUEm66D0eIWN5p2QL/FeQUGj5tJimAJH+kMQvvLa2udde ShSA== X-Gm-Message-State: AJIora/aAP+6MZIv+TxdR2TvHrFGxISL3scstZz21jVIxuc5wCELArYg 2Tf0/8kLMJE6jjjMXDZSTjm3CcsoUEU= X-Google-Smtp-Source: AGRyM1ssmrDqfSTYiw27oyw+Bur5uWJowdKL1cZUrI6LwwxR/IS9bvg1EbmH5xbuw42AXDXnO7H9BQ== X-Received: by 2002:a17:902:b198:b0:16c:1c13:cd8d with SMTP id s24-20020a170902b19800b0016c1c13cd8dmr19183286plr.92.1657553910529; Mon, 11 Jul 2022 08:38:30 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:30 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:11 +0530 Message-Id: <20220711153711.36679-6-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 5/5] gstreamer: Reset the colorSpace if not the same after validation. 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" If the colorSpace set in the previous patch is not same after validation, Reset the colorSpace to the previous value that was present before applying the requested colorspace. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamerasrc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a7a0c440..6cb631df 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -461,6 +461,8 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, GstLibcameraSrcState *state = self->state; GstFlowReturn flow_ret = GST_FLOW_OK; gint ret; + std::vector> prevColorSpaces; + std::vector> appliedColorSpaces; GST_DEBUG_OBJECT(self, "Streaming thread has started"); @@ -501,9 +503,13 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, break; } + /*Store the colorSpaces applied pew pad. */ + prevColorSpaces.push_back(stream_cfg.colorSpace); + /* Fixate caps and configure the stream. */ caps = gst_caps_make_writable(caps); gst_libcamera_configure_stream_from_caps(stream_cfg, caps); + appliedColorSpaces.push_back(stream_cfg.colorSpace); } if (flow_ret != GST_FLOW_OK) @@ -515,6 +521,12 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, goto done; } + for (gsize i = 0; i < state->srcpads_.size(); i++) { + StreamConfiguration &stream_cfg = state->config_->at(i); + + if (stream_cfg.colorSpace != appliedColorSpaces[i]) + stream_cfg.colorSpace = prevColorSpaces[i]; + } /* * Regardless if it has been modified, create clean caps and push the * caps event. Downstream will decide if the caps are acceptable.