mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
gst: correct buffer & meta offset calculation
The offset in GstVideoMeta point to location of merge-mapped buffer memories (see "gst_buffer_find_memory()") instead of raw memory location for each plane, make adjustment to comply this rule.
Also some cleanups.
Fixes 023577e391
This commit is contained in:
parent
4f9f32084c
commit
4b60569c4a
2 changed files with 11 additions and 5 deletions
|
|
@ -508,13 +508,16 @@ do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer)
|
|||
GstVideoMeta *meta = gst_buffer_get_video_meta (buffer);
|
||||
if (meta) {
|
||||
if (meta->n_planes == b->n_datas) {
|
||||
gsize video_size = 0;
|
||||
for (i = 0; i < meta->n_planes; i++) {
|
||||
struct spa_data *d = &b->datas[i];
|
||||
d->chunk->offset = meta->offset[i];
|
||||
d->chunk->offset += meta->offset[i] - video_size;
|
||||
d->chunk->stride = meta->stride[i];
|
||||
|
||||
video_size += d->chunk->size;
|
||||
}
|
||||
} else {
|
||||
GST_ERROR ("plane num not matching, meta:%d buffer:%d", meta->n_planes, b->n_datas);
|
||||
GST_ERROR ("plane num not matching, meta:%u buffer:%u", meta->n_planes, b->n_datas);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -616,6 +616,7 @@ static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
|
|||
}
|
||||
|
||||
if (pwsrc->is_video) {
|
||||
gsize video_size = 0;
|
||||
GstVideoInfo *info = &pwsrc->video_info;
|
||||
GstVideoMeta *meta = gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
|
||||
GST_VIDEO_INFO_FORMAT (info),
|
||||
|
|
@ -625,11 +626,13 @@ static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
|
|||
info->offset,
|
||||
info->stride);
|
||||
|
||||
meta->n_planes = b->buffer->n_datas;
|
||||
for (i = 0; i < b->buffer->n_datas; i++) {
|
||||
meta->n_planes = MIN(meta->n_planes, b->buffer->n_datas);
|
||||
for (i = 0; i < meta->n_planes; i++) {
|
||||
struct spa_data *d = &b->buffer->datas[i];
|
||||
meta->offset[i] = d->chunk->offset;
|
||||
meta->offset[i] = video_size;
|
||||
meta->stride[i] = d->chunk->stride;
|
||||
|
||||
video_size += d->chunk->size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue