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:
Gwenole Beauchesne 2013-01-11 11:53:05 +01:00
parent e876d9a581
commit e6390d6e5f

View file

@ -269,12 +269,40 @@ overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
return GST_BUFFER_DATA(overlay->rect_buffer) != GST_BUFFER_DATA(buffer); 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 static gboolean
overlay_rectangle_update(GstVaapiOverlayRectangle *overlay, overlay_rectangle_update(GstVaapiOverlayRectangle *overlay,
GstVideoOverlayRectangle *rect) GstVideoOverlayRectangle *rect)
{ {
if (overlay_rectangle_changed_pixels(overlay, rect)) if (overlay_rectangle_changed_pixels(overlay, rect))
return FALSE; return FALSE;
if (!overlay_rectangle_update_render_rect(overlay, rect))
return FALSE;
gst_video_overlay_rectangle_replace(&overlay->rect, rect); gst_video_overlay_rectangle_replace(&overlay->rect, rect);
return TRUE; return TRUE;
} }