diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2019-11-18 13:27:42 -0500 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-11-19 16:26:03 +0000 |
commit | 5fbc79c3a8ffb75e447b9e81f506da5b5bf073fe (patch) | |
tree | c1cd41372665ffdc9baa9854325ef3286cf89ea8 | |
parent | 52caa50feb3d145c1c67f68b34a77d1646b2c8d0 (diff) | |
download | gstreamer-plugins-good-5fbc79c3a8ffb75e447b9e81f506da5b5bf073fe.tar.gz |
v4l2object: Workaround bad TRY_FMT colorimetry implementation
libv4l2 reset the colorpace to 0 and does not do any request to the
driver. This yields an invalid colorspace which currently cause a
negotiation failure. This workaround by ignoring bad values during the
TRY_FMT step.
-rw-r--r-- | sys/v4l2/gstv4l2object.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index cbd789f18..8c3c95bb8 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -3251,6 +3251,7 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps, enum v4l2_ycbcr_encoding matrix = 0; enum v4l2_xfer_func transfer = 0; GstStructure *s; + gboolean disable_colorimetry = FALSE; g_return_val_if_fail (!v4l2object->skip_try_fmt_probes || gst_caps_is_writable (caps), FALSE); @@ -3583,17 +3584,24 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps, goto invalid_field; } - gst_v4l2_object_get_colorspace (&format, &info.colorimetry); - if (gst_structure_has_field (s, "colorimetry")) { - if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry, - gst_structure_get_string (s, "colorimetry"))) - goto invalid_colorimetry; + if (gst_v4l2_object_get_colorspace (&format, &info.colorimetry)) { + if (gst_structure_has_field (s, "colorimetry")) { + if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry, + gst_structure_get_string (s, "colorimetry"))) + goto invalid_colorimetry; + } + } else { + /* The driver (or libv4l2) is miss-behaving, just ignore colorimetry from + * the TRY_FMT */ + disable_colorimetry = TRUE; + if (gst_structure_has_field (s, "colorimetry")) + gst_structure_remove_field (s, "colorimetry"); } /* In case we have skipped the try_fmt probes, we'll need to set the * colorimetry and interlace-mode back into the caps. */ if (v4l2object->skip_try_fmt_probes) { - if (!gst_structure_has_field (s, "colorimetry")) { + if (!disable_colorimetry && !gst_structure_has_field (s, "colorimetry")) { gchar *str = gst_video_colorimetry_to_string (&info.colorimetry); gst_structure_set (s, "colorimetry", G_TYPE_STRING, str, NULL); g_free (str); |