diff --git a/src/gst/gstpipewirepool.c b/src/gst/gstpipewirepool.c index f00612fc8..6c6e2dcab 100644 --- a/src/gst/gstpipewirepool.c +++ b/src/gst/gstpipewirepool.c @@ -102,6 +102,18 @@ void gst_pipewire_pool_wrap_buffer (GstPipeWirePool *pool, struct pw_buffer *b) GST_VIDEO_INFO_N_PLANES (&pool->video_info), pool->video_info.offset, pool->video_info.stride); + gsize plane_sizes[GST_VIDEO_MAX_PLANES]; + + if (!gst_video_meta_get_plane_size (meta, plane_sizes)) { + GST_ERROR_OBJECT (pool, "could not compute plane sizes"); + } else { + /* Set memory sizes to expected plane sizes, so we know the valid size, + * and the offsets in the meta make sense */ + for (i = 0; i < gst_buffer_n_memory (buf); i++) { + GstMemory *mem = gst_buffer_peek_memory (buf, i); + gst_memory_resize (mem, 0, plane_sizes[i]); + } + } /* * We need to set the video meta as pooled, else gst_buffer_pool_release_buffer diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c index c0d7df8a6..4457e2eac 100644 --- a/src/gst/gstpipewiresink.c +++ b/src/gst/gstpipewiresink.c @@ -654,17 +654,13 @@ do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer) if (meta) { if (meta->n_planes == b->n_datas) { uint32_t n_planes = GST_VIDEO_INFO_N_PLANES (&data->pool->video_info); - gboolean is_planar = n_planes > 1; gsize video_size = 0; for (i = 0; i < n_planes; i++) { struct spa_data *d = &b->datas[i]; d->chunk->stride = meta->stride[i]; - if (is_planar) - d->chunk->offset = meta->offset[i]; - else - d->chunk->offset += meta->offset[i] - video_size; + d->chunk->offset = meta->offset[i] - video_size; video_size += d->chunk->size; } @@ -969,8 +965,6 @@ gst_pipewire_sink_render (GstBaseSink * bsink, GstBuffer * buffer) GST_ERROR_OBJECT(pwsink, "Failed to copy the frame"); return GST_FLOW_ERROR; } - - gst_buffer_copy_into(b, buffer, GST_BUFFER_COPY_METADATA, 0, -1); } else { gst_buffer_map (b, &info, GST_MAP_WRITE); gsize extract_size = (buf_size <= info.maxsize) ? buf_size: info.maxsize;