Commit e6390d6e authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

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.
parent e876d9a5
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment