From patchwork Thu Jul 7 09:43:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16567 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 0E01CBE173 for ; Thu, 7 Jul 2022 09:45:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BCE176048D; Thu, 7 Jul 2022 11:45:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657187109; bh=vrmX0jagPaiuqOHcRlTN4eBQIdjthx/IP+2DusFR41M=; 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=j4X5G1MML/CIVPJ4IeRUy9qkpeNjxQucVDaI/QEgpk0aiBRw4o9SrmbPbxmGL5/c+ tLOEMHcHHI2O2NNnqtO69FyM1OnSbRl3RiwJaHT4L9NstzHRd9/fQlyGfN/+jc0bdo ZthnQQk5AIr0F3RHeasC4X/vAxshAlikaELlTHYZU37syYurBazOQlfQOkuLtHwT2l NVKj8GEvJIlCmUdsZS7RY+RfgKC5NqoNBO/JOVe4+a/+1hTLSLOoQnFias3zrp4Xa9 cImH9Y4W5VxdWGaln0EyY/8lUjalJI+McxpZ9rYKtVul/xfZBP2r/6ZsN+6LCtSkwA 0RYcA7iorYp7A== Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97DBA60401 for ; Thu, 7 Jul 2022 11:45:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NxUSjJMt"; dkim-atps=neutral Received: by mail-pf1-x435.google.com with SMTP id x184so4905141pfx.2 for ; Thu, 07 Jul 2022 02:45:07 -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=tyDMdzAvFdoqw+pj00jWOccwYIWcruJQCOAJ7uJJFD0=; b=NxUSjJMt3qRBrfu2tu/11f7mmOdh4FjDQ7IU2m5nuf82d16L23+umPdOln0KJIgWDN LcpS/HXWP2RGp5ymxVqoR2ePebtvUNiYHjMjScgn0kucEGcrwcMzTR7nCTq0X+s1Er5x 7X6pl+YP8KT6RpmNZxdZ5CsEBcIEx6Pc4npe6gGabuZyksBNzlsdMWSYo3bZWqm1Rr4v fvMSAWnSLjcxHe4phlVGKdKynLonhWhmKfTN3shGL13YY2CHe9EEECvJ0pBy9dKeYFYu dkWfT2sT8VA0uO3ltjoHX/d/N4vIwZwa70Q+9FaKlCCI8bGive+yizNZFTKiTalDNUZv V3TA== 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=tyDMdzAvFdoqw+pj00jWOccwYIWcruJQCOAJ7uJJFD0=; b=ajbtkaC9oQdwvXsnj9crSl/kPdc2UKdt++bs67Rc9LReJ0osmJrshYrHfC3NRNXMv6 98mxk44fURhrOIV/CaYQq5JecXTj8ypTzYVyeCV9rIz2lqYPgN/dfLaL094U452rbU3y HUpgPoUbixHYw+CTktO1TW35d3XWRutl/a4NqrMItOXg5/+CxLT3bn6Fu1YIcGQjanRs xhFh0nfiFXd2Pbou9NZn89yzGhvDuM3j5EFzI2np30AXAijxXJAr1Id0ei2opRFW69HL PyOIK3L1lLr8GZumtL+f5AtKjvpYFC5d/ymb6KuALc6bXrnQb44h6PtAeOdMcZUT0d8H gmdg== X-Gm-Message-State: AJIora+OukIZtiHsdjZ1/3+YBps/WAHf7J3YaC2a7rRdahoLTQv6OZMr NOiXaJAAxot+OFudrfRaBzeGY7qQvH0= X-Google-Smtp-Source: AGRyM1tIv/f1M0IzdzN4p8SLR5jgPUcpvkhByHoCAo3TfI6aIVyZI70wawZyLSQWsfA3h3+mg9nj2Q== X-Received: by 2002:a63:2bd0:0:b0:412:2f70:f0ac with SMTP id r199-20020a632bd0000000b004122f70f0acmr19319758pgr.465.1657187105816; Thu, 07 Jul 2022 02:45:05 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30ae:d446:13ee:d079:112a:ac10]) by smtp.googlemail.com with ESMTPSA id p2-20020a1709027ec200b00168f08d0d12sm24530712plb.89.2022.07.07.02.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:45:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 7 Jul 2022 15:13:59 +0530 Message-Id: <20220707094402.28730-2-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> References: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] gstreamer: convert from libcamera colorspace toGStreamer 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. Map the libcamera colorspace to GStreamer colorimetry and find the colorimetry corresponding to the colorspace that is being applied to the camera. This colorimetry if found will be pushed in the caps. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index c97c0d43..60ac8c8e 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,32 @@ bare_structure_from_format(const PixelFormat &format) } } +static gchar * +colorimerty_from_colorspace(std::optional colorSpace) +{ + gchar *colorimetry_str = nullptr; + gchar *colorimetry_found = nullptr; + GstVideoColorimetry colorimetry; + gboolean isColorimetryValid; + + auto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(), + [&colorSpace](const auto &item) { + return colorSpace == item.first; + }); + if (iterColorimetry != ColorSpaceTocolorimetry.end()) { + colorimetry_found = (gchar *)iterColorimetry->second.c_str(); + isColorimetryValid = gst_video_colorimetry_from_string(&colorimetry, colorimetry_found); + } + if (isColorimetryValid) { + colorimetry_str = gst_video_colorimetry_to_string(&colorimetry); + return colorimetry_str; + } else { + g_free(colorimetry_found); + g_free(colorimetry_str); + return nullptr; + } +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) { From patchwork Thu Jul 7 09:44:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16568 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 7E0A3BE173 for ; Thu, 7 Jul 2022 09:45:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4A03063315; Thu, 7 Jul 2022 11:45:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657187112; bh=cUgUPITQQWgiPlqqex4TkY/l3u2R4d9+4Lr45jZ1spg=; 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=SBXoerE+mOUk8lub8g4bLeo9L/S0DJoozLhHNqoffDUrZjbGes3DQZ1KQOK2GSnQg IuqrFzhsTZsz3aCdH+vDEqHF2RCXPEI+T2fyVE/vttPQW0CLG673SS8wRFSWVDH6Ec XSJHFoAntHlgN5mupyZNkTwNYDNfbg/mCmm5fxLwbCW7Bgz37GnO01gEBNtEJLeDTj p9arSBDxggNve6rLUn3c6GSRN1O4tNfCQux7EMAdmTP2xjXO9TUot8eFDU57OKy6PS 1jx7w+fdr0mvy5uIR1GF52eOZK78MSpQJqthJYGL89Z6T5D/XswbmPw4DV7eiCxkqM r6Jr2jjZxq3gQ== Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71AA160401 for ; Thu, 7 Jul 2022 11:45:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jRwf0Eee"; dkim-atps=neutral Received: by mail-pg1-x52d.google.com with SMTP id o18so16312512pgu.9 for ; Thu, 07 Jul 2022 02:45:11 -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=bNl0sT3bbTAE09VbE3LX+X/cDVAeGq77EOfMbHTB+58=; b=jRwf0EeeuLaHONc8psY0Un9w5nT/3H7O+CFqt6k/3CDZASpMsu4h6DWNUBeYCOCkmz GpHs2LjGj9b+N8WAQ+IR7eZGwNfhmUG9VCvrVfhzKKbObPUHExEgoyp/cnBly5rtBm5J yncpjWzJL/EnAG+0ox7JHMVAIzMHhAjkvChvN4g8Gx745boXOsHHgGhN2zUa/pRhv7v2 nRjbxFTcfi/P2ksgpyuELwj3+Z5wy7P5QW0heUlEBgSbkjxmKqXZg7YpVukjLsPAGouQ btaH9ARba1PEWLhBVmqZ0+bIVTMAr3vjswjG7Rh+6NEuVDmYC1CSXIoGA8+Fao9Q5hZZ 6VIg== 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=bNl0sT3bbTAE09VbE3LX+X/cDVAeGq77EOfMbHTB+58=; b=OqmEod3BKmwJZF/LNO2nmrQspJ1fAuG6MsNvu6OMwukq5s5Ca2sSN/SrHyWTIn2tjQ 4HxhYReSGl0fxCBNs3qR0IrHF3qP2yQ2G9ZVyAgy8uBeYUkcNe2DFlI0Bqwba1QY775z aCvpbhN2yR5lvqI+BpmYa3q03E2JGu6IdRXEC8hJcYxmF6ipX5Nvn66Yywpr18LPWHiM bFe+ssEenFf5BvOz2TYeOp1H5aBwbvZx5MJwj99CygK3p0L+YnvKyV9ed5fjMBkhsX5l 4Nf/LNpKXKOPNonY3Nz5V9fcGAZ9jyJjgUygRkBMhSQqyOTNO26SroLNKnaFRPVfqvVN IHuw== X-Gm-Message-State: AJIora8Q07Mp9EAEKJ0/U343oH38Zae90v/Sa3nwm7h4Ull6bqP8F4ap FhXxlstROaKyxUwpyZWt4CK/nJGEtRo= X-Google-Smtp-Source: AGRyM1uwvGRUrbaQM/+FQECgO0/C+1CGXLx7pfgllazDZpbOVDfILcvyXWu1vVTMlf1bpF7dwQk3zA== X-Received: by 2002:a63:b443:0:b0:40c:fbf9:8366 with SMTP id n3-20020a63b443000000b0040cfbf98366mr38156353pgu.308.1657187109909; Thu, 07 Jul 2022 02:45:09 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30ae:d446:13ee:d079:112a:ac10]) by smtp.googlemail.com with ESMTPSA id p2-20020a1709027ec200b00168f08d0d12sm24530712plb.89.2022.07.07.02.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:45:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 7 Jul 2022 15:14:00 +0530 Message-Id: <20220707094402.28730-3-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> References: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] 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, get the colorimetry as a result of conversion from the previous patch and update it into the caps. If the colorimetry corresponding to the colorspace set in the StreamConfiguration is not available in GStreamer set the colorimetry field to nullptr in the caps (this will fail the negotiation). Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 60ac8c8e..eb9c49da 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -166,11 +166,26 @@ 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) { + colorimetry = colorimerty_from_colorspace(colorspace); + if (colorimetry) { + gst_structure_set(s, "colorimetry", G_TYPE_STRING, colorimetry, nullptr); + } else { + gst_structure_set(s, "colorimetry", G_TYPE_STRING, nullptr, nullptr); + g_free(colorimetry); + } + } else { + g_free(colorimetry); + } + gst_caps_append_structure(caps, s); return caps; From patchwork Thu Jul 7 09:44:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16569 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 0FEA5BE173 for ; Thu, 7 Jul 2022 09:45:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C207E6330E; Thu, 7 Jul 2022 11:45:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657187116; bh=sJThdyBfxUyE40DY+r1wMy6yCo4WAYqM4FfbhFrsvLg=; 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=iV/TIVJFZaKMWDYNZm2Ot4OLA/r1DN/tP/vzH4OEa1BDkBW+NAc9yoOvu4cH9VHhT EN1kRLjIXRhc7ki0Em4IXrjeaY6sA5gck7S1nMUmKN17Q2X6CKt2xxjwl5EhjsMFqI mthwjQR4f7+UfaTv4ZD9vy47Gco1H8hXsrni2Qk7C2g6tnEsc5krRAeoSUV6WENqRZ mG6YNMHG2prSMhMDSdX2Kan4+U7c4/SnzNUM0yJBRa2+iFBen/hNf/hETJiFTfYmNT bVBQNViGBIgIm0ozsaRuoHMnJXZFdKAz8G6LtRFeFInaJo1PwpVhdlbIzfWG1H5e/i mrwBoRDlna+7Q== Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E126C60401 for ; Thu, 7 Jul 2022 11:45:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eBO7ffzr"; dkim-atps=neutral Received: by mail-pg1-x52d.google.com with SMTP id o18so16312796pgu.9 for ; Thu, 07 Jul 2022 02:45:14 -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=RW2JF1n1924LYd0TU9ejiNK/gAPHiBkN8cF+tJSgJjE=; b=eBO7ffzrRdMDyBft4SqZL2HWHi1LR3GVjgmBMM6vCXg4S9FHeneKbSM7yvAuChHDxc rsCRLPjNhXUJQBrorPSC8nfjT402lertejUjOrB4zWhb6kQL0GllXil4my/aILS8uA0G ZDtx7/OiHT+OltjxNyrHS3+ips83YxZlEtRc/yUJf77MyGCbFQyVtaPCo6v//+HZPsVN R25ifi6uns+GOs52ZYH7hr5HnOpySNGeq1WVmWfbwqt0HjGhDbxaoVhKODK14RyHO4LU HwHXVdIX61DF6PkNGI9ZyrJeZsVd04vEuwaaD9kMhf+VA0kaLz7hIbegQ/nqkAUgPdQC aYzg== 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=RW2JF1n1924LYd0TU9ejiNK/gAPHiBkN8cF+tJSgJjE=; b=wnFvsMYCZTPdFMD8BSwfuiay5gd6u9aHS4YItPZG4DZmGYyOuUhrZFNivDLx25qyA+ LUCqi8nKdrxp9DwFgL9aam2RwtBu6XzMh2KuYQAs+utsGt6JquXNbrUj9dqLZeVl2jox Q41mQw1LtBgYhzpYXtHAs79hCy7jTwyX5/UkDiY6CG7ZAFUMBt0iuezgzaFkz9L7VWuA m0nGXq/UxpvT51Rds1r4nLi8Qe2PZiUf7BwaYWnCFwvTpSFl4zSLx9yRrOeuobp2EVtS LFFTzpcHnkGJlLEPC8qmQZnV8BAfUa+VNItSfA/J8k4/sHuCvJJW9GvhZA7jqYWTChty Ijeg== X-Gm-Message-State: AJIora/siUAdnIRCH51+tJD+U8vaNrb81pswf4d76JrLvZkPFp9DMXYq oTdu2yd3gC5l4RQMnjPFGMLp8YlL32Y= X-Google-Smtp-Source: AGRyM1sl+CYf88sCazUQugDb4K4qJQjBqRPPOPux1eAJZfpzRXZ8F7wvQicezikrs25WxOvk1CERAA== X-Received: by 2002:a17:90a:710a:b0:1ef:991c:dc67 with SMTP id h10-20020a17090a710a00b001ef991cdc67mr4284919pjk.110.1657187114330; Thu, 07 Jul 2022 02:45:14 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30ae:d446:13ee:d079:112a:ac10]) by smtp.googlemail.com with ESMTPSA id p2-20020a1709027ec200b00168f08d0d12sm24530712plb.89.2022.07.07.02.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:45:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 7 Jul 2022 15:14:01 +0530 Message-Id: <20220707094402.28730-4-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> References: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] gstreamer:Convert between requested colorimetry and 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 and the function colorspace_form_colorimetry() to convert from gstreamer colorimetry to libcamera colorspace. 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index eb9c49da..feefead9 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) { @@ -119,6 +125,15 @@ colorimerty_from_colorspace(std::optional colorSpace) } } +void colorspace_form_colorimetry(std::optional &colorspace, const gchar *colorimetry) +{ + auto iterColorSpace = colorimetryToColorSpace.find(colorimetry); + if (iterColorSpace != colorimetryToColorSpace.end()) { + colorspace = iterColorSpace->second; + return; + } +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) { From patchwork Thu Jul 7 09:44:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16570 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 7D3CDBE173 for ; Thu, 7 Jul 2022 09:45:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38F086331B; Thu, 7 Jul 2022 11:45:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657187121; bh=vwLNOOd8KqMTxpbDa0Qo8PIPOBBLsA9MbL8bOUFd5bc=; 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=c7+X+akrMYm83DdfQvfR9dn/ZztTjphxI4gWcUTnS1+zvoDD6Cq+PhSiDPJEeKZ+k hKOZcEJVO5ys8MCpEEhH4OyPVbpKC1DQz1bxM1+ZfyWOR5pyHsLI08LCN9tLu0X0Sx i8iMIR8WHZdQN1vfy4e/XNsNAU4HsbZnNZOqLZouDdVDSvwllEy/BVjyziboZ3grPt j4+K+pXCwm3Dx5+WVcOtcF/Q0BJqk3xv2Da7yipj/EFAbvfsJdu9Ybe/VJETbv0C8T 0GiZHKqth+u6BYeyqfvLV5IP19hJV7qq9Qgri3dUwX7qjB85y0QsX29/E6kd9Ute2O nCaDnEq3kwzaA== Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCA6B60401 for ; Thu, 7 Jul 2022 11:45:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XbS8N8r4"; dkim-atps=neutral Received: by mail-pg1-x535.google.com with SMTP id 145so17474144pga.12 for ; Thu, 07 Jul 2022 02:45:19 -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=3iRgLuDezP4t290LfGG98rmzMB3RzYpumLdoyBdEnyM=; b=XbS8N8r46T2BCZQ2JwwgZFyGs/pbKqO3Vaoh+/YlxDmSxgdmYpNytmTLgUCIo5tQgn Gs3YLIrUQI3ca7KNdF/LZjppHfkU/qj7zBDpPDaUE63+4DGo0ga2oV5IJH6lOsNf5hC8 E1mLg4BwEG3VfIUt9COSyi5O6iY8fjCf+am8f20oQVt8BP8isaVFB4fTGKQ7xWlvMaQO OYteGB9OMyzuO1hO9nJLqWdA9n1K3iw+H6KlkS2yrfjjFQfHZyWFtfIQrkvgi02rMgnZ 7Adb3gYjBfHXEP8wjS6A/OlvB75yF435Lq0lCxxpWZJwlepcqLzWMb4ughb1GidwApco t7Lg== 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=3iRgLuDezP4t290LfGG98rmzMB3RzYpumLdoyBdEnyM=; b=joe3RT11fO5IrBreNxDB3a+WQyCII6VMToblop0I9Ts6GQgXuY0aTDAlhB1eGPbjZ9 WSW75SoXEYu9gGeuHRnPDLjUfqNLOsFV0uayiRRdeMncvDrvJp/8ilFcQvgOXlKH763O N5sHUWPkBW/By/3YMfHA7XrvQW87Lvdv1yRs+2gvBjabJMmvxso8rENIuiSM5E9Wq4fA Qax1Eb9Oyd2Z+ibPp1NQwSMwTBGhRC/SwIWnXkesFY30wLGpqOVMtdZC4mkYSlCuDea8 uxLwafsYJ2GGUmHD6x/A7EjPfcsJpSkZHRvrPpFoNYEpdontZ8T4IPOCH+/QhsDjTV8+ I22g== X-Gm-Message-State: AJIora/n1qpb6PEB3/PHhyVLnCfznmAzqwns4Bccr7K9f/nX46Me4Nyn 4F6IGrPaQsd4OsJTUxTIIMUUi39KJvs= X-Google-Smtp-Source: AGRyM1v93LrDd18u1VziFU5zxhVjk82rfLiKx2+fmip/DGGCJFmGycTghD2L1DP+QkU4Kqer1H56Nw== X-Received: by 2002:a17:90b:3e8a:b0:1ef:6a5e:e55a with SMTP id rj10-20020a17090b3e8a00b001ef6a5ee55amr4246968pjb.112.1657187118229; Thu, 07 Jul 2022 02:45:18 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30ae:d446:13ee:d079:112a:ac10]) by smtp.googlemail.com with ESMTPSA id p2-20020a1709027ec200b00168f08d0d12sm24530712plb.89.2022.07.07.02.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:45:18 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 7 Jul 2022 15:14:02 +0530 Message-Id: <20220707094402.28730-5-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> References: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] 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 pass that to the function colorspace_form_colorimetry() which will set the colorspace corresponding to the requested colorimetry in the stream configuration. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index feefead9..229a29cd 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -279,6 +279,13 @@ 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 = gst_structure_get_string(s, "colorimetry"); + std::optional &colorSpace = stream_cfg.colorSpace; + colorspace_form_colorimetry(colorSpace, colorimetry); + } + gint width, height; gst_structure_get_int(s, "width", &width); gst_structure_get_int(s, "height", &height);