Commit a7286563 authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2: Add initial support for alignment and cropping

parent 70e7868f
......@@ -141,11 +141,13 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
GstV4l2Meta *meta;
GstV4l2Object *obj;
GstVideoInfo *info;
GstVideoAlignment *align;
guint index;
gint i;
obj = pool->obj;
info = &obj->info;
align = &obj->align;
switch (obj->mode) {
case GST_V4L2_IO_RW:
......@@ -339,6 +341,15 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
GST_VIDEO_INFO_FORMAT (info), width, height, n_gst_planes,
offset, stride);
}
if (pool->add_cropmeta) {
GstVideoCropMeta *crop;
crop = gst_buffer_add_video_crop_meta (newbuf);
crop->x = align->padding_left;
crop->y = align->padding_top;
crop->width = info->width;
crop->width = info->height;
}
break;
}
case GST_V4L2_IO_USERPTR:
......@@ -1666,3 +1677,9 @@ start_failed:
return FALSE;
}
}
void
gst_v4l2_buffer_pool_add_crop_meta (GstV4l2BufferPool * bpool, gboolean add)
{
bpool->add_cropmeta = add;
}
......@@ -54,6 +54,7 @@ struct _GstV4l2BufferPool
GstAllocationParams params;
guint size;
gboolean add_videometa;
gboolean add_cropmeta;
gboolean can_alloc; /* if extra buffers can be allocated */
guint num_buffers; /* number of buffers we use */
......@@ -110,6 +111,8 @@ GstFlowReturn gst_v4l2_buffer_pool_process (GstV4l2BufferPool * bpool, Gst
gboolean gst_v4l2_buffer_pool_flush (GstV4l2BufferPool * pool);
void gst_v4l2_buffer_pool_add_crop_meta (GstV4l2BufferPool * bpool, gboolean add);
G_END_DECLS
#endif /*__GST_V4L2_BUFFER_POOL_H__ */
This diff is collapsed.
......@@ -97,6 +97,10 @@ struct _GstV4l2Object {
/* the current format */
struct v4l2_fmtdesc *fmtdesc;
GstVideoInfo info;
GstVideoAlignment align;
gboolean need_video_meta;
gboolean need_crop_meta;
/* only used if the device supports MPLANE
* nb planes is meaning of v4l2 planes
......@@ -254,8 +258,7 @@ GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object,
GstCaps * filter);
gboolean gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object,
GstVideoInfo * info,
GstVideoAlignment * align);
GstVideoInfo * info);
gboolean gst_v4l2_object_decide_allocation (GstV4l2Object * v4l2object,
GstQuery * query);
......
......@@ -65,8 +65,6 @@ struct _GstV4l2VideoDec
gboolean active;
gboolean processing;
GstFlowReturn output_flow;
GstVideoAlignment align;
};
struct _GstV4l2VideoDecClass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment