v4l2object: Use active resolution during fallback colorspace probe
authorHou Qi <qi.hou@nxp.com>
Fri, 11 Dec 2020 03:24:14 +0000 (11:24 +0800)
committerHou Qi <qi.hou@nxp.com>
Mon, 14 Dec 2020 01:15:18 +0000 (09:15 +0800)
For legacy drivers that don't implement ENUM_FRAMESIZE, use active
resolution to probe colorspace. This can improve the accuracy of the
result when the colorspace depends on the resolution. This fixes a
wrong colorspace issue on board with vendor bsp at resolution 2560x1440.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/830>

sys/v4l2/gstv4l2object.c

index c6d1f5f..e46eb72 100644 (file)
@@ -2950,9 +2950,19 @@ default_frame_sizes:
         pixelformat);
 
     if (!v4l2object->skip_try_fmt_probes) {
+      gint probed_w, probed_h;
+      if (v4l2object->info.width >= min_w && v4l2object->info.width <= max_w &&
+          v4l2object->info.height >= min_h
+          && v4l2object->info.height <= max_h) {
+        probed_w = v4l2object->info.width;
+        probed_h = v4l2object->info.height;
+      } else {
+        probed_w = max_w;
+        probed_h = max_h;
+      }
       /* We could consider to check colorspace for min too, in case it depends on
        * the size. But in this case, min and max could not be enough */
-      gst_v4l2_object_add_colorspace (v4l2object, tmp, max_w, max_h,
+      gst_v4l2_object_add_colorspace (v4l2object, tmp, probed_w, probed_h,
           pixelformat);
     }