From 4d37b7ae50ccb0cb10ec2c311c7640ff28babcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qian=20Hu=20=28=E8=83=A1=E9=AA=9E=29?= Date: Mon, 22 Jul 2024 19:28:13 +0800 Subject: [PATCH] v4l2object: handle unsupported hlg colorimetry gracefully This patch addresses the issue where GStreamer would throw an error when attempting to use bt2100-hlg colorimetry with V4L2, which is not supported by the current V4L2 kernel. When bt2100-hlg colorimetry is set from caps, the check for transfer (GST_VIDEO_TRANSFER_ARIB_STD_B67) is bypassed. The main improvement is to avoid checking the transfer value in gst_v4l2_video_colorimetry_matches when it is GST_VIDEO_TRANSFER_ARIB_STD_B67. This is because the transfer value in the cinfo parameter comes from gst_v4l2_object_get_colorspace, which converts the transfer to another value, causing a mismatch. Since the kernel does not support GST_VIDEO_TRANSFER_ARIB_STD_B67, gst_v4l2_object_get_colorspace cannot map it correctly from V4L2 to GStreamer. Therefore, we ignore this check to prevent errors. changes: - Added a condition in gst_v4l2_video_colorimetry_matches to bypass the transfer check when the transfer is GST_VIDEO_TRANSFER_ARIB_STD_B67. - Ensured that the pipeline does not throw errors due to unsupported bt2100-hlg colorimetry in V4L2. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2object.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c index 9e60709fd5..0134de4756 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c @@ -3731,6 +3731,18 @@ gst_v4l2_video_colorimetry_matches (const GstVideoColorimetry * cinfo, && gst_video_colorimetry_is_equal (cinfo, &ci_jpeg)) return TRUE; + /* bypass check the below GST_VIDEO_TRANSFER_ARIB_STD_B67 type, + * because kernel do not support it. GST_VIDEO_TRANSFER_ARIB_STD_B67 is cast + * to GST_VIDEO_TRANSFER_BT2020_12 type in gst_v4l2_object_get_colorspace */ + if (info.colorimetry.transfer == GST_VIDEO_TRANSFER_ARIB_STD_B67) { + info.colorimetry.transfer = cinfo->transfer; + GST_WARNING + ("v4l2 framework do not support GST_VIDEO_TRANSFER_ARIB_STD_B67"); + + if (gst_video_colorimetry_is_equal (&info.colorimetry, cinfo)) + return TRUE; + } + /* bypass check the below transfer types, because those types are cast to * V4L2_XFER_FUNC_NONE type when try format or set format and V4L2_XFER_FUNC_NONE * type is cast to GST_VIDEO_TRANSFER_GAMMA10 type in gst_v4l2_object_get_colorspace */