mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 13:32:29 +00:00
Add VA buffer helpers.
This commit is contained in:
parent
9b9c049a67
commit
e0913aaf0e
2 changed files with 93 additions and 0 deletions
|
@ -47,6 +47,74 @@ vaapi_check_status(VAStatus status, const char *msg)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Maps VA buffer */
|
||||
void *
|
||||
vaapi_map_buffer(VADisplay dpy, VABufferID buf_id)
|
||||
{
|
||||
VAStatus status;
|
||||
void *data = NULL;
|
||||
|
||||
status = vaMapBuffer(dpy, buf_id, &data);
|
||||
if (!vaapi_check_status(status, "vaMapBuffer()"))
|
||||
return NULL;
|
||||
return data;
|
||||
}
|
||||
|
||||
/* Unmaps VA buffer */
|
||||
void
|
||||
vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf)
|
||||
{
|
||||
VAStatus status;
|
||||
|
||||
if (pbuf)
|
||||
*pbuf = NULL;
|
||||
|
||||
status = vaUnmapBuffer(dpy, buf_id);
|
||||
if (!vaapi_check_status(status, "vaUnmapBuffer()"))
|
||||
return;
|
||||
}
|
||||
|
||||
/* Creates and maps VA buffer */
|
||||
void *
|
||||
vaapi_create_buffer(
|
||||
VADisplay dpy,
|
||||
VAContextID ctx,
|
||||
int type,
|
||||
unsigned int size,
|
||||
VABufferID *buf_id_ptr
|
||||
)
|
||||
{
|
||||
VABufferID buf_id;
|
||||
VAStatus status;
|
||||
void *data;
|
||||
|
||||
status = vaCreateBuffer(dpy, ctx, type, size, 1, NULL, &buf_id);
|
||||
if (!vaapi_check_status(status, "vaCreateBuffer()"))
|
||||
return NULL;
|
||||
|
||||
data = vaapi_map_buffer(dpy, buf_id);
|
||||
if (!data)
|
||||
goto error;
|
||||
|
||||
*buf_id_ptr = buf_id;
|
||||
return data;
|
||||
|
||||
error:
|
||||
vaapi_destroy_buffer(dpy, &buf_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Destroy VA buffer */
|
||||
void
|
||||
vaapi_destroy_buffer(VADisplay dpy, VABufferID *buf_id_ptr)
|
||||
{
|
||||
if (!buf_id_ptr || *buf_id_ptr == VA_INVALID_ID)
|
||||
return;
|
||||
|
||||
vaDestroyBuffer(dpy, *buf_id_ptr);
|
||||
*buf_id_ptr = VA_INVALID_ID;
|
||||
}
|
||||
|
||||
/* Return a string representation of a VAProfile */
|
||||
const char *string_of_VAProfile(VAProfile profile)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,31 @@ gboolean
|
|||
vaapi_check_status(VAStatus status, const char *msg)
|
||||
attribute_hidden;
|
||||
|
||||
/** Maps VA buffer */
|
||||
void *
|
||||
vaapi_map_buffer(VADisplay dpy, VABufferID buf_id)
|
||||
attribute_hidden;
|
||||
|
||||
/** Unmaps VA buffer */
|
||||
void
|
||||
vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf)
|
||||
attribute_hidden;
|
||||
|
||||
/** Creates and maps VA buffer */
|
||||
void *
|
||||
vaapi_create_buffer(
|
||||
VADisplay dpy,
|
||||
VAContextID ctx,
|
||||
int type,
|
||||
unsigned int size,
|
||||
VABufferID *buf_id
|
||||
) attribute_hidden;
|
||||
|
||||
/** Destroy VA buffer */
|
||||
void
|
||||
vaapi_destroy_buffer(VADisplay dpy, VABufferID *buf_id)
|
||||
attribute_hidden;
|
||||
|
||||
/** Return a string representation of a VAProfile */
|
||||
const char *string_of_VAProfile(VAProfile profile)
|
||||
attribute_hidden;
|
||||
|
|
Loading…
Reference in a new issue