mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
msdkvpp: hold GstBuffer ref count for locked surfaces
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1278>
This commit is contained in:
parent
12532cc8bb
commit
275518f661
2 changed files with 46 additions and 3 deletions
|
@ -176,13 +176,52 @@ typedef struct
|
||||||
} MsdkSurface;
|
} MsdkSurface;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_msdk_surface (MsdkSurface * surface)
|
free_msdk_surface (gpointer p)
|
||||||
{
|
{
|
||||||
|
MsdkSurface *surface = (MsdkSurface *) p;
|
||||||
if (surface->buf)
|
if (surface->buf)
|
||||||
gst_buffer_unref (surface->buf);
|
gst_buffer_unref (surface->buf);
|
||||||
g_slice_free (MsdkSurface, surface);
|
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
|
static void
|
||||||
gst_msdkvpp_add_extra_param (GstMsdkVPP * thiz, mfxExtBuffer * param)
|
gst_msdkvpp_add_extra_param (GstMsdkVPP * thiz, mfxExtBuffer * param)
|
||||||
{
|
{
|
||||||
|
@ -755,6 +794,7 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
||||||
MsdkSurface *out_surface = NULL;
|
MsdkSurface *out_surface = NULL;
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
||||||
|
free_unlocked_msdk_surfaces (thiz);
|
||||||
|
|
||||||
in_surface = get_msdk_surface_from_input_buffer (thiz, inbuf);
|
in_surface = get_msdk_surface_from_input_buffer (thiz, inbuf);
|
||||||
if (!in_surface)
|
if (!in_surface)
|
||||||
|
@ -855,8 +895,8 @@ error_push_buffer:
|
||||||
gst_flow_get_name (ret));
|
gst_flow_get_name (ret));
|
||||||
|
|
||||||
transform_end:
|
transform_end:
|
||||||
free_msdk_surface (in_surface);
|
release_msdk_surface (thiz, in_surface);
|
||||||
free_msdk_surface (out_surface);
|
release_msdk_surface (thiz, out_surface);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -880,6 +920,7 @@ gst_msdkvpp_close (GstMsdkVPP * thiz)
|
||||||
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
|
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
|
||||||
msdk_status_to_string (status));
|
msdk_status_to_string (status));
|
||||||
}
|
}
|
||||||
|
free_all_msdk_surfaces (thiz);
|
||||||
|
|
||||||
gst_clear_object (&thiz->context);
|
gst_clear_object (&thiz->context);
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,8 @@ struct _GstMsdkVPP
|
||||||
/* Extended buffers */
|
/* Extended buffers */
|
||||||
mfxExtBuffer *extra_params[MAX_EXTRA_PARAMS];
|
mfxExtBuffer *extra_params[MAX_EXTRA_PARAMS];
|
||||||
guint num_extra_params;
|
guint num_extra_params;
|
||||||
|
|
||||||
|
GList* locked_msdk_surfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstMsdkVPPClass
|
struct _GstMsdkVPPClass
|
||||||
|
|
Loading…
Reference in a new issue