Offset are relative to the buffer and there is no guarantee substracting
them will give us the plane size. So we let bufferpool make the math as
it is more aware of video info than allocator and pass a size array to
allocator import function.
Pointed out by Nicolas Dufresne <nicolas.dufresne@collabora.com>
https://bugzilla.gnome.org/show_bug.cgi?id=738013
gboolean
gst_v4l2_allocator_import_userptr (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group, gsize img_size, int n_planes,
gboolean
gst_v4l2_allocator_import_userptr (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group, gsize img_size, int n_planes,
- gpointer * data, gsize * offset)
+ gpointer * data, gsize * size)
{
GstV4l2Memory *mem;
gint i;
{
GstV4l2Memory *mem;
gint i;
goto n_mem_missmatch;
for (i = 0; i < group->n_mem; i++) {
goto n_mem_missmatch;
for (i = 0; i < group->n_mem; i++) {
if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
struct v4l2_pix_format_mplane *pix = &allocator->format.fmt.pix_mp;
if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
struct v4l2_pix_format_mplane *pix = &allocator->format.fmt.pix_mp;
maxsize = allocator->format.fmt.pix.sizeimage;
}
maxsize = allocator->format.fmt.pix.sizeimage;
}
- if ((i + 1) == n_planes) {
- size = img_size - offset[i];
- } else {
- size = offset[i + 1] - offset[i];
- }
-
- g_assert (size <= img_size);
+ g_assert (size[i] <= img_size);
GST_LOG_OBJECT (allocator, "imported USERPTR %p plane %d size %"
GST_LOG_OBJECT (allocator, "imported USERPTR %p plane %d size %"
- G_GSIZE_FORMAT, data[i], i, size);
+ G_GSIZE_FORMAT, data[i], i, size[i]);
mem = (GstV4l2Memory *) group->mem[i];
mem->mem.maxsize = maxsize;
mem = (GstV4l2Memory *) group->mem[i];
mem->mem.maxsize = maxsize;
+ mem->mem.size = size[i];
mem->data = data[i];
group->planes[i].length = maxsize;
mem->data = data[i];
group->planes[i].length = maxsize;
- group->planes[i].bytesused = size;
+ group->planes[i].bytesused = size[i];
group->planes[i].m.userptr = (unsigned long) data[i];
group->planes[i].data_offset = 0;
}
group->planes[i].m.userptr = (unsigned long) data[i];
group->planes[i].data_offset = 0;
}
gboolean gst_v4l2_allocator_import_userptr (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup *group,
gsize img_size, int n_planes,
gboolean gst_v4l2_allocator_import_userptr (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup *group,
gsize img_size, int n_planes,
- gpointer * data, gsize * offset);
+ gpointer * data, gsize * size);
void gst_v4l2_allocator_flush (GstV4l2Allocator * allocator);
void gst_v4l2_allocator_flush (GstV4l2Allocator * allocator);
if (finfo && (finfo->format != GST_VIDEO_FORMAT_UNKNOWN &&
finfo->format != GST_VIDEO_FORMAT_ENCODED)) {
if (finfo && (finfo->format != GST_VIDEO_FORMAT_UNKNOWN &&
finfo->format != GST_VIDEO_FORMAT_ENCODED)) {
+ gsize size[GST_VIDEO_MAX_PLANES] = { 0, };
+ gint i;
+
data->is_frame = TRUE;
if (!gst_video_frame_map (&data->frame, &pool->caps_info, src, flags))
goto invalid_buffer;
data->is_frame = TRUE;
if (!gst_video_frame_map (&data->frame, &pool->caps_info, src, flags))
goto invalid_buffer;
+ for (i = 0; i < GST_VIDEO_FORMAT_INFO_N_PLANES (finfo); i++) {
+ if (GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) {
+ gint tinfo = GST_VIDEO_FRAME_PLANE_STRIDE (&data->frame, i);
+ gint pstride;
+ guint pheight;
+
+ pstride = GST_VIDEO_TILE_X_TILES (tinfo) <<
+ GST_VIDEO_FORMAT_INFO_TILE_WS (finfo);
+
+ pheight = GST_VIDEO_TILE_Y_TILES (tinfo) <<
+ GST_VIDEO_FORMAT_INFO_TILE_HS (finfo);
+
+ size[i] = pstride * pheight;
+ } else {
+ size[i] = GST_VIDEO_FRAME_PLANE_STRIDE (&data->frame, i) *
+ GST_VIDEO_FRAME_COMP_HEIGHT (&data->frame, i);
+ }
+ }
+
if (!gst_v4l2_allocator_import_userptr (pool->vallocator, group,
if (!gst_v4l2_allocator_import_userptr (pool->vallocator, group,
- data->frame.info.size, finfo->n_planes, data->frame.data,
- data->frame.info.offset))
+ data->frame.info.size, finfo->n_planes, data->frame.data, size))
goto import_failed;
} else {
goto import_failed;
} else {
- gsize offset[1] = { 0 };
goto invalid_buffer;
ptr[0] = data->map.data;
goto invalid_buffer;
ptr[0] = data->map.data;
+ size[0] = data->map.size;
if (!gst_v4l2_allocator_import_userptr (pool->vallocator, group,
if (!gst_v4l2_allocator_import_userptr (pool->vallocator, group,
- data->map.size, 1, ptr, offset))
+ data->map.size, 1, ptr, size))