mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
v4l2object: Move the extrapolation of stride at the right place
Now that we have a stride array, we should extrapolate only when eeded (non multi-planar buffer). https://bugzilla.gnome.org/show_bug.cgi?id=720568
This commit is contained in:
parent
5f1e47da24
commit
5faa20b044
2 changed files with 29 additions and 33 deletions
|
@ -317,25 +317,10 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
|
||||||
obj->bytesperline[i]);
|
obj->bytesperline[i]);
|
||||||
|
|
||||||
offset[i] = offs;
|
offset[i] = offs;
|
||||||
|
stride[i] = obj->bytesperline[i];
|
||||||
|
|
||||||
switch (info->finfo->format) {
|
/* when using multiplanar mode and if there is more then one v4l
|
||||||
case GST_VIDEO_FORMAT_NV12:
|
* plane for each gst plane
|
||||||
case GST_VIDEO_FORMAT_NV21:
|
|
||||||
case GST_VIDEO_FORMAT_NV16:
|
|
||||||
case GST_VIDEO_FORMAT_NV24:
|
|
||||||
stride[i] =
|
|
||||||
(i == 0 ? 1 : 2) * GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo,
|
|
||||||
i, obj->bytesperline[i]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
stride[i] =
|
|
||||||
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, i,
|
|
||||||
obj->bytesperline[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* when using multiplanar mode and if there is one v4l plane for
|
|
||||||
* each gst plane
|
|
||||||
*/
|
*/
|
||||||
if (V4L2_TYPE_IS_MULTIPLANAR (obj->type) && meta->n_planes > 1)
|
if (V4L2_TYPE_IS_MULTIPLANAR (obj->type) && meta->n_planes > 1)
|
||||||
/* non_contiguous case here so we have to make sure that gst goes to the
|
/* non_contiguous case here so we have to make sure that gst goes to the
|
||||||
|
|
|
@ -2504,7 +2504,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
guint32 pixelformat;
|
guint32 pixelformat;
|
||||||
struct v4l2_fmtdesc *fmtdesc;
|
struct v4l2_fmtdesc *fmtdesc;
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
gint width, height, fps_n, fps_d, stride;
|
gint width, height, fps_n, fps_d;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
GST_V4L2_CHECK_OPEN (v4l2object);
|
GST_V4L2_CHECK_OPEN (v4l2object);
|
||||||
|
@ -2518,7 +2518,6 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
height = GST_VIDEO_INFO_HEIGHT (&info);
|
height = GST_VIDEO_INFO_HEIGHT (&info);
|
||||||
fps_n = GST_VIDEO_INFO_FPS_N (&info);
|
fps_n = GST_VIDEO_INFO_FPS_N (&info);
|
||||||
fps_d = GST_VIDEO_INFO_FPS_D (&info);
|
fps_d = GST_VIDEO_INFO_FPS_D (&info);
|
||||||
stride = GST_VIDEO_INFO_PLANE_STRIDE (&info, 0);
|
|
||||||
|
|
||||||
/* get bytesperline for each plane */
|
/* get bytesperline for each plane */
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++)
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++)
|
||||||
|
@ -2537,7 +2536,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "Desired format %dx%d, format "
|
GST_DEBUG_OBJECT (v4l2object->element, "Desired format %dx%d, format "
|
||||||
"%" GST_FOURCC_FORMAT " stride: %d", width, height,
|
"%" GST_FOURCC_FORMAT " stride: %d", width, height,
|
||||||
GST_FOURCC_ARGS (pixelformat), stride);
|
GST_FOURCC_ARGS (pixelformat), v4l2object->bytesperline[0]);
|
||||||
|
|
||||||
/* MPEG-TS source cameras don't get their format set for some reason.
|
/* MPEG-TS source cameras don't get their format set for some reason.
|
||||||
* It looks wrong and we weren't able to track down the reason for that code
|
* It looks wrong and we weren't able to track down the reason for that code
|
||||||
|
@ -2628,10 +2627,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
v4l2object->n_v4l2_planes = format.fmt.pix_mp.num_planes;
|
v4l2object->n_v4l2_planes = format.fmt.pix_mp.num_planes;
|
||||||
v4l2object->sizeimage = 0;
|
v4l2object->sizeimage = 0;
|
||||||
for (i = 0; i < format.fmt.pix_mp.num_planes; i++) {
|
for (i = 0; i < format.fmt.pix_mp.num_planes; i++) {
|
||||||
/* For compatibility reasons with the non-v4l2-multiplanar mode
|
v4l2object->bytesperline[i] = format.fmt.pix_mp.plane_fmt[i].bytesperline;
|
||||||
* we have to use the bytesperline of<F3> the first v4l plane
|
|
||||||
* See plane_fmt[0] instead of plane_fmt[i] in next line */
|
|
||||||
v4l2object->bytesperline[i] = format.fmt.pix_mp.plane_fmt[0].bytesperline;
|
|
||||||
v4l2object->sizeimage += format.fmt.pix_mp.plane_fmt[i].sizeimage;
|
v4l2object->sizeimage += format.fmt.pix_mp.plane_fmt[i].sizeimage;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2650,7 +2646,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
/* something different, set the format */
|
/* something different, set the format */
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "Setting format to %dx%d, format "
|
GST_DEBUG_OBJECT (v4l2object->element, "Setting format to %dx%d, format "
|
||||||
"%" GST_FOURCC_FORMAT " bytesperline %d", width, height,
|
"%" GST_FOURCC_FORMAT " bytesperline %d", width, height,
|
||||||
GST_FOURCC_ARGS (pixelformat), stride);
|
GST_FOURCC_ARGS (pixelformat), v4l2object->bytesperline[0]);
|
||||||
|
|
||||||
format.type = v4l2object->type;
|
format.type = v4l2object->type;
|
||||||
format.fmt.pix.width = width;
|
format.fmt.pix.width = width;
|
||||||
|
@ -2658,7 +2654,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
format.fmt.pix.pixelformat = pixelformat;
|
format.fmt.pix.pixelformat = pixelformat;
|
||||||
format.fmt.pix.field = field;
|
format.fmt.pix.field = field;
|
||||||
/* try to ask our prefered stride */
|
/* try to ask our prefered stride */
|
||||||
format.fmt.pix.bytesperline = stride;
|
format.fmt.pix.bytesperline = v4l2object->bytesperline[0];
|
||||||
|
|
||||||
if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0)
|
if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0)
|
||||||
goto set_fmt_failed;
|
goto set_fmt_failed;
|
||||||
|
@ -2684,12 +2680,27 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
v4l2object->n_v4l2_planes = 1;
|
v4l2object->n_v4l2_planes = 1;
|
||||||
|
|
||||||
/* figure out the frame layout */
|
/* figure out the frame layout */
|
||||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
for (i = 0; i < info.finfo->n_planes; i++) {
|
||||||
/* In non-multiplanar mode, there is only one field for bytesperline
|
const GstVideoFormatInfo *finfo = info.finfo;
|
||||||
* Just set it everywhere in order to the code factorized
|
guint stride = format.fmt.pix.bytesperline;
|
||||||
* with multiplanar case in gstv4l2bufferpool.c::alloc_buffer function
|
|
||||||
*/
|
switch (info.finfo->format) {
|
||||||
v4l2object->bytesperline[i] = format.fmt.pix.bytesperline;
|
case GST_VIDEO_FORMAT_NV12:
|
||||||
|
case GST_VIDEO_FORMAT_NV21:
|
||||||
|
case GST_VIDEO_FORMAT_NV16:
|
||||||
|
case GST_VIDEO_FORMAT_NV24:
|
||||||
|
v4l2object->bytesperline[i] = (i == 0 ? 1 : 2) *
|
||||||
|
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, i, stride);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
v4l2object->bytesperline[i] =
|
||||||
|
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, i, stride);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (v4l2object->element,
|
||||||
|
"Extrapolated stride for plane %d from %d to %d", i, stride,
|
||||||
|
v4l2object->bytesperline[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
v4l2object->sizeimage = format.fmt.pix.sizeimage;
|
v4l2object->sizeimage = format.fmt.pix.sizeimage;
|
||||||
|
|
Loading…
Reference in a new issue