Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
xvimagesink: Handle cropping when copying frames.
Cropping was not handled properly when frames have to be copied to
xvimage's buffer pool, first because the crop meta were dropped, and
second because the allocated frame size in xvimage's buffer pool were
smaller than the incoming frame.

This patch updates xvimagesink's video info when propose_allocation()
is called, and copies the GstVideoCropMeta from source frame to
destination one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1088>
  • Loading branch information
ceyusa committed Apr 28, 2021
1 parent c38bede commit 87193af
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sys/xvimage/xvimagesink.c
Expand Up @@ -954,6 +954,7 @@ gst_xv_image_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
} else {
GstVideoFrame src, dest;
GstBufferPoolAcquireParams params = { 0, };
GstVideoCropMeta *crop_meta;

/* Else we have to copy the data into our private image, */
/* if we have one... */
Expand Down Expand Up @@ -997,6 +998,15 @@ gst_xv_image_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)

gst_video_frame_unmap (&dest);
gst_video_frame_unmap (&src);

if ((crop_meta = gst_buffer_get_video_crop_meta (buf))) {
GstVideoCropMeta *dmeta = gst_buffer_add_video_crop_meta (to_put);

dmeta->x = crop_meta->x;
dmeta->y = crop_meta->y;
dmeta->width = crop_meta->width;
dmeta->height = crop_meta->height;
}
}

if (!gst_xv_image_sink_xvimage_put (xvimagesink, to_put))
Expand Down Expand Up @@ -1101,6 +1111,10 @@ gst_xv_image_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
goto no_pool;
}

/* update info since allocation frame's wxh might differ from the
* negotiation ones */
xvimagesink->info = info;

/* we need at least 2 buffer because we hold on to the last one */
gst_query_add_allocation_pool (query, pool, size, 2, 0);
if (pool)
Expand Down

0 comments on commit 87193af

Please sign in to comment.