} MsdkSurface;
static void
-free_msdk_surface (MsdkSurface * surface)
+free_msdk_surface (gpointer p)
{
+ MsdkSurface *surface = (MsdkSurface *) p;
if (surface->buf)
gst_buffer_unref (surface->buf);
g_slice_free (MsdkSurface, surface);
}
static void
+release_msdk_surface (GstMsdkVPP * thiz, MsdkSurface * surface)
+{
+ if (surface->surface) {
+ if (surface->surface->Data.Locked) {
+ thiz->locked_msdk_surfaces =
+ g_list_append (thiz->locked_msdk_surfaces, surface);
+ } else {
+ free_msdk_surface (surface);
+ }
+ }
+}
+
+static void
+free_unlocked_msdk_surfaces (GstMsdkVPP * thiz)
+{
+ GList *l;
+ MsdkSurface *surface;
+
+ for (l = thiz->locked_msdk_surfaces; l;) {
+ GList *next = l->next;
+ surface = l->data;
+ if (surface->surface->Data.Locked == 0) {
+ free_msdk_surface (surface);
+ thiz->locked_msdk_surfaces =
+ g_list_delete_link (thiz->locked_msdk_surfaces, l);
+ }
+ l = next;
+ }
+}
+
+static void
+free_all_msdk_surfaces (GstMsdkVPP * thiz)
+{
+ g_list_free_full (thiz->locked_msdk_surfaces, free_msdk_surface);
+ thiz->locked_msdk_surfaces = NULL;
+}
+
+static void
gst_msdkvpp_add_extra_param (GstMsdkVPP * thiz, mfxExtBuffer * param)
{
if (thiz->num_extra_params < MAX_EXTRA_PARAMS) {
MsdkSurface *out_surface = NULL;
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
+ free_unlocked_msdk_surfaces (thiz);
in_surface = get_msdk_surface_from_input_buffer (thiz, inbuf);
if (!in_surface)
gst_flow_get_name (ret));
transform_end:
- free_msdk_surface (in_surface);
- free_msdk_surface (out_surface);
+ release_msdk_surface (thiz, in_surface);
+ release_msdk_surface (thiz, out_surface);
return ret;
}
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
msdk_status_to_string (status));
}
+ free_all_msdk_surfaces (thiz);
gst_clear_object (&thiz->context);