mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
v4l2object: Fix support for planar format in 1 v4l2 mplane
So far we where only setting saving the first plane stride in the meta. This was leading to wrong values in GstVideoMeta.
This commit is contained in:
parent
a6a8c2b5eb
commit
49065b1693
1 changed files with 39 additions and 24 deletions
|
@ -2240,30 +2240,15 @@ no_supported_capture_method:
|
|||
}
|
||||
|
||||
static void
|
||||
gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
|
||||
struct v4l2_fmtdesc *fmtdesc, struct v4l2_format *format,
|
||||
GstVideoInfo * info, GstVideoAlignment * align)
|
||||
gst_v4l2_object_extrapolate_stride (GstV4l2Object * v4l2object,
|
||||
struct v4l2_format *format, const GstVideoFormatInfo * finfo, guint stride)
|
||||
{
|
||||
const GstVideoFormatInfo *finfo = info->finfo;
|
||||
gint i;
|
||||
|
||||
if (V4L2_TYPE_IS_MULTIPLANAR (v4l2object->type)) {
|
||||
/* figure out the frame layout */
|
||||
v4l2object->n_v4l2_planes = MAX (1, format->fmt.pix_mp.num_planes);
|
||||
v4l2object->sizeimage = 0;
|
||||
for (i = 0; i < format->fmt.pix_mp.num_planes; i++) {
|
||||
v4l2object->bytesperline[i] =
|
||||
format->fmt.pix_mp.plane_fmt[i].bytesperline;
|
||||
v4l2object->sizeimage += format->fmt.pix_mp.plane_fmt[i].sizeimage;
|
||||
}
|
||||
} else {
|
||||
/* only one plane in non-MPLANE mode */
|
||||
v4l2object->n_v4l2_planes = 1;
|
||||
g_return_if_fail (v4l2object->n_v4l2_planes == 1);
|
||||
|
||||
/* figure out the frame layout */
|
||||
for (i = 0; i < finfo->n_planes; i++) {
|
||||
guint stride = format->fmt.pix.bytesperline;
|
||||
|
||||
switch (finfo->format) {
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
case GST_VIDEO_FORMAT_NV21:
|
||||
|
@ -2282,8 +2267,38 @@ gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
|
|||
"Extrapolated stride for plane %d from %d to %d", i, stride,
|
||||
v4l2object->bytesperline[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
|
||||
struct v4l2_fmtdesc *fmtdesc, struct v4l2_format *format,
|
||||
GstVideoInfo * info, GstVideoAlignment * align)
|
||||
{
|
||||
const GstVideoFormatInfo *finfo = info->finfo;
|
||||
guint stride;
|
||||
gint i;
|
||||
|
||||
if (V4L2_TYPE_IS_MULTIPLANAR (v4l2object->type)) {
|
||||
/* figure out the frame layout */
|
||||
v4l2object->n_v4l2_planes = MAX (1, format->fmt.pix_mp.num_planes);
|
||||
v4l2object->sizeimage = 0;
|
||||
for (i = 0; i < format->fmt.pix_mp.num_planes; i++) {
|
||||
v4l2object->bytesperline[i] =
|
||||
format->fmt.pix_mp.plane_fmt[i].bytesperline;
|
||||
v4l2object->sizeimage += format->fmt.pix_mp.plane_fmt[i].sizeimage;
|
||||
}
|
||||
|
||||
/* Extrapolate stride if planar format are being set in 1 v4l2 plane */
|
||||
if (v4l2object->n_v4l2_planes < finfo->n_planes) {
|
||||
stride = format->fmt.pix_mp.plane_fmt[0].bytesperline;
|
||||
gst_v4l2_object_extrapolate_stride (v4l2object, format, finfo, stride);
|
||||
}
|
||||
} else {
|
||||
/* only one plane in non-MPLANE mode */
|
||||
v4l2object->n_v4l2_planes = 1;
|
||||
v4l2object->sizeimage = format->fmt.pix.sizeimage;
|
||||
stride = format->fmt.pix.bytesperline;
|
||||
gst_v4l2_object_extrapolate_stride (v4l2object, format, finfo, stride);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (v4l2object->element, "Got sizeimage %u",
|
||||
|
|
Loading…
Reference in a new issue