summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHou Qi <qi.hou@nxp.com>2021-03-23 16:59:28 +0800
committerHou Qi <qi.hou@nxp.com>2021-03-24 08:40:52 +0800
commite0373913648120e0725d9a325067b2fd20896267 (patch)
treedb8a437396bd07d017a978ea1b438d85973bd59f /sys
parent4c6ff9fb58cf58a7cc66cd31771a2e05339cca02 (diff)
v4l2object: Avoid colorimetry mismatch for streams with invalid colorimetry
video-info sets gst colorimetry to default value when colorimetry in caps is unparsable or invalid. Then v4l2object uses this gst colorimetry to do mapping with v4l2 colorimetry. This may cause colorimetry mismatch when check mapped gst colorimetry with that read from caps directly. To fix this, need to correct gst colorimetry as that parsed from video-info when check gst_v4l2_video_colorimetry_matches(). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/917>
Diffstat (limited to 'sys')
-rw-r--r--sys/v4l2/gstv4l2object.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index cafdfe277..b5af59bdb 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -3391,9 +3391,9 @@ get_v4l2_field_for_info (GstVideoInfo * info)
static gboolean
gst_v4l2_video_colorimetry_matches (const GstVideoColorimetry * cinfo,
- const gchar * color)
+ GstCaps * caps)
{
- GstVideoColorimetry ci;
+ GstVideoInfo info;
static const GstVideoColorimetry ci_likely_jpeg = {
GST_VIDEO_COLOR_RANGE_0_255, GST_VIDEO_COLOR_MATRIX_BT601,
GST_VIDEO_TRANSFER_UNKNOWN, GST_VIDEO_COLOR_PRIMARIES_UNKNOWN
@@ -3403,14 +3403,14 @@ gst_v4l2_video_colorimetry_matches (const GstVideoColorimetry * cinfo,
GST_VIDEO_TRANSFER_SRGB, GST_VIDEO_COLOR_PRIMARIES_BT709
};
- if (!gst_video_colorimetry_from_string (&ci, color))
+ if (!gst_video_info_from_caps (&info, caps))
return FALSE;
- if (gst_video_colorimetry_is_equal (&ci, cinfo))
+ if (gst_video_colorimetry_is_equal (&info.colorimetry, cinfo))
return TRUE;
/* Allow 1:4:0:0 (produced by jpegdec) if the device expects 1:4:7:1 */
- if (gst_video_colorimetry_is_equal (&ci, &ci_likely_jpeg)
+ if (gst_video_colorimetry_is_equal (&info.colorimetry, &ci_likely_jpeg)
&& gst_video_colorimetry_is_equal (cinfo, &ci_jpeg))
return TRUE;
@@ -3804,8 +3804,7 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
if (gst_v4l2_object_get_colorspace (v4l2object, &format, &info.colorimetry)) {
if (gst_structure_has_field (s, "colorimetry")) {
- if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry,
- gst_structure_get_string (s, "colorimetry")))
+ if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry, caps))
goto invalid_colorimetry;
}
} else {