decoder: retain proxy surface until the GstVaapiPicture is destroyed.

Keep a valid reference to the proxy in GstVaapiPicture so that frames
marked as "used for reference" could be kept during the lifetime of the
picture. i.e. don't release them too soon as they could be re-used right
away.
This commit is contained in:
Gwenole Beauchesne 2012-01-26 15:28:42 +01:00
parent 2897618b85
commit 4a46b5d6c4
2 changed files with 18 additions and 4 deletions

View file

@ -71,6 +71,11 @@ gst_vaapi_picture_destroy(GstVaapiPicture *picture)
picture->bitplane = NULL;
}
if (picture->proxy) {
g_object_unref(picture->proxy);
picture->proxy = NULL;
}
picture->surface_id = VA_INVALID_ID;
picture->surface = NULL;
@ -110,6 +115,7 @@ gst_vaapi_picture_init(GstVaapiPicture *picture)
{
picture->type = GST_VAAPI_PICTURE_TYPE_NONE;
picture->surface = NULL;
picture->proxy = NULL;
picture->surface_id = VA_INVALID_ID;
picture->param = NULL;
picture->param_id = VA_INVALID_ID;
@ -227,12 +233,19 @@ gst_vaapi_picture_output(GstVaapiPicture *picture)
g_return_val_if_fail(GST_VAAPI_IS_PICTURE(picture), FALSE);
proxy = gst_vaapi_surface_proxy_new(GET_CONTEXT(picture), picture->surface);
if (!proxy)
return FALSE;
proxy = picture->proxy;
if (!proxy) {
proxy = gst_vaapi_surface_proxy_new(
GET_CONTEXT(picture),
picture->surface
);
if (!proxy)
return FALSE;
picture->proxy = proxy;
}
gst_vaapi_surface_proxy_set_timestamp(proxy, picture->pts);
gst_vaapi_decoder_push_surface_proxy(GET_DECODER(picture), proxy);
gst_vaapi_decoder_push_surface_proxy(GET_DECODER(picture), g_object_ref(proxy));
return TRUE;
}

View file

@ -105,6 +105,7 @@ struct _GstVaapiPicture {
/*< private >*/
GstVaapiCodecObject parent_instance;
GstVaapiSurface *surface;
GstVaapiSurfaceProxy *proxy;
VABufferID param_id;
/*< public >*/