v4l2: Update fmt if padded height is greater than fmt height
authorTrung Do <trung1.dothanh@toshiba.co.jp>
Mon, 1 Nov 2021 03:08:32 +0000 (10:08 +0700)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 16 Nov 2021 15:46:29 +0000 (10:46 -0500)
If padded height is greater, buffer bytesused could be larger than plane length,
and cause VIDIOC_QBUF failure.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1355>

subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c

index 9851ffc..43121f6 100644 (file)
@@ -4597,6 +4597,18 @@ gst_v4l2_object_match_buffer_layout (GstV4l2Object * obj, guint n_planes,
           offset[p], obj->info.offset[p], p);
       need_fmt_update = TRUE;
     }
+
+    if (padded_height) {
+      guint fmt_height;
+
+      if (V4L2_TYPE_IS_MULTIPLANAR (obj->type))
+        fmt_height = obj->format.fmt.pix_mp.height;
+      else
+        fmt_height = obj->format.fmt.pix.height;
+
+      if (padded_height > fmt_height)
+        need_fmt_update = TRUE;
+    }
   }
 
   if (need_fmt_update) {