mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
overlay: detect render-rect changes.
Don't re-upload VA subpicture if only the render rectangle changed. Rather deassociate the subpicture and re-associate it with the new render rectangle.
This commit is contained in:
parent
e876d9a581
commit
e6390d6e5f
1 changed files with 28 additions and 0 deletions
|
@ -269,12 +269,40 @@ overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
|
|||
return GST_BUFFER_DATA(overlay->rect_buffer) != GST_BUFFER_DATA(buffer);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
overlay_rectangle_update_render_rect(GstVaapiOverlayRectangle *overlay,
|
||||
GstVideoOverlayRectangle *rect)
|
||||
{
|
||||
GstVaapiRectangle * const render_rect = &overlay->render_rect;
|
||||
guint width, height;
|
||||
gint x, y;
|
||||
|
||||
gst_video_overlay_rectangle_get_render_rectangle(rect,
|
||||
&x, &y, &width, &height);
|
||||
|
||||
if (x == render_rect->x &&
|
||||
y == render_rect->y &&
|
||||
width == render_rect->width &&
|
||||
height == render_rect->height)
|
||||
return TRUE;
|
||||
|
||||
overlay_rectangle_deassociate(overlay);
|
||||
|
||||
render_rect->x = x;
|
||||
render_rect->y = y;
|
||||
render_rect->width = width;
|
||||
render_rect->height = height;
|
||||
return overlay_rectangle_associate(overlay);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
overlay_rectangle_update(GstVaapiOverlayRectangle *overlay,
|
||||
GstVideoOverlayRectangle *rect)
|
||||
{
|
||||
if (overlay_rectangle_changed_pixels(overlay, rect))
|
||||
return FALSE;
|
||||
if (!overlay_rectangle_update_render_rect(overlay, rect))
|
||||
return FALSE;
|
||||
gst_video_overlay_rectangle_replace(&overlay->rect, rect);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue