typedef struct _GstVaDisplayPrivate GstVaDisplayPrivate;
struct _GstVaDisplayPrivate
{
- GRecMutex lock;
VADisplay display;
gboolean foreign;
static void
gst_va_display_finalize (GObject * object)
{
- GstVaDisplayPrivate *priv = GET_PRIV (object);
-
- g_rec_mutex_clear (&priv->lock);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
{
GstVaDisplayPrivate *priv = GET_PRIV (self);
- g_rec_mutex_init (&priv->lock);
priv->impl = GST_VA_IMPLEMENTATION_INVALID;
}
-/**
- * gst_va_display_lock:
- * @self: a #GstVaDisplay
- *
- * Lock the display. It will be used before we call the
- * VA API functions to serialize the VA commands.
- *
- * Since: 1.20
- **/
-void
-gst_va_display_lock (GstVaDisplay * self)
-{
- GstVaDisplayPrivate *priv;
-
- g_return_if_fail (GST_IS_VA_DISPLAY (self));
-
- priv = GET_PRIV (self);
-
- g_rec_mutex_lock (&priv->lock);
-}
-
-/**
- * gst_va_display_unlock:
- * @self: a #GstVaDisplay
- *
- * Unlock the display. It will be used after we call the
- * VA API functions.
- *
- * Since: 1.20
- **/
-void
-gst_va_display_unlock (GstVaDisplay * self)
-{
- GstVaDisplayPrivate *priv;
-
- g_return_if_fail (GST_IS_VA_DISPLAY (self));
-
- priv = GET_PRIV (self);
-
- g_rec_mutex_unlock (&priv->lock);
-}
-
#ifndef GST_DISABLE_GST_DEBUG
static gchar *
_strip_msg (const char *message)
GST_VA_API
GType gst_va_display_get_type (void);
GST_VA_API
-void gst_va_display_lock (GstVaDisplay * self);
-GST_VA_API
-void gst_va_display_unlock (GstVaDisplay * self);
-GST_VA_API
gboolean gst_va_display_initialize (GstVaDisplay * self);
GST_VA_API
gpointer gst_va_display_get_va_dpy (GstVaDisplay * self);
dpy = gst_va_display_get_va_dpy (display);
- gst_va_display_lock (display);
status = vaQuerySurfaceAttributes (dpy, config, NULL, attrib_count);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (display, "vaQuerySurfaceAttributes: %s",
vaErrorStr (status));
attribs = g_new (VASurfaceAttrib, *attrib_count);
- gst_va_display_lock (display);
status = vaQuerySurfaceAttributes (dpy, config, attribs, attrib_count);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (display, "vaQuerySurfaceAttributes: %s",
vaErrorStr (status));
dpy = gst_va_display_get_va_dpy (display);
- gst_va_display_lock (display);
status = vaCreateConfig (dpy, profile, entrypoint, &attrib, 1, &config);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (display, "vaCreateConfig: %s", vaErrorStr (status));
return NULL;
caps = gst_va_create_raw_caps_from_config (display, config);
- gst_va_display_lock (display);
status = vaDestroyConfig (dpy, config);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (display, "vaDestroyConfig: %s", vaErrorStr (status));
return NULL;
dpy = gst_va_display_get_va_dpy (display);
- gst_va_display_lock (display);
status = vaGetConfigAttributes (dpy, profile, entrypoint, attribs,
G_N_ELEMENTS (attribs));
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (display, "vaGetConfigAttributes: %s",
vaErrorStr (status));
}
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateConfig (dpy, profile, VAEntrypointVLD, &attrib, 1, &config);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateConfig: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
if (self->context != VA_INVALID_ID) {
- gst_va_display_lock (self->display);
status = vaDestroyContext (dpy, self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS)
GST_ERROR_OBJECT (self, "vaDestroyContext: %s", vaErrorStr (status));
}
- gst_va_display_lock (self->display);
status = vaDestroyConfig (dpy, self->config);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaDestroyConfig: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateContext (dpy, self->config, coded_width, coded_height,
VA_PROGRESSIVE, render_targets, num_render_targets, &context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaDestroyConfig: %s", vaErrorStr (status));
g_return_val_if_fail (pic && data && size > 0, FALSE);
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateBuffer (dpy, self->context, type, size, 1, data, &buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateBuffer: %s", vaErrorStr (status));
return FALSE;
&& params_data && params_size > 0, FALSE);
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateBuffer (dpy, self->context, VASliceParameterBufferType,
params_size, params_num, params_data, ¶ms_buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateBuffer: %s", vaErrorStr (status));
return FALSE;
}
- gst_va_display_lock (self->display);
status = vaCreateBuffer (dpy, self->context, VASliceDataBufferType,
slice_size, 1, slice_data, &slice_buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateBuffer: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaBeginPicture (dpy, self->context, surface);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING_OBJECT (self, "vaBeginPicture: %s", vaErrorStr (status));
goto fail_end_pic;
}
if (pic->buffers->len > 0) {
- gst_va_display_lock (self->display);
status = vaRenderPicture (dpy, self->context,
(VABufferID *) pic->buffers->data, pic->buffers->len);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING_OBJECT (self, "vaRenderPicture: %s", vaErrorStr (status));
goto fail_end_pic;
}
if (pic->slices->len > 0) {
- gst_va_display_lock (self->display);
status = vaRenderPicture (dpy, self->context,
(VABufferID *) pic->slices->data, pic->slices->len);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING_OBJECT (self, "vaRenderPicture: %s", vaErrorStr (status));
goto fail_end_pic;
}
}
- gst_va_display_lock (self->display);
status = vaEndPicture (dpy, self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS)
GST_WARNING_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status));
else
fail_end_pic:
{
- gst_va_display_lock (self->display);
status = vaEndPicture (dpy, self->context);
- gst_va_display_unlock (self->display);
goto bail;
}
}
if (pic->buffers) {
for (i = 0; i < pic->buffers->len; i++) {
buffer = g_array_index (pic->buffers, VABufferID, i);
- gst_va_display_lock (pic->display);
status = vaDestroyBuffer (dpy, buffer);
- gst_va_display_unlock (pic->display);
if (status != VA_STATUS_SUCCESS) {
ret = FALSE;
GST_WARNING ("Failed to destroy parameter buffer: %s",
if (pic->slices) {
for (i = 0; i < pic->slices->len; i++) {
buffer = g_array_index (pic->slices, VABufferID, i);
- gst_va_display_lock (pic->display);
status = vaDestroyBuffer (dpy, buffer);
- gst_va_display_unlock (pic->display);
if (status != VA_STATUS_SUCCESS) {
ret = FALSE;
GST_WARNING ("Failed to destroy slice buffer: %s", vaErrorStr (status));
dpy = gst_va_display_get_va_dpy (self);
- gst_va_display_lock (self);
num_profiles = vaMaxNumProfiles (dpy);
num_entrypoints = vaMaxNumEntrypoints (dpy);
- gst_va_display_unlock (self);
profiles = g_new (VAProfile, num_profiles);
entrypoints = g_new (VAEntrypoint, num_entrypoints);
- gst_va_display_lock (self);
status = vaQueryConfigProfiles (dpy, profiles, &num_profiles);
- gst_va_display_unlock (self);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaQueryConfigProfile: %s", vaErrorStr (status));
goto bail;
if (codec != gst_va_profile_codec (profiles[i]))
continue;
- gst_va_display_lock (self);
status = vaQueryConfigEntrypoints (dpy, profiles[i], entrypoints,
&num_entrypoints);
- gst_va_display_unlock (self);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaQueryConfigEntrypoints: %s", vaErrorStr (status));
goto bail;
dpy = gst_va_display_get_va_dpy (self);
- gst_va_display_lock (self);
max = vaMaxNumImageFormats (dpy);
- gst_va_display_unlock (self);
if (max == 0)
return NULL;
va_formats = g_new (VAImageFormat, max);
- gst_va_display_lock (self);
status = vaQueryImageFormats (dpy, va_formats, &num);
- gst_va_display_unlock (self);
gst_va_video_format_fix_map (va_formats, num);
dpy = gst_va_display_get_va_dpy (self);
- gst_va_display_lock (self);
max = vaMaxNumEntrypoints (dpy);
- gst_va_display_unlock (self);
entrypoints = g_new (VAEntrypoint, max);
- gst_va_display_lock (self);
status = vaQueryConfigEntrypoints (dpy, VAProfileNone, entrypoints, &num);
- gst_va_display_unlock (self);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaQueryImageFormats: %s", vaErrorStr (status));
goto bail;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaGetConfigAttributes (dpy, VAProfileNone, VAEntrypointVideoProc,
attribs, G_N_ELEMENTS (attribs));
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaGetConfigAttributes: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaQueryVideoProcPipelineCaps (dpy, self->context, NULL, 0,
&self->pipeline_caps);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaQueryVideoProcPipelineCaps: %s",
vaErrorStr (status));
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateConfig (dpy, VAProfileNone, VAEntrypointVideoProc, &attrib,
1, &self->config);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateConfig: %s", vaErrorStr (status));
return FALSE;
if (!gst_va_filter_ensure_surface_attributes (self))
goto bail;
- gst_va_display_lock (self->display);
status = vaCreateContext (dpy, self->config, 0, 0, 0, NULL, 0,
&self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateContext: %s", vaErrorStr (status));
goto bail;
bail:
{
- gst_va_display_lock (self->display);
status = vaDestroyConfig (dpy, self->config);
- gst_va_display_unlock (self->display);
return FALSE;
}
dpy = gst_va_display_get_va_dpy (self->display);
if (self->context != VA_INVALID_ID) {
- gst_va_display_lock (self->display);
status = vaDestroyContext (dpy, self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS)
GST_ERROR_OBJECT (self, "vaDestroyContext: %s", vaErrorStr (status));
}
- gst_va_display_lock (self->display);
status = vaDestroyConfig (dpy, self->config);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaDestroyConfig: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaQueryVideoProcFilters (dpy, self->context, filter_types, &num);
- gst_va_display_unlock (self->display);
if (status == VA_STATUS_ERROR_MAX_NUM_EXCEEDED) {
filter_types = g_try_realloc_n (filter_types, num, sizeof (*filter_types));
- gst_va_display_lock (self->display);
status = vaQueryVideoProcFilters (dpy, self->context, filter_types, &num);
- gst_va_display_unlock (self->display);
}
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaQueryVideoProcFilters: %s", vaErrorStr (status));
struct VaFilter filter = { filter_types[i], num_caps, {{{0,}}} };
if (num_caps > 0) {
- gst_va_display_lock (self->display);
status = vaQueryVideoProcFilterCaps (dpy, self->context, filter.type,
&filter.caps, &filter.num_caps);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING_OBJECT (self, "vaQueryVideoProcFiltersCaps: %s",
vaErrorStr (status));
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaQueryVideoProcPipelineCaps (dpy, self->context, va_filters,
num_filters, caps);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaQueryVideoProcPipelineCaps: %s",
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateBuffer (dpy, self->context, VAProcFilterParameterBufferType,
size, num, data, &buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateBuffer: %s", vaErrorStr (status));
return FALSE;
for (i = 0; i < self->filters->len; i++) {
buffer = g_array_index (self->filters, VABufferID, i);
- gst_va_display_lock (self->display);
status = vaDestroyBuffer (dpy, buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
ret = FALSE;
GST_WARNING_OBJECT (self, "Failed to destroy filter buffer: %s",
GST_OBJECT_UNLOCK (self);
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaCreateBuffer (dpy, self->context,
VAProcPipelineParameterBufferType, sizeof (params), 1, ¶ms, buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateBuffer: %s", vaErrorStr (status));
return FALSE;
dpy = gst_va_display_get_va_dpy (self->display);
- gst_va_display_lock (self->display);
status = vaBeginPicture (dpy, self->context, dst->surface);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaBeginPicture: %s", vaErrorStr (status));
return FALSE;
}
- gst_va_display_lock (self->display);
status = vaRenderPicture (dpy, self->context, &buffer, 1);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaRenderPicture: %s", vaErrorStr (status));
goto fail_end_pic;
}
- gst_va_display_lock (self->display);
status = vaEndPicture (dpy, self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status));
goto bail;
ret = TRUE;
bail:
- gst_va_display_lock (self->display);
status = vaDestroyBuffer (dpy, buffer);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING_OBJECT (self, "Failed to destroy pipeline buffer: %s",
vaErrorStr (status));
fail_end_pic:
{
- gst_va_display_lock (self->display);
status = vaEndPicture (dpy, self->context);
- gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS)
GST_ERROR_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status));
goto bail;
dpy = gst_va_display_get_va_dpy (display);
- gst_va_display_lock (display);
status = vaGetDisplayAttributes (dpy, &attr, 1);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_INFO ("vaGetDisplayAttribures: %s", vaErrorStr (status));
return FALSE;
g_return_val_if_fail (num_surfaces > 0, FALSE);
- gst_va_display_lock (display);
status = vaDestroySurfaces (dpy, surfaces, num_surfaces);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaDestroySurfaces: %s", vaErrorStr (status));
return FALSE;
/* *INDENT-ON* */
}
- gst_va_display_lock (display);
status = vaCreateSurfaces (dpy, rt_format, width, height, surfaces,
num_surfaces, attrs, num_attrs);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaCreateSurfaces: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaExportSurfaceHandle (dpy, surface,
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, flags, desc);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaExportSurfaceHandle: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaDestroyImage (dpy, image_id);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaDestroyImage: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaDeriveImage (dpy, surface, image);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING ("vaDeriveImage: %s", vaErrorStr (status));
return FALSE;
if (!va_format)
return FALSE;
- gst_va_display_lock (display);
status =
vaCreateImage (dpy, (VAImageFormat *) va_format, width, height, image);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaCreateImage: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaGetImage (dpy, surface, 0, 0, image->width, image->height,
image->image_id);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaGetImage: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaSyncSurface (dpy, surface);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING ("vaSyncSurface: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaMapBuffer (dpy, buffer, data);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING ("vaMapBuffer: %s", vaErrorStr (status));
return FALSE;
VADisplay dpy = gst_va_display_get_va_dpy (display);
VAStatus status;
- gst_va_display_lock (display);
status = vaUnmapBuffer (dpy, buffer);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_WARNING ("vaUnmapBuffer: %s", vaErrorStr (status));
return FALSE;
if (!va_sync_surface (display, surface))
return FALSE;
- gst_va_display_lock (display);
status = vaPutImage (dpy, surface, image->image_id, 0, 0, image->width,
image->height, 0, 0, image->width, image->height);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaPutImage: %s", vaErrorStr (status));
return FALSE;
VAStatus status;
VASurfaceStatus state;
- gst_va_display_lock (display);
status = vaQuerySurfaceStatus (dpy, surface, &state);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS)
GST_ERROR ("vaQuerySurfaceStatus: %s", vaErrorStr (status));
/* *INDENT-ON* */
VAStatus status;
- gst_va_display_lock (display);
status = vaCopy (dpy, &obj_dst, &obj_src, option);
- gst_va_display_unlock (display);
if (status != VA_STATUS_SUCCESS) {
GST_INFO ("vaCopy: %s", vaErrorStr (status));
return FALSE;