# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.57)
-AC_INIT([libva], 0.25, [waldo.bastian@intel.com], libva)
+AC_INIT([libva], 0.26, [waldo.bastian@intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
}
+
+static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size)
+{
+ VAStatus vaStatus = VA_STATUS_SUCCESS;
+
+ obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size);
+ if (NULL == obj_buffer->buffer_data)
+ {
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+ return vaStatus;
+}
+
VAStatus dummy_CreateBuffer(
VADriverContextP ctx,
- VABufferType type, /* in */
- VABufferID *buf_desc /* out */
- )
+ VAContextID context, /* in */
+ VABufferType type, /* in */
+ unsigned int size, /* in */
+ unsigned int num_elements, /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
+)
{
INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS;
obj_buffer->buffer_data = NULL;
- *buf_desc = bufferID;
-
- return vaStatus;
-}
-
-static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size)
-{
- VAStatus vaStatus = VA_STATUS_SUCCESS;
-
- obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size);
- if (NULL == obj_buffer->buffer_data)
- {
- vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
- }
- return vaStatus;
-}
-
-VAStatus dummy_BufferData(
- VADriverContextP ctx,
- VABufferID buf_id, /* in */
- unsigned int size, /* in */
- unsigned int num_elements, /* in */
- void *data /* in */
- )
-{
- INIT_DRIVER_DATA
- VAStatus vaStatus = VA_STATUS_SUCCESS;
- object_buffer_p obj_buffer = BUFFER(buf_id);
- ASSERT(obj_buffer);
-
vaStatus = dummy__allocate_buffer(obj_buffer, size * num_elements);
if (VA_STATUS_SUCCESS == vaStatus)
{
}
}
+ if (VA_STATUS_SUCCESS == vaStatus)
+ {
+ *buf_id = bufferID;
+ }
+
return vaStatus;
}
+
VAStatus dummy_BufferSetNumElements(
VADriverContextP ctx,
VABufferID buf_id, /* in */
break;
}
}
+
+ /* Release buffers */
+ for(i = 0; i < num_buffers; i++)
+ {
+ object_buffer_p obj_buffer = BUFFER(buffers[i]);
+ ASSERT(obj_buffer);
+ dummy__destroy_buffer(driver_data, obj_buffer);
+ }
return vaStatus;
}
return VA_STATUS_SUCCESS;
}
-VAStatus __vaDriverInit_0_25( VADriverContextP ctx )
+VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
{
object_base_p obj;
int result;
int i;
ctx->version_major = 0;
- ctx->version_minor = 25;
+ ctx->version_minor = 26;
ctx->max_profiles = DUMMY_MAX_PROFILES;
ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
ctx->vtable.vaCreateContext = dummy_CreateContext;
ctx->vtable.vaDestroyContext = dummy_DestroyContext;
ctx->vtable.vaCreateBuffer = dummy_CreateBuffer;
- ctx->vtable.vaBufferData = dummy_BufferData;
ctx->vtable.vaBufferSetNumElements = dummy_BufferSetNumElements;
ctx->vtable.vaMapBuffer = dummy_MapBuffer;
ctx->vtable.vaUnmapBuffer = dummy_UnmapBuffer;
libva_la_LTLIBRARIES = libva.la
libva_ladir = $(libdir)
-libva_la_LDFLAGS = -version-number 0:25:0 -no-undefined
+libva_la_LDFLAGS = -version-number 0:26:0 -no-undefined
libva_la_LIBADD = -ldl -lX11 -lXext
libva_la_SOURCES = va_dri.c va.c va_dristr.h
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
#define DRIVER_EXTENSION "_drv_video.so"
-#define DRIVER_INIT_FUNC "__vaDriverInit_0_25"
+#define DRIVER_INIT_FUNC "__vaDriverInit_0_26"
#define CTX(dpy) ((VADriverContextP) dpy );
#define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
CHECK_VTABLE(vaStatus, ctx, CreateContext);
CHECK_VTABLE(vaStatus, ctx, DestroyContext);
CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
- CHECK_VTABLE(vaStatus, ctx, BufferData);
CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
CHECK_VTABLE(vaStatus, ctx, MapBuffer);
CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
VAStatus vaCreateBuffer (
VADisplay dpy,
- VABufferType type, /* in */
- VABufferID *buf_id /* out */
+ VAContextID context, /* in */
+ VABufferType type, /* in */
+ unsigned int size, /* in */
+ unsigned int num_elements, /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
)
{
VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx);
TRACE(vaCreateBuffer);
- return ctx->vtable.vaCreateBuffer( ctx, type, buf_id);
-}
-
-VAStatus vaBufferData (
- VADisplay dpy,
- VABufferID buf_id, /* in */
- unsigned int size, /* in */
- unsigned int num_elements, /* in */
- void *data /* in */
-)
-{
- VADriverContextP ctx = CTX(dpy);
- CHECK_CONTEXT(ctx);
-
- TRACE(vaBufferData);
- return ctx->vtable.vaBufferData( ctx, buf_id, size, num_elements, data);
+ return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
}
VAStatus vaBufferSetNumElements (
* rev 0.23 (09/11/2007 Jonathan Bian) - Fixed some issues with images and subpictures.
* rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes.
* rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types.
+ * rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics
*
* Acknowledgements:
* Some concepts borrowed from XvMC and XvImage.
/* Buffer functions */
/*
- * Creates a buffer for storing a certain type of data, no data store allocated
- * Note: image buffers are created by the library, not the client. Please see
- * vaCreateImage on how image buffers are managed.
- */
-VAStatus vaCreateBuffer (
- VADisplay dpy,
- VABufferType type, /* in */
- VABufferID *buf_id /* out */
-);
-
-/*
- * Create data store for the buffer and initalize with "data".
+ * Creates a buffer for "num_elements" elements of "size" bytes and
+ * initalize with "data".
* if "data" is null, then the contents of the buffer data store
* are undefined.
* Basically there are two ways to get buffer data to the server side. One is
- * to call vaBufferData() with a non-null "data", which results the data being
+ * to call vaCreateBuffer() with a non-null "data", which results the data being
* copied to the data store on the server side. A different method that
- * eliminates this copy is to pass null as "data" when calling vaBufferData(),
+ * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
* and then use vaMapBuffer() to map the data store from the server side to the
* client address space for access.
+ * Note: image buffers are created by the library, not the client. Please see
+ * vaCreateImage on how image buffers are managed.
*/
-VAStatus vaBufferData (
+VAStatus vaCreateBuffer (
VADisplay dpy,
- VABufferID buf_id, /* in */
+ VAContextID context,
+ VABufferType type, /* in */
unsigned int size, /* in */
unsigned int num_elements, /* in */
- void *data /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
);
/*
/*
* Map data store of the buffer into the client's address space
- * vaBufferData() needs to be called with "data" set to NULL before
+ * vaCreateBuffer() needs to be called with "data" set to NULL before
* calling vaMapBuffer()
*/
VAStatus vaMapBuffer (
/*
* After this call, the buffer is deleted and this buffer_id is no longer valid
+ * Only call this if the buffer is not going to be passed to vaRenderBuffer
*/
VAStatus vaDestroyBuffer (
VADisplay dpy,
/*
* Send decode buffers to the server.
+ * Buffers are automatically destroyed afterwards
*/
VAStatus vaRenderPicture (
VADisplay dpy,
/* Create a picture parameter buffer for this frame */
VABufferID picture_buf;
VAPictureParameterBufferMPEG2 *picture_param;
- vaCreateBuffer(dpy, VAPictureParameterBufferType, &picture_buf);
- vaBufferData(dpy, picture_buf, sizeof(VAPictureParameterBufferMPEG2), NULL);
+ vaCreateBuffer(dpy, context, VAPictureParameterBufferType, sizeof(VAPictureParameterBufferMPEG2), 1, NULL, &picture_buf);
vaMapBuffer(dpy, picture_buf, &picture_param);
picture_param->horizontal_size = 720;
picture_param->vertical_size = 480;
/* Create an IQ matrix buffer for this frame */
VABufferID iq_buf;
VAIQMatrixBufferMPEG2 *iq_matrix;
- vaCreateBuffer(dpy, VAIQMatrixBufferType, &iq_buf);
- vaBufferData(dpy, iq_buf, sizeof(VAIQMatrixBufferMPEG2), NULL);
+ vaCreateBuffer(dpy, context, VAIQMatrixBufferType, sizeof(VAIQMatrixBufferMPEG2), 1, NULL, &iq_buf);
vaMapBuffer(dpy, iq_buf, &iq_matrix);
/* fill values for IQ_matrix here */
vaUnmapBuffer(dpy, iq_buf);
/* Create a slice parameter buffer */
VABufferID slice_param_buf;
VASliceParameterBufferMPEG2 *slice_param;
- vaCreateBuffer(dpy, VASliceParameterBufferType, &slice_param_buf);
- vaBufferData(dpy, slice_param_buf, sizeof(VASliceParameterBufferMPEG2), NULL);
+ vaCreateBuffer(dpy, context, VASliceParameterBufferType, sizeof(VASliceParameterBufferMPEG2), 1, NULL, &slice_param_buf);
vaMapBuffer(dpy, slice_param_buf, &slice_param);
slice_param->slice_data_offset = 0;
/* Let's say all slices in this bit-stream has 64-bit header */
/* Create a slice data buffer */
unsigned char *slice_data;
VABufferID slice_data_buf;
- vaCreateBuffer(dpy, VASliceDataBufferType, slice_data_buf);
- vaBufferData(dpy, slice_data_buf, x /* decoder figure out how big */, NULL);
+ vaCreateBuffer(dpy, context, VASliceDataBufferType, x /* decoder figure out how big */, 1, NULL, &slice_data_buf);
vaMapBuffer(dpy, slice_data_buf, &slice_data);
/* decoder fill in slice_data */
vaUnmapBuffer(dpy, slice_data_buf);
VAStatus (*vaCreateBuffer) (
VADriverContextP ctx,
- VABufferType type, /* in */
- VABufferID *buf_desc /* out */
- );
-
- VAStatus (*vaBufferData) (
- VADriverContextP ctx,
- VABufferID buf_id, /* in */
- unsigned int size, /* in */
+ VAContextID context, /* in */
+ VABufferType type, /* in */
+ unsigned int size, /* in */
unsigned int num_elements, /* in */
- void *data /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
);
VAStatus (*vaBufferSetNumElements) (
#include "test_common.c"
+VAConfigID config;
+VAContextID context;
+VASurfaceID *surfaces;
+int total_surfaces;
+
void pre()
{
test_init();
+
+ va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+ status("vaCreateConfig returns %08x\n", config);
+
+ int width = 352;
+ int height = 288;
+ int surface_count = 4;
+ total_surfaces = surface_count;
+
+ surfaces = malloc(total_surfaces * sizeof(VASurfaceID));
+
+ // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config
+ va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ status("vaCreateContext with config %08x\n", config);
+ int flags = 0;
+ va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
}
void test_unique_buffers(VABufferID *buffer_list, int buffer_count)
VAImageBufferType
};
+unsigned int buffer_sizes[] =
+{
+ sizeof(VAPictureParameterBufferMPEG4),
+ sizeof(VAIQMatrixBufferH264),
+ 32*1024,
+ 48*1024,
+ sizeof(VASliceParameterBufferMPEG2),
+ 128*1024,
+ sizeof(VAMacroblockParameterBufferMPEG2),
+ 32*1024,
+ 15*1024,
+ 32*1024,
+};
+
+
#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType))
#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff)
for(i=0; i < NUM_BUFFER_TYPES; i++)
{
buffer_ids[i+1] = DEAD_BUFFER_ID;
- va_status = vaCreateBuffer(va_dpy, buffer_types[i], &buffer_ids[i]);
+ va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, NULL, &buffer_ids[i]);
ASSERT( VA_STATUS_SUCCESS == va_status );
ASSERT( DEAD_BUFFER_ID == buffer_ids[i+1] ); /* Bounds check */
}
void post()
{
+ status("vaDestroyContext for context %08x\n", context);
+ va_status = vaDestroyContext( va_dpy, context );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ status("vaDestroyConfig for config %08x\n", config);
+ va_status = vaDestroyConfig( va_dpy, config );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ free(surfaces);
+
test_terminate();
}
#include "test_common.c"
+VAConfigID config;
+VAContextID context;
+VASurfaceID *surfaces;
+int total_surfaces;
+
void pre()
{
test_init();
+
+ va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+ status("vaCreateConfig returns %08x\n", config);
+
+ int width = 352;
+ int height = 288;
+ int surface_count = 4;
+ total_surfaces = surface_count;
+
+ surfaces = malloc(total_surfaces * sizeof(VASurfaceID));
+
+ // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config
+ va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ status("vaCreateContext with config %08x\n", config);
+ int flags = 0;
+ va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+}
+
+void test_unique_buffers(VABufferID *buffer_list, int buffer_count)
+{
+ int i,j;
+
+ for(i = 0; i < buffer_count; i++)
+ {
+ for(j = 0; j < i; j++)
+ {
+ ASSERT(buffer_list[i] != buffer_list[j]);
+ }
+ }
}
VABufferType buffer_types[] =
32*1024,
};
+
#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType))
+#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff)
+
void test()
{
VABufferID buffer_ids[NUM_BUFFER_TYPES+1];
for(i=0; i < NUM_BUFFER_TYPES; i++)
{
uint32_t *data;
- va_status = vaCreateBuffer(va_dpy, buffer_types[i], &buffer_ids[i]);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]);
input_data[i] = malloc(buffer_sizes[i]+4);
ASSERT(input_data[i]);
ASSERT(data);
memcpy(data, input_data[i], buffer_sizes[i]);
- /* Send to VA Buffer */
- va_status = vaBufferData(va_dpy, buffer_ids[i], buffer_sizes[i], 1, data);
+ /* Create buffer and fill with data */
+ va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]);
ASSERT( VA_STATUS_SUCCESS == va_status );
+ status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]);
/* Wipe secondary buffer */
memset(data, 0, buffer_sizes[i]);
{
void *data = NULL;
/* Fetch VA Buffer */
- va_status = vaBufferData(va_dpy, buffer_ids[i], buffer_sizes[i], 1, NULL);
- ASSERT( VA_STATUS_SUCCESS == va_status );
-
va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data);
ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]);
}
}
+
+
void post()
{
+ status("vaDestroyContext for context %08x\n", context);
+ va_status = vaDestroyContext( va_dpy, context );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ status("vaDestroyConfig for config %08x\n", config);
+ va_status = vaDestroyConfig( va_dpy, config );
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
+ ASSERT( VA_STATUS_SUCCESS == va_status );
+
+ free(surfaces);
+
test_terminate();
}