mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
libs: context: ensure context formats
This patch ensures to get the formats, as filter does, available in the decoder / encoder context. The context fills up the array as soon it is created, otherwise the pipeline could get stalled (perhaps this is a bug in my HSW backend). https://bugzilla.gnome.org/show_bug.cgi?id=752958
This commit is contained in:
parent
d1581ba557
commit
71264ede6f
2 changed files with 46 additions and 0 deletions
|
@ -50,6 +50,18 @@
|
||||||
/* Number of scratch surfaces beyond those used as reference */
|
/* Number of scratch surfaces beyond those used as reference */
|
||||||
#define SCRATCH_SURFACES_COUNT (4)
|
#define SCRATCH_SURFACES_COUNT (4)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ensure_formats (GstVaapiContext * context)
|
||||||
|
{
|
||||||
|
if (G_LIKELY (context->formats))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
context->formats =
|
||||||
|
gst_vaapi_get_surface_formats (GST_VAAPI_OBJECT_DISPLAY (context),
|
||||||
|
context->va_config);
|
||||||
|
return (context->formats != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unref_surface_cb (GstVaapiSurface * surface)
|
unref_surface_cb (GstVaapiSurface * surface)
|
||||||
{
|
{
|
||||||
|
@ -106,6 +118,11 @@ context_destroy (GstVaapiContext * context)
|
||||||
GST_WARNING ("failed to destroy config 0x%08x", context->va_config);
|
GST_WARNING ("failed to destroy config 0x%08x", context->va_config);
|
||||||
context->va_config = VA_INVALID_ID;
|
context->va_config = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context->formats) {
|
||||||
|
g_array_unref (context->formats);
|
||||||
|
context->formats = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -325,6 +342,8 @@ gst_vaapi_context_init (GstVaapiContext * context,
|
||||||
context->va_config = VA_INVALID_ID;
|
context->va_config = VA_INVALID_ID;
|
||||||
context->reset_on_resize = TRUE;
|
context->reset_on_resize = TRUE;
|
||||||
gst_vaapi_context_overlay_init (context);
|
gst_vaapi_context_overlay_init (context);
|
||||||
|
|
||||||
|
context->formats = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -520,3 +539,25 @@ gst_vaapi_context_reset_on_resize (GstVaapiContext * context,
|
||||||
|
|
||||||
context->reset_on_resize = reset_on_resize;
|
context->reset_on_resize = reset_on_resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_context_get_surface_formats:
|
||||||
|
* @context: a #GstVaapiContext
|
||||||
|
*
|
||||||
|
* Determines the set of supported formats by the surfaces associated
|
||||||
|
* to @context. The caller owns an extra reference of the resulting
|
||||||
|
* array of #GstVideoFormat elements, so it shall be released with
|
||||||
|
* g_array_unref after usage.
|
||||||
|
*
|
||||||
|
* Return value: (transfer full): the set of target formats supported
|
||||||
|
* by the surfaces in @context.
|
||||||
|
*/
|
||||||
|
GArray *
|
||||||
|
gst_vaapi_context_get_surface_formats (GstVaapiContext * context)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (context, NULL);
|
||||||
|
|
||||||
|
if (!ensure_formats (context))
|
||||||
|
return NULL;
|
||||||
|
return g_array_ref (context->formats);
|
||||||
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ struct _GstVaapiContext
|
||||||
GPtrArray *overlays[2];
|
GPtrArray *overlays[2];
|
||||||
guint overlay_id;
|
guint overlay_id;
|
||||||
gboolean reset_on_resize;
|
gboolean reset_on_resize;
|
||||||
|
GArray *formats;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,6 +150,10 @@ void
|
||||||
gst_vaapi_context_reset_on_resize (GstVaapiContext * context,
|
gst_vaapi_context_reset_on_resize (GstVaapiContext * context,
|
||||||
gboolean reset_on_resize);
|
gboolean reset_on_resize);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GArray *
|
||||||
|
gst_vaapi_context_get_surface_formats (GstVaapiContext * context);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_CONTEXT_H */
|
#endif /* GST_VAAPI_CONTEXT_H */
|
||||||
|
|
Loading…
Reference in a new issue