mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
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>
This commit is contained in:
parent
4c6ff9fb58
commit
e037391364
1 changed files with 6 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue