summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-01-17 11:10:37 +0100
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2018-01-17 13:32:58 -0500
commitf7e280bf0d90b0ee2732ee5918115762889a3e88 (patch)
treec82cef3fae7f36273e131d4958cdaef6670ba19c
parent3bbfd150476032db39083a7c01df8326d6283890 (diff)
v4l2: fix division by 0 for complex video formats
So complex video formats have 0 as pstride. Don't try to divide the stride in such cases. https://bugzilla.gnome.org/show_bug.cgi?id=792596
-rw-r--r--sys/v4l2/gstv4l2object.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index 995c719b8..a5e67076f 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -3022,7 +3022,7 @@ gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
{
const GstVideoFormatInfo *finfo = info->finfo;
gboolean standard_stride = TRUE;
- gint stride, padded_width, padded_height, i;
+ gint stride, pstride, padded_width, padded_height, i;
if (GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_FORMAT_ENCODED) {
v4l2object->n_v4l2_planes = 1;
@@ -3036,7 +3036,16 @@ gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
else
stride = format->fmt.pix.bytesperline;
- padded_width = stride / GST_VIDEO_FORMAT_INFO_PSTRIDE (finfo, 0);
+ pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (finfo, 0);
+ if (pstride) {
+ padded_width = stride / pstride;
+ } else {
+ /* pstride can be 0 for complex formats */
+ GST_WARNING_OBJECT (v4l2object->element,
+ "format %s has a pstride of 0, cannot compute padded with",
+ gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (info)));
+ padded_width = stride;
+ }
if (padded_width < format->fmt.pix.width)
GST_WARNING_OBJECT (v4l2object->dbg_obj,