From patchwork Fri Nov 8 09:12:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Hou X-Patchwork-Id: 21862 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 15322C323E for ; Fri, 8 Nov 2024 09:13:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF7406548E; Fri, 8 Nov 2024 10:13:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="JA2ZlhS+"; dkim-atps=neutral Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f403:260e::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2058060589 for ; Fri, 8 Nov 2024 10:13:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P++hj+uDyboyDphU9lcGzY95i6EEGid08PLb8XwLI+AWEJiEg2pee2f3yPzM5gDLdxRZUe5GQNRWGkp1rQP0U8pu7lYnLx/p3USkXTGLKzBvW3gx5lf4+z9wpKdSheeJ4T7/QG7+7FSDdD7ZbNBSxQx+UbvE4cQndE43DuhR/ALlAdUpquEQd9LrZ7zAd2XdZEXj5yStPuLcCT0b2BgIJAlJXbxn+1ciCvu3TWDrlSzSD6gMoCQEcAplbcf8ac3QU5pqTldzG3nfh5EfMUcJfTXTvd2rTf+Q5hZQbQbASSt7QEXCTxRdBF+e98L6xjJ/QRG7f/n3mZ8jlT3EnzV47w== 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=npEZybaAN7M53jtYqOYwqE7hDl9O3u238af7A7zISPo=; b=U+rFsp9Sd/wwjCNCGbNPyJxk6xWlqgAKtG+HOm7VDBLdk2Bc8qHKVBi9GxQobtADOOoL455bvLMWQbgbqcaFVEB74Vb5TcPCVBO3iW9mEWxSkDqjzYFl2Rq8YYOveGszUiV+Jocdl1w4ifxgjstwZnQoQbpVlc8vFReSR0yLL7E63XGQHoa+/wiEoRoY0m7j8P9dGdyayPys/g8uupMHXf3h4LPFf6hzLBFMMT7EwYwAhNzr5h3ga5QNH+gNcJqFd2O7YJVWop1JZOOgBZczV/2LdjKyah+Vzo9MEC2W6HT58zhRP/ark8QWvaGwY7Q6+yKxV/gL1WAOuJUl548xcg== 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=npEZybaAN7M53jtYqOYwqE7hDl9O3u238af7A7zISPo=; b=JA2ZlhS+t54GOaxlTMbyIorrQ1l7QHJy2TTzYdAw+IAewmkdrqjfXMUNX1JKc11JwHgDzPwmjbBUucMT9emTw2aNRsWpbjWBX0tu40a4mPDFPUvnWjJEGpwkjwm/wdZukL7dalZmAcmJF7e03IsPmaiW9Ivw74twLLZ/2geNrZghqH9GeV0k/5TZh6W9PjI+BOx0Le/j69xdHYyF7V38b9OGw+i/28rSzlSbMzgp8WvI0OocyeA8J+3ZKMG4JRXh6x1Ki6+QR6/HGPNDAStpTg/ApEUWSusFyt2Fm/8mJW2chj3l3waf0APc96corGF/YTL5eihscGgWHZ5qjkEjKg== 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 VI1PR04MB9979.eurprd04.prod.outlook.com (2603:10a6:800:1da::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Fri, 8 Nov 2024 09:13:03 +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:13:02 +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: Read correct colorimetry from caps into the stream configuration Date: Fri, 8 Nov 2024 18:12:46 +0900 Message-Id: <20241108091246.3753388-1-qi.hou@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:3:18::18) To PAXPR04MB8285.eurprd04.prod.outlook.com (2603:10a6:102:1ca::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8285:EE_|VI1PR04MB9979:EE_ X-MS-Office365-Filtering-Correlation-Id: abfbb758-e0b7-47c4-def7-08dcffd58c59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: OBP6EIyedsJqKMOaV0eeDDfad9LhsylHgGX4Fm2jfjfDWbJhrSjdjicwB2qtWnN59V4dkv22wDoHxoCI/dyr3m2VjlEIurfOvkyY1nOBmDg1eZwSvkXK9Gt0sSaltI8WXwjoNzhpvZJBdxMx2S+6R+4W8E6znuoF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ZsurUMcn5d+4c9aQNiYMvHGWAs2OEOgqeJUBc61lYZM39+x/x17+I1ajQ1Nxd6XOW9pbVcI3qwb5WlNgR9/H3FgJnRuCr1TOTRp7K9vOTJFSeFylmtaWhoRIIdC5xtiMMRk6B18gc= 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)(1800799024)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8WoX4RTY0FkRgntwRk9tWIYnPCP5MkggF9vlZU8vSk3MFCGoC0fUCVl7yyA8HC9jZWacUofJ0XPuZ6YG0/rFNx5nNduQ8yqPo2enc9N4MpP0wUX7dQDh3lpHzLc13FxEAaprqK/4p/Oum+eTLRedmBqu1TUKsdNypBgdbTUNkD2DczKp3jz5oYG8QyrUpEIMkOtnIwLFSY49pYnenmyZ5wJnVhD4aFuPyFj2cxzbRkTp2jX3zIxR19iGaPWcwyVnhbvbe0ckCnm9pb1fVhwogvJdANUTW2gZW5gQtJS/FGTu7g7BIdtNSRiQ7QrRQ0UpNtRXA3pP1fcues02v07N1FGWyEWg2whHH0ZVIMP+AJLlwLJvTpcLKn6bi3LvHF07KxTZvtSNuGKYbkCvKSMtOa18VupAu2Hmnvl9jkbZgVRzCes4MXTAjT2f+ZGzy48ciRP2EsER0WZmdA2a19oPyDZ+840daPwK4LTP2xH9lITS9GTm3oQIhHvkWynLQLsD2s9HTGhgERwzGn5d4VkrrcsI1wNgzSKddoNl255lUuN3+M6+zDfvpKffHmKQ5yO3cjA4CVitYT9BgaUcXfR0vb8C7WqWdMhog5yCJKEJPNv7F1JTHFEGVsSsFm3LjqVjXVlhICZCbJ5gizmQhIPMa2jUjKAphQzFzzFqirQFZ14MeQKdgO4SIBCJNctYYd2MiLusKkWvAKLfdOGHyBO2c0WUIYqqnVNnyipH8jgOPj1Gfw7vzJXx3gacBLHT5Lj4BvOELnY1Z1ns9TE0al7J5bavo7lLEoVLQ8YKM7e+bds/EXEdsPXtIakfPsvNAL6WmqrG3gNztdI7Y7sICir7Sg1hN77QL4Muu7JknHpEYkbaPY8tzJ4zxSnAt6bCwuDSCGGJtAZSN/yGIUDNsEbGtiDhmkqouGJTwiPlSubzMuwuiZEuiuDDpKIAzzoiK+eFjiTZG82IOCIO8pd++FT/P+hE1m8vYoonLFfG+vW9DXIH1DzAy382GYw/5cYscc6zRoQkYBFMhbWYksvMiPFKyi/T7tGXMjDEdqvvhk5qlvUZZjY+0hu18meORd8yYXP8Dgbn0+h6JOboJp17v6dFnli9qypM8f8yUMpvcGeDq21qei09UndwlCE8U2GqENhWqH9oXhnBO5nsBx8ATUTuU1wCuLoM4tnbfZb6IT36xb1MqzntR2FwGYmxO/kpjSfIP2eNP7nuUNtVXj+yClsiHRA86cqcHLy6Jlaz6qikMCBOFLxoTEqiL52mBQsp8ESWN7KSc3LA5kqS2h8XpbWk3rzWA2PePEFkq990Ex/W2AX6w5melq/kmwF2Rz1VNnsOPQU3VUyKblFcSastrB1yeJ84bMjyIywVwyTgpd3FV0BzSzv7r7GbaZDRHwN13oCaqe5G6vtXwimkAUiMyTK6b7l9IZxcSSBZ2eU52iws0QIjYeelZF8EY5g3HenZjTA82TNi0XSqepV9nV2u9Ds1LAjzsc9eKN51lj1WjuoDJFEJ71204xDXXawJKU+wmtaS3tk9xdGvIAa+euJYjjZ7WWHokB6eMZTRDlWTENduG39HpG143H1J1SFb86+AHWaD X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: abfbb758-e0b7-47c4-def7-08dcffd58c59 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:13:02.9505 (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: MBk15y4Q6AT7caAel4ZsCRgzMT8Rt6t3MqP8oQoIXo9SxkDAUtJidKJzIq6+sM5B X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9979 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" When libcamerasrc is negotiating with downstream element, it first extracts colorimetry field from downstream supported caps, then set this colorimetry to its stream configuration and propagates the colorimetry downstream. Currently libamerasrc only considers the case there is one colorimetry in colorimetry field of downstream caps. But the issue is that downstream caps may report a list of supported colorimetry, which causes libcamerasrc to set unknown colorimetry to stream configuration and negotiate fail with downstream element. In order to fix the issue, get the first string if colorimetry field holds string list to set it to stream configuration. Signed-off-by: Hou Qi --- src/gstreamer/gstlibcamera-utils.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 732987ef..2c1ebce8 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -489,9 +489,22 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg, /* Configure colorimetry */ if (gst_structure_has_field(s, "colorimetry")) { - const gchar *colorimetry_str = gst_structure_get_string(s, "colorimetry"); + const GValue *mode; + const gchar *colorimetry_str = NULL; GstVideoColorimetry colorimetry; + mode = gst_structure_get_value(s, "colorimetry"); + + if (G_VALUE_HOLDS_STRING(mode)) { + colorimetry_str = gst_structure_get_string(s, "colorimetry"); + } else if (GST_VALUE_HOLDS_LIST(mode)) { + const GValue *first_element = gst_value_list_get_value(mode, 0); + + if (G_VALUE_HOLDS_STRING(first_element)) { + colorimetry_str = g_value_get_string(first_element); + } + } + if (!gst_video_colorimetry_from_string(&colorimetry, colorimetry_str)) g_critical("Invalid colorimetry %s", colorimetry_str);