summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-01-30 10:15:32 +0100
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-01-30 10:32:14 +0100
commita79c7f9fa6e8d7eb5f62d682df7d9418e5b6241b (patch)
treef241e59d50eeaf3194ffcbe4073ec2e12c4326df /gst-libs
parent5cd0242bbb74370835b306c05afdd99065765f83 (diff)
decoder: optimize slice data buffers initialization.
VA drivers may have a faster means to transfer user buffers to GPU buffers than using memcpy(). In particular, on Intel Gen graphics, we can use pwrite(). This provides for faster upload of bitstream and can help higher bitrates. vaapi_create_buffer() helper function was also updated to allow for un-mapped buffers and pre-initialized data for buffers.
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapicodec_objects.c34
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_objects.c30
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.c33
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.h14
4 files changed, 59 insertions, 52 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicodec_objects.c b/gst-libs/gst/vaapi/gstvaapicodec_objects.c
index 7af2dd95..9a244bc9 100644
--- a/gst-libs/gst/vaapi/gstvaapicodec_objects.c
+++ b/gst-libs/gst/vaapi/gstvaapicodec_objects.c
@@ -150,16 +150,13 @@ gst_vaapi_iq_matrix_create(
const GstVaapiCodecObjectConstructorArgs *args
)
{
- iq_matrix->param = vaapi_create_buffer(
- GET_VA_DISPLAY(iq_matrix),
- GET_VA_CONTEXT(iq_matrix),
- VAIQMatrixBufferType,
- args->param_size,
- &iq_matrix->param_id
- );
- if (!iq_matrix->param)
- return FALSE;
- return TRUE;
+ return vaapi_create_buffer(GET_VA_DISPLAY(iq_matrix),
+ GET_VA_CONTEXT(iq_matrix),
+ VAIQMatrixBufferType,
+ args->param_size,
+ args->param,
+ &iq_matrix->param_id,
+ &iq_matrix->param);
}
static void
@@ -212,16 +209,13 @@ gst_vaapi_bitplane_create(
const GstVaapiCodecObjectConstructorArgs *args
)
{
- bitplane->data = vaapi_create_buffer(
- GET_VA_DISPLAY(bitplane),
- GET_VA_CONTEXT(bitplane),
- VABitPlaneBufferType,
- args->param_size,
- &bitplane->data_id
- );
- if (!bitplane->data)
- return FALSE;
- return TRUE;
+ return vaapi_create_buffer(GET_VA_DISPLAY(bitplane),
+ GET_VA_CONTEXT(bitplane),
+ VABitPlaneBufferType,
+ args->param_size,
+ args->param,
+ &bitplane->data_id,
+ &bitplane->data);
}
static void
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c
index ed5f3c78..aa1d7481 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c
@@ -89,19 +89,23 @@ gst_vaapi_picture_create(
const GstVaapiCodecObjectConstructorArgs *args
)
{
+ gboolean success;
+
picture->surface = gst_vaapi_context_get_surface(GET_CONTEXT(picture));
if (!picture->surface)
return FALSE;
picture->surface_id = gst_vaapi_surface_get_id(picture->surface);
- picture->param = vaapi_create_buffer(
+ success = vaapi_create_buffer(
GET_VA_DISPLAY(picture),
GET_VA_CONTEXT(picture),
VAPictureParameterBufferType,
args->param_size,
- &picture->param_id
+ args->param,
+ &picture->param_id,
+ &picture->param
);
- if (!picture->param)
+ if (!success)
return FALSE;
picture->slices = g_ptr_array_new();
@@ -274,28 +278,30 @@ gst_vaapi_slice_create(
)
{
VASliceParameterBufferBase *slice_param;
- guint8 *data;
+ gboolean success;
- data = vaapi_create_buffer(
+ success = vaapi_create_buffer(
GET_VA_DISPLAY(slice),
GET_VA_CONTEXT(slice),
VASliceDataBufferType,
args->data_size,
- &slice->data_id
+ args->data,
+ &slice->data_id,
+ NULL
);
- if (!data)
+ if (!success)
return FALSE;
- memcpy(data, args->data, args->data_size);
- vaapi_unmap_buffer(GET_VA_DISPLAY(slice), slice->data_id, NULL);
- slice->param = vaapi_create_buffer(
+ success = vaapi_create_buffer(
GET_VA_DISPLAY(slice),
GET_VA_CONTEXT(slice),
VASliceParameterBufferType,
args->param_size,
- &slice->param_id
+ args->param,
+ &slice->param_id,
+ &slice->param
);
- if (!slice->param)
+ if (!success)
return FALSE;
slice_param = slice->param;
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.c b/gst-libs/gst/vaapi/gstvaapiutils.c
index 97518cf2..2b8f17bd 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.c
+++ b/gst-libs/gst/vaapi/gstvaapiutils.c
@@ -76,33 +76,38 @@ vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf)
}
/* Creates and maps VA buffer */
-void *
+gboolean
vaapi_create_buffer(
- VADisplay dpy,
- VAContextID ctx,
- int type,
- unsigned int size,
- VABufferID *buf_id_ptr
+ VADisplay dpy,
+ VAContextID ctx,
+ int type,
+ unsigned int size,
+ gconstpointer buf,
+ VABufferID *buf_id_ptr,
+ gpointer *mapped_data
)
{
VABufferID buf_id;
VAStatus status;
- void *data;
+ gpointer data = (gpointer)buf;
- status = vaCreateBuffer(dpy, ctx, type, size, 1, NULL, &buf_id);
+ status = vaCreateBuffer(dpy, ctx, type, size, 1, data, &buf_id);
if (!vaapi_check_status(status, "vaCreateBuffer()"))
- return NULL;
+ return FALSE;
- data = vaapi_map_buffer(dpy, buf_id);
- if (!data)
- goto error;
+ if (mapped_data) {
+ data = vaapi_map_buffer(dpy, buf_id);
+ if (!data)
+ goto error;
+ *mapped_data = data;
+ }
*buf_id_ptr = buf_id;
- return data;
+ return TRUE;
error:
vaapi_destroy_buffer(dpy, &buf_id);
- return NULL;
+ return FALSE;
}
/* Destroy VA buffer */
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.h b/gst-libs/gst/vaapi/gstvaapiutils.h
index ac6a38f2..b8a42bc7 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.h
+++ b/gst-libs/gst/vaapi/gstvaapiutils.h
@@ -48,13 +48,15 @@ vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf)
attribute_hidden;
/** Creates and maps VA buffer */
-void *
+gboolean
vaapi_create_buffer(
- VADisplay dpy,
- VAContextID ctx,
- int type,
- unsigned int size,
- VABufferID *buf_id
+ VADisplay dpy,
+ VAContextID ctx,
+ int type,
+ unsigned int size,
+ gconstpointer data,
+ VABufferID *buf_id,
+ gpointer *mapped_data
) attribute_hidden;
/** Destroy VA buffer */