From 4a46b5d6c4a54fcb50828ee2b590d46b5f409906 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 26 Jan 2012 15:28:42 +0100 Subject: [PATCH] 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. --- gst-libs/gst/vaapi/gstvaapidecoder_objects.c | 21 ++++++++++++++++---- gst-libs/gst/vaapi/gstvaapidecoder_objects.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c index c25e86cfea..ed5f3c7803 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c @@ -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; } diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_objects.h b/gst-libs/gst/vaapi/gstvaapidecoder_objects.h index 2bd1ea9879..6bdfe2cb5c 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_objects.h +++ b/gst-libs/gst/vaapi/gstvaapidecoder_objects.h @@ -105,6 +105,7 @@ struct _GstVaapiPicture { /*< private >*/ GstVaapiCodecObject parent_instance; GstVaapiSurface *surface; + GstVaapiSurfaceProxy *proxy; VABufferID param_id; /*< public >*/