v4l2object: Read driver selected interlace mode
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 19 Oct 2018 02:23:31 +0000 (22:23 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 8 Nov 2018 00:29:51 +0000 (19:29 -0500)
If there was no interlace-mode field in the caps. Read back the value
selected by the driver. This way, if the driver does not support
progressive, then it will automatically negotiate the returned mode
unless this mode is not supported by GStreamer.

This method was already used for colorimetry. Just like colorimetry, the
interlace mode is not longer probed by v4l2src dues to performance
issues.

Fixes #511

sys/v4l2/gstv4l2object.c

index 8f8c239..81e0ad2 100644 (file)
@@ -3583,13 +3583,18 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
   if (is_mplane && format.fmt.pix_mp.num_planes != n_v4l_planes)
     goto invalid_planes;
 
-  if ((is_mplane && format.fmt.pix_mp.field != field)
-      || format.fmt.pix.field != field)
+  /* used to check colorimetry and interlace mode fields presence */
+  s = gst_caps_get_structure (caps, 0);
+
+  if (!gst_v4l2_object_get_interlace_mode (format.fmt.pix.field,
+          &info.interlace_mode))
     goto invalid_field;
+  if (gst_structure_has_field (s, "interlace-mode")) {
+    if (format.fmt.pix.field != field)
+      goto invalid_field;
+  }
 
   gst_v4l2_object_get_colorspace (&format, &info.colorimetry);
-
-  s = gst_caps_get_structure (caps, 0);
   if (gst_structure_has_field (s, "colorimetry")) {
     if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry,
             gst_structure_get_string (s, "colorimetry")))