From patchwork Sun Jul 3 07:33:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16524 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 D5D1EBE173 for ; Sun, 3 Jul 2022 07:34:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E16A6564E; Sun, 3 Jul 2022 09:34:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833651; bh=1be0cULGX9WjRXUnQ3WYCT+hSTxYbW0VRIrm7vonzRc=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qIHRi/9q56SahZfMnG9HDPZ+1ipLCKPa4vpy2j5vLTPDeJ18Ta/x3IUmDD9AOgwqi JOA90GAF/kJXTVEH51ZhBpTdQrkUiiStQC+kaspz14BbetHDawMHvBrKIMOiihBWTi qkwh9Yvp5Kh3ef8pQ129/PbdXOHb/+gN8VwNRz0quFi7rhXHeso/MjDLxc/LywEmDe le3uVgguzABGcoQm8gRiYuvF1I/bjKcEXh9lJnf+RrvAhhKgNBrbVL+aAQY9SU50iX 3lMtAhamfrXL9QKdsb6Oci+osmyZNQCuvOq5vSvCYIcugMhZzA5zXh4yDgVYQy5ZZe iVWJCVgTy6tNw== Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E5B561FB0 for ; Sun, 3 Jul 2022 09:34:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mqXWRA/w"; dkim-atps=neutral Received: by mail-pj1-x1033.google.com with SMTP id j1-20020a17090aeb0100b001ef777a7befso1308171pjz.0 for ; Sun, 03 Jul 2022 00:34:10 -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:mime-version :content-transfer-encoding; bh=cvCl0z382EYdkVPSkS58OKglurMkpOPZlcquWibtLi8=; b=mqXWRA/wfvwac8bzFe20xC8z1RPZ+TvpXL3ErGo3zqAufpXvIi0UKk/Jbc15GmevEm MCpdM5K8mDNjSMAX5+f+TmldQaj/ycCJJyyis1NHWZ9LNdTdoPFQMBp1ExCCcbzv3HKD NVkD3QnSwzssmfAirQ0kzhfGYwIhQQJY1BORI7J0KCSYOtECMRlTfn4l3eg+M3pjqXgH nxcA8efOjWMnNOshBSFqPo10FbB0rEbwdJJutRn7abpZ38ZQ9dBfbtd2007UxXF6rjtz Cg5nR6VKpY7tCELoXZZrUrQzuFlpHpECzIyyO62BZglNJHCb4lyN3o7aE57eYCXSSL23 kofA== 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:mime-version :content-transfer-encoding; bh=cvCl0z382EYdkVPSkS58OKglurMkpOPZlcquWibtLi8=; b=QQDU1KrVFi4NcyLmuZdEGZamhuw2nVd/alS+Dj13bwFG2HNeE2lLrJFMwlGa4LCsZy DpKNaw9qcolHgmsM59MYx4xH8rC36o+Ikfw7oUnazUu53q3NAOt/YSyo+G2D7O3ErzyR vk/8Vqit4Mfako2LAkKzriDJyaiVkqopsVZ4Cw0yWFT0lPop8/IdfRHA6X1kiTy+Vd9u ZYQz4He790+im65bLz0E1AjkkJ3RPGkqWQOV2eMHBlRjLc2fi9U5YJhURSn6bLtCE9Qe Vyno/nqGWSVVPayvrw1dBVD8j95BkQqjJdBBum0Du8KqoZftIFAgIqpLG0RJaFUMrlIE VFHw== X-Gm-Message-State: AJIora8Jtm/+twsfWExU/ohS22e80skCd7sI502AynUKAJkCX+rOAeyy XjHlOn6zNK++gWYy7dj72A4ypJpJsDU1YbYt X-Google-Smtp-Source: AGRyM1u0Ig2PP8/NdwgzMHfiDKlGNNwC2DLJcjcbJYN1Ib+07UHAJoKkNRZtarK3OAOb4GXsa1WMZw== X-Received: by 2002:a17:902:7d86:b0:16a:53f:4d36 with SMTP id a6-20020a1709027d8600b0016a053f4d36mr29125219plm.34.1656833648516; Sun, 03 Jul 2022 00:34:08 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:08 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:54 +0530 Message-Id: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/5] gstreamer: Convert form colorspace to 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 between the libcamera colorspace and GStreamer colorimetry and find the closest colorimetry corresponding to the colorspace in stream configuration. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 3f242286..20c39919 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -45,6 +45,34 @@ 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 const std::map ToGstVideoColorPrimaries = { + { ColorSpace::Primaries::Smpte170m, GST_VIDEO_COLOR_PRIMARIES_SMPTE170M }, + { ColorSpace::Primaries::Rec709, GST_VIDEO_COLOR_PRIMARIES_BT709 }, + { ColorSpace::Primaries::Rec2020, GST_VIDEO_COLOR_PRIMARIES_BT2020 }, +}; + +static const std::map ToGstVideoTransferFunction = { + { ColorSpace::TransferFunction::Srgb, GST_VIDEO_TRANSFER_SRGB }, + { ColorSpace::TransferFunction::Rec709, GST_VIDEO_TRANSFER_BT709 }, +}; + +static const std::map ToGstVideoColorMatrix = { + { ColorSpace::YcbcrEncoding::Rec601, GST_VIDEO_COLOR_MATRIX_BT601 }, + { ColorSpace::YcbcrEncoding::Rec709, GST_VIDEO_COLOR_MATRIX_BT709 }, + { ColorSpace::YcbcrEncoding::Rec2020, GST_VIDEO_COLOR_MATRIX_BT2020 }, +}; + +static const std::map ToGstVideoColorRange = { + { ColorSpace::Range::Full, GST_VIDEO_COLOR_RANGE_0_255 }, + { ColorSpace::Range::Limited, GST_VIDEO_COLOR_RANGE_16_235 }, +}; + static GstVideoFormat pixel_format_to_gst_format(const PixelFormat &format) { @@ -87,6 +115,49 @@ bare_structure_from_format(const PixelFormat &format) } } +static const gchar * +colorimerty_from_colorspace(std::optional colorSpace) +{ + const gchar *colorimetry_str; + GstVideoColorimetry colorimetry; + + auto iterColorimetry = std::find_if(ColorSpaceTocolorimetry.begin(), ColorSpaceTocolorimetry.end(), + [&colorSpace](const auto &item) { + return colorSpace == item.first; + }); + if (iterColorimetry != ColorSpaceTocolorimetry.end()) { + colorimetry_str = (gchar *)iterColorimetry->second.c_str(); + return colorimetry_str; + } + + auto iterPrimaries = ToGstVideoColorPrimaries.find(colorSpace->primaries); + if (iterPrimaries != ToGstVideoColorPrimaries.end()) + colorimetry.primaries = iterPrimaries->second; + else + colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN; + + auto iterTransferFunction = ToGstVideoTransferFunction.find(colorSpace->transferFunction); + if (iterTransferFunction != ToGstVideoTransferFunction.end()) + colorimetry.transfer = iterTransferFunction->second; + else + colorimetry.transfer = GST_VIDEO_TRANSFER_UNKNOWN; + + auto iterYcbcrEncoding = ToGstVideoColorMatrix.find(colorSpace->ycbcrEncoding); + if (iterYcbcrEncoding != ToGstVideoColorMatrix.end()) + colorimetry.matrix = iterYcbcrEncoding->second; + else + colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN; + + auto iterRange = ToGstVideoColorRange.find(colorSpace->range); + if (iterRange != ToGstVideoColorRange.end()) + colorimetry.range = iterRange->second; + else + colorimetry.range = GST_VIDEO_COLOR_RANGE_UNKNOWN; + + colorimetry_str = gst_video_colorimetry_to_string(&colorimetry); + return colorimetry_str; +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) { From patchwork Sun Jul 3 07:33:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16525 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 0CCD3BE173 for ; Sun, 3 Jul 2022 07:34:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CCF706564D; Sun, 3 Jul 2022 09:34:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833660; bh=HBN0zhzfgevyKBGy8V3w5seZyiIHkcYKXESY1RADJgw=; 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=XNoU8eTJgvYqsbLrbeIgaL94xmdLYRO9HkBoxMOC8HVwDQWNu4z1ngcQJdr2tVNLy 8vtX3mlTSMP4mmnJMKQhEfoQRIzYj6Yz4GkKM8XY5fVpvN08y4sllTrTuv16H5cLVN 8OplWEARt7n+TyJQbab3JOpIFKGTlCRjgrjpyO+/UcH+sZ57THLOzee8f+VrIEOqmW QzWz3B7aMwSgxtkzXwXAaRlu3eyCbOdR86Df7IK5ETrFXwTjwLHE0Gp8Bf+VaGvCXW Eet1nu26qmNRQ9CuRug1adAzP6CcuT0vwoeEaIm42d05/TzISVktFVCfpFhQqhqhTN RbcFrvGktxaIg== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 850AA6564A for ; Sun, 3 Jul 2022 09:34:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d1fYrcIo"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id g16-20020a17090a7d1000b001ea9f820449so10481855pjl.5 for ; Sun, 03 Jul 2022 00:34: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=BVRpnbi43YEWEksgXVhZVaj+0wwRHaTrgC6U8PWM9hQ=; b=d1fYrcIoHdBUfE2bv32UPUR3bhQtKByakijqFmwF3vghaGFbBs/5TIC+RkLMHriUrc KE10m4R5xPykFrVD8/YrUbuZS5PwOz07CzMHN1Hxp9BBkSPy3PNMoBoDX8rZbUOh3yJX j8M38zpn31lWMlw9d/LAJ7AhePGEcf+0/FWJbG96A1Whn9fthCIncEP4CFODemV7trL9 bBxLRzb7bXUcpkPYrldLveD179yyW2W/8y4R3KGJcogHIfyvKEO8QmoezvlPYIXXeUqS pkw1wVOEYLedP1jwj0HK2J/EauNs1c4gkogY6V9hkBBJcSKZa+6nAnxFSPtOf+AWLIzD XE6Q== 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=BVRpnbi43YEWEksgXVhZVaj+0wwRHaTrgC6U8PWM9hQ=; b=B2kvatwpz2P4sWD9ShpUhrx1gPipBxbHAq4WLZue7eShuGQ3bHPagZRRN9P3YJ+CkN YFgrVJWlqLynKL4JTmBtaKcey8cRKIO1xkJyPyBEUPIGjv5gjR30Bpb6ETshIoKi80dW 1pozEnNzkvyf5AkaGLpiyalqwdBFZX6TVJJYeX5u8Jdg7MgXU588rdEVKcGktUSR4T0R lNWzo+/zHl0A7CSJlHWaEqztWCDEHwz9w53sQvOPvkbFNwhpz8wSAaQJH7xXbnpWIyDt CKsS4c/1uptfOjvBiXTnuytDsQ1XtRHc7ELHLJFUd916ZAiNed4qkJLd/r0nBPHZsF3h votQ== X-Gm-Message-State: AJIora8j0gQg7+qSLdU/tFgaraqg4QgZEnCmBW8RCTzAXp6heNdUvh6S aYdTXgqNhBAISIUz11t9F6cEqcJaEUDwCwaP X-Google-Smtp-Source: AGRyM1vuACPD+Mt34E+de2Z2oNJsvKPNok2SvvuqJBsUPEhVZcjZWZ/eBc4OBIdoSUyvtvLW70adlw== X-Received: by 2002:a17:90b:3850:b0:1ed:7d1:f0a with SMTP id nl16-20020a17090b385000b001ed07d10f0amr27903943pjb.67.1656833657952; Sun, 03 Jul 2022 00:34:17 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:17 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:55 +0530 Message-Id: <20220703073358.76643-2-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> References: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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" Get the colorimetry as a result conversion in the previous patch and update the colorimetry in the gstreamer caps. 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 20c39919..690a9f43 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -205,10 +205,17 @@ 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); + const gchar *colorimetry; + std::optional colorspace = stream_cfg.colorSpace; + if (colorspace) + colorimetry = colorimerty_from_colorspace(colorspace); + else + colorimetry = g_strdup("Unset"); gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, "height", G_TYPE_INT, stream_cfg.size.height, + "colorimetry", G_TYPE_STRING, colorimetry, nullptr); gst_caps_append_structure(caps, s); From patchwork Sun Jul 3 07:33:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16526 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 8D568BE173 for ; Sun, 3 Jul 2022 07:34:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45CD565650; Sun, 3 Jul 2022 09:34:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833669; bh=kCce0/Hrh4NafDou48L6iKh47MxvPkotjv5ywVVuOA4=; 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=j1r3HodhQVE/rCdQI/gxz8ZpoY9Wc9zYnGaj+JsMGr3SRTwLXTek4spAqfg+7CPdC WLgag9vRNn8v7XQoeAzjTnHjYHp6E/YYJN1E+2Xw1S1NJrcjKfQNCGiLMhX6w1dxW+ 18FP8a/CRHVb1QQq/RSB38qnakme8kEnNNfQf4X12GLnfL+ua4mvnixDphWI89TWA3 vCyo8rQEZFSGsib2DUbvJBHx5a9CqIZRo24slSHHiIKlVAQ4aavqJLfUkxNxHZGCyQ y0hGZkiQeHhNGvkZU3/Q4eJucr3kLCICP/qHM5AGmsTHqceV72ZMjEUraI2s9XxQCk FdpQk3uJRWb7Q== Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4F9E6564A for ; Sun, 3 Jul 2022 09:34:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="o8/RPUxq"; dkim-atps=neutral Received: by mail-pj1-x1033.google.com with SMTP id fz10so390991pjb.2 for ; Sun, 03 Jul 2022 00:34:28 -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=Tb+P9IAJbs/5lWvtGt1UxkTi4iLo+typkPrJkm9ogY4=; b=o8/RPUxq9T87vvQbLIDkKhQ9N9jB7H0mktF0ziXqHXcmUIQCIZ9yQ0P3WIUE1cj0XT fEqy5Zh2hJ/n3I/BU4JpIb7sgyxBYOFQ53fhZ+E64oXTfr58sqDys36YJ6sBX+FuEcXL +Dne9eCpOf9RhT7rYjn/MTk6oVFdS5eRK9rWCNZGYRi5ocW5vxTZmF5cw93WU6Atr/tk rgXyKh85EqKPbs/Z+8SUv1CNBPppPPigHaMOEvfGDjZWmiMsY70aYBHM/BzlNjKZMUIH o+ZaYhUffk0BcbzpV8pcjH5HlebR6PpRa/aMzqwnH/fhxn765Es3rN1rJ97ZczOdcQ1h UWdg== 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=Tb+P9IAJbs/5lWvtGt1UxkTi4iLo+typkPrJkm9ogY4=; b=ux73wW+V37zlnq5LZXl34/IUpVHeYmHS6GYZJuNAvNutBJHrkdy4P6vzLC3/FTiGpS 4/p+nGCAgrJXOp06dGg01UdaUYkQQx21139dKU6glMnsEe9oqUU4RSWhHfjmhYpw3/b6 bvpwgoQ/hZ7HqCVjb7bxAjAfncHbMY+3Vp6rE+2kQZN4VmlwJczeXbTMCeRdHgQEzXJ7 nLTS9WSeyH+vYboM4cGd+E9GpqAYlbqqRaU3EhJJlLo1UjcKG88Oxy12I5RmFpUFAQw1 kCneuVnREL1y47hFVR6BMf1Gp37Yu5HFlvf6q2oqhsOSuQXWM8OZvg7mk5ZFruCh3LNA 9Pzg== X-Gm-Message-State: AJIora8yFl5rL4VrKbgQf+EQnqNQvxtUkyeQqISM7hj1SwBW8c9P9eEr SLMZCpRXLyxqEiu/zpfD57ykQHk7QfvX8QB3 X-Google-Smtp-Source: AGRyM1ticpmnaKsxqD3pBrUJPEMu8LYV3Z6OtFPc4WDhogPQ8oaxYAW9Wh+ZL5qM/HIySp8m6bywxA== X-Received: by 2002:a17:90b:1bcc:b0:1ed:361b:702a with SMTP id oa12-20020a17090b1bcc00b001ed361b702amr29592910pjb.1.1656833667149; Sun, 03 Jul 2022 00:34:27 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:26 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:56 +0530 Message-Id: <20220703073358.76643-3-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> References: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/5] gstreamer:Install the colorimetry property 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 the colorimetry field in the _GstLibcameraSrc. Add switch cases in gst_libcamera_src_set_property() and gst_libcamera_src_get_property() to access and modify the property. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamerasrc.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 46fd02d2..120319b3 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -121,6 +121,7 @@ struct _GstLibcameraSrc { GstTask *task; gchar *camera_name; + gchar *colorimetry; GstLibcameraSrcState *state; GstLibcameraAllocator *allocator; @@ -129,7 +130,8 @@ struct _GstLibcameraSrc { enum { PROP_0, - PROP_CAMERA_NAME + PROP_CAMERA_NAME, + PROP_COLORIMETRY, }; G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT, @@ -532,6 +534,10 @@ gst_libcamera_src_set_property(GObject *object, guint prop_id, g_free(self->camera_name); self->camera_name = g_value_dup_string(value); break; + case PROP_COLORIMETRY: + g_free(self->colorimetry); + self->colorimetry = g_value_dup_string(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -549,6 +555,9 @@ gst_libcamera_src_get_property(GObject *object, guint prop_id, GValue *value, case PROP_CAMERA_NAME: g_value_set_string(value, self->camera_name); break; + case PROP_COLORIMETRY: + g_value_set_string(value, self->colorimetry); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -717,4 +726,11 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass) | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, PROP_CAMERA_NAME, spec); + + GParamSpec *spec2 = g_param_spec_string("colorimetry", "Coloirmetry", + "Colorimetry that will be applied to the StreamConfiguration", nullptr, + (GParamFlags)(GST_PARAM_MUTABLE_READY + | G_PARAM_READWRITE + | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class,PROP_COLORIMETRY,spec2); } From patchwork Sun Jul 3 07:33:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16527 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 2920ABE173 for ; Sun, 3 Jul 2022 07:34:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E90AA6564A; Sun, 3 Jul 2022 09:34:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833676; bh=od/F7mDvbjsOqucnf4PTHvCW287++kgVDi9oiaJXcfc=; 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=p6+RzO54htspqhEcsBE7rXuTClTd5fmXes2EliVKdOQTIiC8vsWLUmVoM22pXsxUt fmfQu0b3Fl6OwcffHoGk+I9qaoQz9NnwW8MP8dskczpHqHJHDQ2OujjtrF5VQw7Lkc 4Y025ib++ljeGW1QbIsbCP/ehCC5aHMTupSxCJvp3hu5zVegOo4cTIlXbmQakE27uQ FpQLxyzRHrCP3yluAjcNC/yxykoOmnCmYJo0ET0OCnP+TuWMwl9fqaFFSO8VzjrXgo DNP9COGqEwyilVEpVsrk/tAJ/weicrMd+e5DGK63r8pQtiL8kqq/7Tpge4hXe/WqzC 32kFM7JpdWSng== Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2566E6564A for ; Sun, 3 Jul 2022 09:34:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ig09jwFq"; dkim-atps=neutral Received: by mail-pg1-x532.google.com with SMTP id q140so6196970pgq.6 for ; Sun, 03 Jul 2022 00:34:35 -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=uKye1mYdGvCKbcR65Kghc9l6W+ZDxjv5P//wb8fqUks=; b=ig09jwFqUB5PJzDSShXhn5tqQfrDQyS9Zo+pVk8kE+VFKxh5YYMd9SqyEH0dz8ctl1 kliBvLNVbrxBW7WMNpt58oT0P7gSUPaThSALHXe5Lk1Oh/qSCf1DwwNcOin/Mkln4Ljr Oxw+Y5RBDtiY0eK2OctfxXALGy2QF940BALwiRcWkkVOVgxcbbCpyqI9bdJIJw0JIzvP v4n/96CsRoCJra13NV4idaM45PdXsSlw+wpLorxDo7cJ/2Dk0MUNLMBh1V999gj/oho2 CcfgQv2shFmFzBdhAyS4axYFuI9rMyZfkT1YPV8rqYxLa2uS+Waorh73OTuWyNuKzHod y/cA== 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=uKye1mYdGvCKbcR65Kghc9l6W+ZDxjv5P//wb8fqUks=; b=BogF5sufkbW9iFKkOb7G7pdLQK8uiX9xPKPOW6GSYxQYnep3nlvGTdtcbFrevvwf/N AHnNrzAj35djTAGjDVvUCShC8t2UfDx/oY3rR8D1w0B3ZmSyYmQ7hgckxn6Bvv6aMIeH /w/gCGoAsVq2pRqh66oteksarmHUB+djDGh27oguno25BTcHfNS8bu2x/HRGCdZ5IefB IKHXOYxYRQcc4FxhynViPepEOvESwSaSlxjmErToDfegg7Q1haGJW0VtP4KsKqYZP9Wv bKZmyac4ycKsRh1MOSeJzx1/5BrcficaTAmkZ5VEs8z5lpaG/NY27L//6KQzjNm6JIKo FDYw== X-Gm-Message-State: AJIora/LssWIoCSmrC1aEW4XVuNLT6dEc1DKNM8NlJ2T4qanRio87tTY QvkIze3g1g061vCzmTYyeEG6aAeLrHeY+g82 X-Google-Smtp-Source: AGRyM1sIwMe+mpuT6nIuCybHgovxEoissNSPhL0UaFJpV9e3st1CRxODg/rpb1hwEMA5UtKwxj60Zw== X-Received: by 2002:a05:6a00:b94:b0:525:930f:57ff with SMTP id g20-20020a056a000b9400b00525930f57ffmr30161252pfj.72.1656833673521; Sun, 03 Jul 2022 00:34:33 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:57 +0530 Message-Id: <20220703073358.76643-4-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> References: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/5] 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 +++++++++++++++ src/gstreamer/gstlibcamera-utils.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 690a9f43..221100e9 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -73,6 +73,12 @@ static const std::map ToGstVideoColorRang { ColorSpace::Range::Limited, GST_VIDEO_COLOR_RANGE_16_235 }, }; +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) { @@ -158,6 +164,15 @@ colorimerty_from_colorspace(std::optional colorSpace) return colorimetry_str; } +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) { diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h index d54f1588..6aff6be0 100644 --- a/src/gstreamer/gstlibcamera-utils.h +++ b/src/gstreamer/gstlibcamera-utils.h @@ -20,6 +20,7 @@ void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &st GstCaps *caps); void gst_libcamera_resume_task(GstTask *task); std::shared_ptr gst_libcamera_get_camera_manager(int &ret); +void colorspace_form_colorimetry(std::optional &colorspace, const gchar *colorimetry); /** * \class GLibLocker From patchwork Sun Jul 3 07:33:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16528 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 94CD9BE173 for ; Sun, 3 Jul 2022 07:34:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5F08365650; Sun, 3 Jul 2022 09:34:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833681; bh=Djjw2Xg6w0jHQcyV8UYedjkqFjMlptdQ0h4ErIx2ZfA=; 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=PgCMQqG9Qkix2BVqaCuOF6WaNT7m2gfAkIhVZe6C0dohjeG65pbkHIusdqnXEGFRl 6WFZd5lnz+37a/v0Lvr/nJuZaN38G4/QARCWxITC3JIeOVIGC9kMuqdyyneV0PPSxX 8FIRCVAlDO8NeczL+/fZYrkofpSxUK5OPo+Pe7H5dZ0G0KxuMZXBCj/K4qNZ1QxX7I JJapaWpRc6KinvBotX6xHIgfbdIwopneH0hwwmYoH28tYkxOO+8vcDT/RApVhj4M4l kUUXQSs1P6VQTVDMaNPIp1iocUEdmyd1PQjfuT04d8ed3hZhuBEDVb2+f+TohDQXo5 Ah4gJODI4+1mA== Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECB736564D for ; Sun, 3 Jul 2022 09:34:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DCYtK6Se"; dkim-atps=neutral Received: by mail-pj1-x1036.google.com with SMTP id g16-20020a17090a7d1000b001ea9f820449so10482199pjl.5 for ; Sun, 03 Jul 2022 00:34:39 -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=Cr4BjYS4XcdvowXiRLCk7G0cV8EtybZvIBEeGgIpvTQ=; b=DCYtK6Se3YURdLkum/5M/QytcNokNE8E6aGFOphfcwjk32ucuikX7hZtWktOjr6nAV fPLxwaNULKuMn4kqGcSFahyQoT+cMED2I+eRfPLqXgMaQeAHqkZGUptaBE2Zf4AxpLDc d3nYynlwX9QXsHi5VyyiKPErcqxvV/okaSoXvlAOdRd7p/zgJWkyaPo/tR+LQa1voQY6 /LZBp0O86c3X4yushS94DFF/tuTBDNt2/JxYUwCeH+H7aUHowj2/Z3dLCGWEsVEV94kn 6qfx6YQsCTGWFtTuarrWAtAah/qLmF0G1Q/LBanEzNManBXN2fgqMzEmVpLtk8JWnOBb dOUw== 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=Cr4BjYS4XcdvowXiRLCk7G0cV8EtybZvIBEeGgIpvTQ=; b=53zuC9DptCXmi5XhjlLsTkKY3iwycg0dCfynfdtRTyitPErMWENQOwx0TOxJbhv5Wf ItjgVqe566TPmpTAqv66vKyi6JmyEoRxl5rErFLYEGlQL0D1R+N9kd9TlypxDjES1WWj 302J1MvWvRMI+cEj9DNm9IrnYDl6OHmbVgkI7Copl3rU2PadFN9brpaGolKpgQUbRkdU BwWv4bYoUDkGAMjjZTVFO7S5D1IUBd5L2GlxbbMJ4fqeOxuKPx3Y4mwtBRmo/Da6d7Nl 8aGvj7LdYb1UkGrb7dURY7BO//W/sV/mrrjKkJnPhLp6r2g8AmtNJOvDGbsUJvYjpvIb pkZw== X-Gm-Message-State: AJIora89J02ysds9RReKNdEJIKn12tsuCsZd88UipXU+XKAE3GJEe4yV NiFdZlQxxRguQCaj+W7AiHuQvbAbG5k9AcmN X-Google-Smtp-Source: AGRyM1uY0HuqcBdI6hY1wgV/GZpk5DceyU6/fbPMhlAs0KZBfdNhY/O/zCxc7wYzeChwo60z+GB1gg== X-Received: by 2002:a17:90a:4294:b0:1ee:f3f2:9cd0 with SMTP id p20-20020a17090a429400b001eef3f29cd0mr27127788pjg.79.1656833678842; Sun, 03 Jul 2022 00:34:38 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:38 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:58 +0530 Message-Id: <20220703073358.76643-5-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> References: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/5] gstreamer: Change 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/gstlibcamerasrc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 120319b3..91668e81 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -387,6 +387,13 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, for (gsize i = 0; i < state->srcpads_.size(); i++) { GstPad *srcpad = state->srcpads_[i]; StreamConfiguration &stream_cfg = state->config_->at(i); + gchar *colorimetry; + + g_object_get(self, "colorimetry", &colorimetry, NULL); + if (colorimetry != nullptr) { + std::optional &colorSpace = stream_cfg.colorSpace; + colorspace_form_colorimetry(colorSpace, colorimetry); + } /* Retrieve the supported caps. */ g_autoptr(GstCaps) filter = gst_libcamera_stream_formats_to_caps(stream_cfg.formats());