From patchwork Fri Nov 8 09:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Qi X-Patchwork-Id: 21861 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 D081DC323E for ; Fri, 8 Nov 2024 09:12:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DFAA06548C; Fri, 8 Nov 2024 10:12:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="QjzWPhF9"; dkim-atps=neutral Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061f.outbound.protection.outlook.com [IPv6:2a01:111:f403:2613::61f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6ECC960589 for ; Fri, 8 Nov 2024 10:12:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dbasCs1bKmftXWeyKokXh5z2DOEovMKDlO/Mkgi7D2gFX7B7haTtkcP4z92Q6vsgJc6cSS7qZRcH0kW6pimy/f/Li99eT3FnX1uEYD0JWA+SeFag/nlYV88VlsA19ABd+RDdyf6g/MTKJI0UlWGJlWq4/JE4/cxAJAFEUoys9HrkSuiUwIlPgDyRwhFA3CKTAbFL+YB6Fj3j8/hbZCGg21VCSkx+pNleXCwVm+ol9J/SFxU5YdrI1bWmg+enw52m1i/4CGyqyizIcDZpfWycurlLJojNh1gDvfLYMtHguKr2WAwLI2QZW5vSxkyjfasAskL2hN9zSKm/LCBgVJ33kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BjLsWZ31MQJ71dVxabE8VNDMVMORKrSSq0GWVWrx8fc=; b=I13ZVfyyiNt51CMBS5teOhizizwjb9RruC9WkZ5oz6ez8Lqx0/AI5zSgCyBf4PRPqVXqH6zZNxJLyie1IaIQIO4TRC//VSyLB1/t7wRZoEvHilmEfqWlwiOVto70mvqyTzuBDGIzpewrzVBJ9/fkH/YnWz0oQwERELsYo5e7fTjQDFkGlR8LvBmrloDTMGthTOqPnw3D11Nls+VQhcxeqNQzNsC7cei47tEZTq7wHwpp5Q1WQBYaeq2AzDZbVngZzFUiTBX36cRHTw5LxKn2hj8c0aps7wMEbJTcVfBBoEnqRDoQ5Jd8ritEaYobcQo1zOU4ErkS+2QusMHmzATxQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BjLsWZ31MQJ71dVxabE8VNDMVMORKrSSq0GWVWrx8fc=; b=QjzWPhF9OkbDoEO/V9hyzkpIdUXYffhQGL5ef+OeH21cvwBZ17oVjjYFuWX+fFK1XW+M87xrNl4ZXPnzmgStfY/oUI9WRY43jdIfbE23bKeIxyaBNVmAQY3jx0OpkteiPvElH0vaE0FBH3oaQFupfs3Bs4Si6ncVNSfy1GwCS4fKz0xmw2byLkLn00hDPriFcn1Ug5ocZAg8W2/x26tBe0L2qObWzn2MvZGCYUvb1OSYN6EOpox7ArJKt49J3rS1wpFgkAO5E2befKO56UB4X2GhJ3DI8FDKtrwZ/u5HoB2S60gB5dDuGL+RGopoPIyiO/N2rA2+RHd4dbjQagsbdw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8285.eurprd04.prod.outlook.com (2603:10a6:102:1ca::15) by DBBPR04MB7834.eurprd04.prod.outlook.com (2603:10a6:10:1ee::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Fri, 8 Nov 2024 09:12:26 +0000 Received: from PAXPR04MB8285.eurprd04.prod.outlook.com ([fe80::e003:8fb:64ea:acfd]) by PAXPR04MB8285.eurprd04.prod.outlook.com ([fe80::e003:8fb:64ea:acfd%3]) with mapi id 15.20.8137.018; Fri, 8 Nov 2024 09:12:25 +0000 From: Hou Qi To: libcamera-devel@lists.libcamera.org Cc: jared.hu@nxp.com, qi.hou@nxp.com, julien.vuillaumier@nxp.com Subject: [PATCH] gstreamer: Handle GST_VIDEO_TRANSFER_BT601 Date: Fri, 8 Nov 2024 18:12:03 +0900 Message-Id: <20241108091203.3751671-1-qi.hou@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SGAP274CA0021.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::33) To PAXPR04MB8285.eurprd04.prod.outlook.com (2603:10a6:102:1ca::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8285:EE_|DBBPR04MB7834:EE_ X-MS-Office365-Filtering-Correlation-Id: 61bd1c74-55dd-498a-0e13-08dcffd57639 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: /c1iclfa3PFpz0ennfCO3ZBps7vd8YP/XSsdkmkIbjEv8gtYGwUcaaBknORoY4EeEbnwBx/CIfJA1nQ6LdynPNHfJJDy9D9mkWAI7eGTKDX6sXIX11tKAnNJ0Z8OVKzHLp8BSHnp1g+6e/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USk48wOsLEoaaJJxk3Hsz6BDrnHjmfjLfSzIA5reFgMHJJO5p1OtgPuw5okQRlc+uqmHn7uxxYvOp8JxzjRQ2TkSI8sy0jQ6bmJ0urNIRb/4pA9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8285.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ep3CzAKD9VaSD8UZL8sEqmwtACbjJugre8rh67aGC0ccclZIHF62Hb7UK8c8aIvFJWvPzJWv13dwctiHxxUY9mOExSRKlbe6Ls1uJGOq0j9Xgc3gHeo+ngZJPot7tORNe/dgoYh6Nak9N/Tc2ohOHRbUIvJwtASd2LbyxAxJ/aaR+k028IAIK5MzcS43cjkI+CqSk1xiKvap0dmoHDcQHuTN9V3jy/o2PWDk+906r3mlzagRgv9IbNENa8hSBKlKAI9sVWI/xk0j5xt0tw7uMNd9fCmDmhVkCV1Mer8UAEGRm2XAndyCnreNwx0f+fRn6l4WffGLIWVgh6iLu0gYoQ+dU1w8WEJANr2IDrYmn+fFe/0xmvOGN7SHtokCCUYkUnwJG1rL2tZhBLQYRi4Ro6tjY2P+lVSyxVwc3AsVdrqpDWBr7nnsoI0IkQXtfPFw1ZoHtvoXy70j5WIG14JgviX9nC3gt5x85k+O5sk1ACc5X4AH5U+IsQGQ5nN2i75Xe7xSQDuPCvOrZeVpaNrJTWC/hn/fe9A2kkNMkuCNSWVXgFUCr6Nu9lFrnDES+albz3bpRYjoyVoQ4BTdHIO0ydjcwMdMoZCe+R3GadgYzIgq9gKgkJIU0QW2RJuHM3SZtMsYbuzdwPGCzUG3wUizS0c/Yk/wFYEqH+siBXIgIeXKWnGGQOEK689uSrKSig3a/5cvxSKBzNF9KH/zABO3rvPT6tXCtCqzCXHZZijTICRb7CFFt/VHZMUY8KUlHGXuoG7EYFMUExaicnj0KHDedAaScxN6Hnoc52zhCzxgPMX1VjtKY505JHpn3CIVGSeHY/n71Rm0hRTGlbor0+0a4Sci1ciWQ3fsOcKkxC26/2H8nKoG6rk2Pz3G62ruXhY25wlG1HKXKL+1YPjIcdqFhoh3FBD0sq63aOvF12OKcp2i5/wCvGeobc+qGbk2o8IYOhHk+Y4D1P5kF+iaJ/ptJGaIwAGModAUsgXF73Uv7UMqZWEjP+3ZMWqldpoSAZdRWZ6gPSewD7VOpOajV80dM2z2XKAZHAVpc2wCa515dwItxNtiHsZsNscR4PI6WIoC2itBSf4TGZxhWQ2SpTEu2+P9yjvs/7WZRdDkGU8KuY6OMiJG9LuYSwzTFYpBwKzmN1Bjm15yTvRns/UCwar7T5Lqlx8mncrnMg2WF3jilqDSk7EMoYrXH3RB4Wgg5FxyPdxkj811dj9IJhUMReX2X6Us9DuIGkvUiS92M8fmBaQZmsc+FbWpi2JtXTH7ZJUYd8Qwh1/DgGtR5sCjmmYfnWqUZU4I6j1ncuJcusJXAKyV6aaocPZn+pQMHVHwtL+Q/HvaY2PwXmd+MVf57js77+Q2E9j3v4xlkab9+QEVmlCpFxntzE1rDs5KbAdAeb2MJHv5W1kQmTeWhzPGbERGynOIDYUwYB/WeJVF0nLQZTwIO95vVR/VwCNoJU5qhXv/gWOMdYvuCylXh5Lsr7EZJRR1JeibbKKZNBjP7LLkC2Oa0TUT6nX/6zdqA2crT2SEETLYCz/nSLR2hnmLpo6xnr8zDYl6jRRJ0oJKtF3OnjI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61bd1c74-55dd-498a-0e13-08dcffd57639 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8285.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 09:12:25.9331 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mlJSdWepCZxZYhEQ8AhH+y/rZR0lYmHMCgb5+6nq1wQ0bR/UWQfwggDlwhxy9DYp X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7834 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The conversions back and forth between GStreamer colorimetry and libcamera color space are not invariant for the bt601 colorimetry. The reason is that Rec709 transfer function defined in GStreamer as GST_VIDEO_TRANSFER_BT709 (5), is to be replaced by its alias GST_VIDEO_TRANSFER_BT601 (16) only for the case of bt601 (aka 2:4:16:4) colorimetry - see [1]. Currently the composition of the GStreamer/libcamera conversions: colorimetry_from_colorspace (colorspace_from_colorimetry (bt601)) returns 2:4:5:4 instead of the expected 2:4:16:4 (bt601). This causes negotiation error when the downstream element explicitly expects bt601 colorimetry. Minimal example to reproduce the issue is with a pipeline handler that do not set the optional color space in the stream configuration, for instance vimc or imx8-isi: export LIBCAMERA_PIPELINES_MATCH_LIST="vimc,imx8-isi" gst-launch-1.0 -v libcamerasrc ! video/x-raw,colorimetry=bt601 ! fakesink Above pipeline fails to start. This change updates colorimetry_from_colorspace() to use the expected GST_VIDEO_TRANSFER_BT601 (16) alternative definition for the Rec709 transfer function, in order to fix the conversion from libcamera color space towards the bt601 colorimetry. This bt601 colorimetry special case is identified by the usage of the Rec709 transfer function combined with the primaries GST_VIDEO_COLOR_PRIMARIES_SMPTE170M (4). [1] https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/724 Signed-off-by: Hou Qi --- 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 732987ef..b2d64733 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -112,7 +112,14 @@ colorimetry_from_colorspace(const ColorSpace &colorSpace) colorimetry.transfer = GST_VIDEO_TRANSFER_SRGB; break; case ColorSpace::TransferFunction::Rec709: +#if GST_CHECK_VERSION(1, 18, 0) + if (colorSpace.primaries == ColorSpace::Primaries::Smpte170m) + colorimetry.transfer = GST_VIDEO_TRANSFER_BT601; + else + colorimetry.transfer = GST_VIDEO_TRANSFER_BT709; +#else colorimetry.transfer = GST_VIDEO_TRANSFER_BT709; +#endif break; }