summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldo Bastian <waldo.bastian@intel.com>2007-12-17 14:00:17 -0800
committerWaldo Bastian <waldo.bastian@intel.com>2007-12-17 14:00:17 -0800
commit563092b87a49483b6e0da071e3416723b13ea863 (patch)
treeb81be2f16f8a9bb4c95b2623b04729030265ae08
parent8de3509ff26510ef02a00fdda78c3431b4329253 (diff)
downloadlibva-563092b87a49483b6e0da071e3416723b13ea863.tar.gz
Update to libva v0.26
-rw-r--r--configure.ac2
-rw-r--r--dummy_drv_video/dummy_drv_video.c271
-rw-r--r--dummy_drv_video/dummy_drv_video.h12
-rw-r--r--src/Makefile.am2
-rw-r--r--src/va.c300
-rwxr-xr-xsrc/va.h504
-rwxr-xr-xsrc/va_backend.h148
-rwxr-xr-xsrc/va_x11.h9
-rw-r--r--test/Makefile.am5
-rw-r--r--test/test.c18
-rw-r--r--test/test_07.c40
-rw-r--r--test/test_08.c14
-rw-r--r--test/test_09.c10
-rw-r--r--test/test_10.c55
-rw-r--r--test/test_11.c69
-rw-r--r--test/vainfo.c73
16 files changed, 944 insertions, 588 deletions
diff --git a/configure.ac b/configure.ac
index 82088ff..eac1988 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.57)
-AC_INIT([libva], 0.22, [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])
diff --git a/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c
index 4ec2a55..7cf1a50 100644
--- a/dummy_drv_video/dummy_drv_video.c
+++ b/dummy_drv_video/dummy_drv_video.c
@@ -366,7 +366,7 @@ VAStatus dummy_CreateSurfaces(
int height,
int format,
int num_surfaces,
- VASurface *surfaces /* out */
+ VASurfaceID *surfaces /* out */
)
{
INIT_DRIVER_DATA
@@ -388,13 +388,8 @@ VAStatus dummy_CreateSurfaces(
vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
break;
}
- obj_surface->surface = &(surfaces[i]);
- obj_surface->surface->surface_id = surfaceID;
- obj_surface->surface->context_id = -1;
- obj_surface->surface->width = width;
- obj_surface->surface->height = height;
- obj_surface->surface->format = format;
- obj_surface->surface->privData = NULL;
+ obj_surface->surface_id = surfaceID;
+ surfaces[i] = surfaceID;
}
/* Error recovery */
@@ -403,8 +398,8 @@ VAStatus dummy_CreateSurfaces(
/* surfaces[i-1] was the last successful allocation */
for(; i--; )
{
- object_surface_p obj_surface = SURFACE(surfaces[i].surface_id);
- surfaces[i].surface_id = -1;
+ object_surface_p obj_surface = SURFACE(surfaces[i]);
+ surfaces[i] = VA_INVALID_SURFACE;
ASSERT(obj_surface);
object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
}
@@ -413,9 +408,9 @@ VAStatus dummy_CreateSurfaces(
return vaStatus;
}
-VAStatus dummy_DestroySurface(
+VAStatus dummy_DestroySurfaces(
VADriverContextP ctx,
- VASurface *surface_list,
+ VASurfaceID *surface_list,
int num_surfaces
)
{
@@ -423,7 +418,7 @@ VAStatus dummy_DestroySurface(
int i;
for(i = num_surfaces; i--; )
{
- object_surface_p obj_surface = SURFACE(surface_list[i].surface_id);
+ object_surface_p obj_surface = SURFACE(surface_list[i]);
ASSERT(obj_surface);
object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
}
@@ -458,7 +453,19 @@ VAStatus dummy_CreateImage(
VAStatus dummy_DestroyImage(
VADriverContextP ctx,
- VAImage *image
+ VAImageID image
+)
+{
+ INIT_DRIVER_DATA
+
+ /* TODO */
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus dummy_SetImagePalette(
+ VADriverContextP ctx,
+ VAImageID image,
+ unsigned char *palette
)
{
INIT_DRIVER_DATA
@@ -469,12 +476,12 @@ VAStatus dummy_DestroyImage(
VAStatus dummy_GetImage(
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */
int y,
unsigned int width, /* width and height of the region */
unsigned int height,
- VAImage *image
+ VAImageID image
)
{
INIT_DRIVER_DATA
@@ -485,8 +492,8 @@ VAStatus dummy_GetImage(
VAStatus dummy_PutImage(
VADriverContextP ctx,
- VASurface *surface,
- VAImage *image,
+ VASurfaceID surface,
+ VAImageID image,
int src_x,
int src_y,
unsigned int width,
@@ -516,8 +523,8 @@ VAStatus dummy_QuerySubpictureFormats(
VAStatus dummy_CreateSubpicture(
VADriverContextP ctx,
- VAImage *image,
- VASubpicture *subpicture /* out */
+ VAImageID image,
+ VASubpictureID *subpicture /* out */
)
{
INIT_DRIVER_DATA
@@ -528,7 +535,7 @@ VAStatus dummy_CreateSubpicture(
VAStatus dummy_DestroySubpicture(
VADriverContextP ctx,
- VASubpicture *subpicture
+ VASubpictureID subpicture
)
{
INIT_DRIVER_DATA
@@ -539,8 +546,8 @@ VAStatus dummy_DestroySubpicture(
VAStatus dummy_SetSubpictureImage(
VADriverContextP ctx,
- VASubpicture *subpicture,
- VAImage *image
+ VASubpictureID subpicture,
+ VAImageID image
)
{
INIT_DRIVER_DATA
@@ -551,7 +558,7 @@ VAStatus dummy_SetSubpictureImage(
VAStatus dummy_SetSubpicturePalette(
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
@@ -568,9 +575,10 @@ VAStatus dummy_SetSubpicturePalette(
VAStatus dummy_SetSubpictureChromakey(
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
unsigned int chromakey_min,
- unsigned int chromakey_max
+ unsigned int chromakey_max,
+ unsigned int chromakey_mask
)
{
INIT_DRIVER_DATA
@@ -581,7 +589,7 @@ VAStatus dummy_SetSubpictureChromakey(
VAStatus dummy_SetSubpictureGlobalAlpha(
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
float global_alpha
)
{
@@ -593,8 +601,9 @@ VAStatus dummy_SetSubpictureGlobalAlpha(
VAStatus dummy_AssociateSubpicture(
VADriverContextP ctx,
- VASurface *target_surface,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
short dest_x, /* upper left offset in surface */
@@ -614,15 +623,28 @@ VAStatus dummy_AssociateSubpicture(
return VA_STATUS_SUCCESS;
}
+VAStatus dummy_DeassociateSubpicture(
+ VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces
+)
+{
+ INIT_DRIVER_DATA
+
+ /* TODO */
+ return VA_STATUS_SUCCESS;
+}
+
VAStatus dummy_CreateContext(
VADriverContextP ctx,
VAConfigID config_id,
int picture_width,
int picture_height,
int flag,
- VASurface *render_targets,
+ VASurfaceID *render_targets,
int num_render_targets,
- VAContext *context /* out */
+ VAContextID *context /* out */
)
{
INIT_DRIVER_DATA
@@ -648,41 +670,34 @@ VAStatus dummy_CreateContext(
return vaStatus;
}
- obj_context->context = context;
+ obj_context->context_id = contextID;
+ *context = contextID;
obj_context->current_render_target = -1;
-
- obj_context->context->context_id = contextID;
- obj_context->context->config_id = config_id;
- obj_context->context->picture_width = picture_width;
- obj_context->context->picture_height = picture_height;
- obj_context->context->num_render_targets = num_render_targets;
- obj_context->context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
+ obj_context->config_id = config_id;
+ obj_context->picture_width = picture_width;
+ obj_context->picture_height = picture_height;
+ obj_context->num_render_targets = num_render_targets;
+ obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
for(i = 0; i < num_render_targets; i++)
{
- if (NULL == SURFACE(render_targets[i].surface_id))
+ if (NULL == SURFACE(render_targets[i]))
{
vaStatus = VA_STATUS_ERROR_INVALID_SURFACE;
break;
}
- obj_context->context->render_targets[i] = render_targets[i].surface_id;
+ obj_context->render_targets[i] = render_targets[i];
}
- obj_context->context->flags = flag;
- obj_context->context->privData = NULL;
+ obj_context->flags = flag;
/* Error recovery */
if (VA_STATUS_SUCCESS != vaStatus)
{
- free(obj_context->context->render_targets);
- obj_context->context->render_targets = NULL;
- obj_context->context->context_id = -1;
- obj_context->context->config_id = -1;
- obj_context->context->picture_width = 0;
- obj_context->context->picture_height = 0;
- free(obj_context->context->render_targets);
- obj_context->context->render_targets = NULL;
- obj_context->context->num_render_targets = 0;
- obj_context->context->flags = 0;
- obj_context->context->privData = NULL;
+ obj_context->context_id = -1;
+ obj_context->config_id = -1;
+ free(obj_context->render_targets);
+ obj_context->render_targets = NULL;
+ obj_context->num_render_targets = 0;
+ obj_context->flags = 0;
object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
}
@@ -692,27 +707,25 @@ VAStatus dummy_CreateContext(
VAStatus dummy_DestroyContext(
VADriverContextP ctx,
- VAContext *context
+ VAContextID context
)
{
INIT_DRIVER_DATA
- object_context_p obj_context = CONTEXT(context->context_id);
+ object_context_p obj_context = CONTEXT(context);
ASSERT(obj_context);
- obj_context->context->context_id = -1;
- obj_context->context->config_id = -1;
- obj_context->context->picture_width = 0;
- obj_context->context->picture_height = 0;
- if (obj_context->context->render_targets)
+ obj_context->context_id = -1;
+ obj_context->config_id = -1;
+ obj_context->picture_width = 0;
+ obj_context->picture_height = 0;
+ if (obj_context->render_targets)
{
- free(obj_context->context->render_targets);
+ free(obj_context->render_targets);
}
- obj_context->context->render_targets = NULL;
- obj_context->context->num_render_targets = 0;
- obj_context->context->flags = 0;
- obj_context->context->privData = NULL;
+ obj_context->render_targets = NULL;
+ obj_context->num_render_targets = 0;
+ obj_context->flags = 0;
- obj_context->context = NULL;
obj_context->current_render_target = -1;
object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
@@ -721,11 +734,28 @@ VAStatus dummy_DestroyContext(
}
+
+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;
@@ -762,36 +792,6 @@ VAStatus dummy_CreateBuffer(
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)
{
@@ -803,9 +803,15 @@ VAStatus dummy_BufferData(
}
}
+ if (VA_STATUS_SUCCESS == vaStatus)
+ {
+ *buf_id = bufferID;
+ }
+
return vaStatus;
}
+
VAStatus dummy_BufferSetNumElements(
VADriverContextP ctx,
VABufferID buf_id, /* in */
@@ -888,8 +894,8 @@ VAStatus dummy_DestroyBuffer(
VAStatus dummy_BeginPicture(
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
)
{
INIT_DRIVER_DATA
@@ -897,10 +903,10 @@ VAStatus dummy_BeginPicture(
object_context_p obj_context;
object_surface_p obj_surface;
- obj_context = CONTEXT(context->context_id);
+ obj_context = CONTEXT(context);
ASSERT(obj_context);
- obj_surface = SURFACE(render_target->surface_id);
+ obj_surface = SURFACE(render_target);
ASSERT(obj_surface);
obj_context->current_render_target = obj_surface->base.id;
@@ -910,7 +916,7 @@ VAStatus dummy_BeginPicture(
VAStatus dummy_RenderPicture(
VADriverContextP ctx,
- VAContext *context,
+ VAContextID context,
VABufferID *buffers,
int num_buffers
)
@@ -921,7 +927,7 @@ VAStatus dummy_RenderPicture(
object_surface_p obj_surface;
int i;
- obj_context = CONTEXT(context->context_id);
+ obj_context = CONTEXT(context);
ASSERT(obj_context);
obj_surface = SURFACE(obj_context->current_render_target);
@@ -938,13 +944,21 @@ VAStatus dummy_RenderPicture(
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;
}
VAStatus dummy_EndPicture(
VADriverContextP ctx,
- VAContext *context
+ VAContextID context
)
{
INIT_DRIVER_DATA
@@ -952,7 +966,7 @@ VAStatus dummy_EndPicture(
object_context_p obj_context;
object_surface_p obj_surface;
- obj_context = CONTEXT(context->context_id);
+ obj_context = CONTEXT(context);
ASSERT(obj_context);
obj_surface = SURFACE(obj_context->current_render_target);
@@ -967,8 +981,8 @@ VAStatus dummy_EndPicture(
VAStatus dummy_SyncSurface(
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
)
{
INIT_DRIVER_DATA
@@ -976,10 +990,10 @@ VAStatus dummy_SyncSurface(
object_context_p obj_context;
object_surface_p obj_surface;
- obj_context = CONTEXT(context->context_id);
+ obj_context = CONTEXT(context);
ASSERT(obj_context);
- obj_surface = SURFACE(render_target->surface_id);
+ obj_surface = SURFACE(render_target);
ASSERT(obj_surface);
/* Assume that this shouldn't be called before vaEndPicture() */
@@ -990,38 +1004,25 @@ VAStatus dummy_SyncSurface(
VAStatus dummy_QuerySurfaceStatus(
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target,
+ VASurfaceID render_target,
VASurfaceStatus *status /* out */
)
{
INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS;
- object_context_p obj_context;
object_surface_p obj_surface;
- obj_context = CONTEXT(context->context_id);
- ASSERT(obj_context);
-
- obj_surface = SURFACE(render_target->surface_id);
+ obj_surface = SURFACE(render_target);
ASSERT(obj_surface);
- /* Assume that we are busy until vaEndPicture() is called */
- if ( obj_context->current_render_target == obj_surface->base.id )
- {
- *status = VASurfaceRendering;
- }
- else
- {
- *status = VASurfaceReady;
- }
+ *status = VASurfaceReady;
return vaStatus;
}
VAStatus dummy_PutSurface(
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
Drawable draw, /* X Drawable */
short srcx,
short srcy,
@@ -1091,7 +1092,7 @@ VAStatus dummy_SetDisplayAttributes (
VAStatus dummy_DbgCopySurfaceToBuffer(
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
void **buffer, /* out */
unsigned int *stride /* out */
)
@@ -1140,7 +1141,7 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
return VA_STATUS_SUCCESS;
}
-VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
+VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
{
object_base_p obj;
int result;
@@ -1148,13 +1149,14 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
int i;
ctx->version_major = 0;
- ctx->version_minor = 24;
+ ctx->version_minor = 26;
ctx->max_profiles = DUMMY_MAX_PROFILES;
ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS;
ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS;
ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES;
+ ctx->str_vendor = DUMMY_STR_VENDOR;
ctx->vtable.vaTerminate = dummy_Terminate;
ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
@@ -1165,11 +1167,10 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaDestroyConfig = dummy_DestroyConfig;
ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes;
ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces;
- ctx->vtable.vaDestroySurface = dummy_DestroySurface;
+ ctx->vtable.vaDestroySurfaces = dummy_DestroySurfaces;
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;
@@ -1183,6 +1184,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats;
ctx->vtable.vaCreateImage = dummy_CreateImage;
ctx->vtable.vaDestroyImage = dummy_DestroyImage;
+ ctx->vtable.vaSetImagePalette = dummy_SetImagePalette;
ctx->vtable.vaGetImage = dummy_GetImage;
ctx->vtable.vaPutImage = dummy_PutImage;
ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
@@ -1193,6 +1195,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
+ ctx->vtable.vaDeassociateSubpicture = dummy_DeassociateSubpicture;
ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes;
ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes;
ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes;
diff --git a/dummy_drv_video/dummy_drv_video.h b/dummy_drv_video/dummy_drv_video.h
index 81a9a44..d1920ab 100644
--- a/dummy_drv_video/dummy_drv_video.h
+++ b/dummy_drv_video/dummy_drv_video.h
@@ -34,6 +34,7 @@
#define DUMMY_MAX_IMAGE_FORMATS 10
#define DUMMY_MAX_SUBPIC_FORMATS 4
#define DUMMY_MAX_DISPLAY_ATTRIBUTES 4
+#define DUMMY_STR_VENDOR "Dummy-dummy-1.0-dummy"
struct dummy_driver_data {
struct object_heap config_heap;
@@ -52,14 +53,19 @@ struct object_config {
struct object_context {
struct object_base base;
- VAContext *context;
- VAConfigID config;
+ VAContextID context_id;
+ VAConfigID config_id;
VASurfaceID current_render_target;
+ int picture_width;
+ int picture_height;
+ int num_render_targets;
+ int flags;
+ VASurfaceID *render_targets;
};
struct object_surface {
struct object_base base;
- VASurface *surface;
+ VASurfaceID surface_id;
};
struct object_buffer {
diff --git a/src/Makefile.am b/src/Makefile.am
index e0ea3c1..1eed0c6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@
libva_la_LTLIBRARIES = libva.la
libva_ladir = $(libdir)
-libva_la_LDFLAGS = -version-number 0:24: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
diff --git a/src/va.c b/src/va.c
index bb02f38..5681a6e 100644
--- a/src/va.c
+++ b/src/va.c
@@ -34,22 +34,26 @@
#include <unistd.h>
#include "va_dri.h"
+#define VA_MAJOR_VERSION 0
+#define VA_MINOR_VERSION 26
+#define DRIVER_INIT_FUNC "__vaDriverInit_0_26"
+
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
#define DRIVER_EXTENSION "_drv_video.so"
-#define DRIVER_INIT_FUNC "__vaDriverInit_0_24"
#define CTX(dpy) ((VADriverContextP) dpy );
-#define ASSERT_CONTEXT(dpy) assert( vaDbgContextIsValid(dpy) )
+#define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
#define ASSERT assert
#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
+#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
#define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
static VADriverContextP pDriverContexts = NULL;
static int va_debug_trace = 0;
-static Bool vaDbgContextIsValid(VADriverContextP arg_ctx)
+static Bool vaContextIsValid(VADriverContextP arg_ctx)
{
VADriverContextP ctx = pDriverContexts;
@@ -70,7 +74,12 @@ VADisplay vaGetDisplay (
{
VADisplay dpy = NULL;
VADriverContextP ctx = pDriverContexts;
-
+
+ if (!native_dpy)
+ {
+ return NULL;
+ }
+
while (ctx)
{
if (ctx->x11_dpy == (Display *)native_dpy)
@@ -134,6 +143,16 @@ static Bool va_checkMaximum(int value, char *variable)
return True;
}
+static Bool va_checkString(const char* value, char *variable)
+{
+ if (!value)
+ {
+ va_errorMessage("Failed to define str_%s in init\n", variable);
+ return False;
+ }
+ return True;
+}
+
static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
{
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
@@ -255,6 +274,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_MAXIMUM(vaStatus, ctx, image_formats);
CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
+ CHECK_STRING(vaStatus, ctx, vendor);
CHECK_VTABLE(vaStatus, ctx, Terminate);
CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
@@ -263,11 +283,10 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
- CHECK_VTABLE(vaStatus, ctx, DestroySurface);
+ CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
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);
@@ -281,6 +300,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
CHECK_VTABLE(vaStatus, ctx, CreateImage);
CHECK_VTABLE(vaStatus, ctx, DestroyImage);
+ CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
CHECK_VTABLE(vaStatus, ctx, GetImage);
CHECK_VTABLE(vaStatus, ctx, PutImage);
CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
@@ -291,6 +311,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
+ CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
@@ -367,7 +388,7 @@ VAStatus vaInitialize (
char *driver_name = NULL;
VAStatus vaStatus;
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
@@ -379,8 +400,8 @@ VAStatus vaInitialize (
vaStatus = va_openDriver(ctx, driver_name);
va_infoMessage("va_openDriver() returns %d\n", vaStatus);
- *major_version = ctx->version_major;
- *minor_version = ctx->version_minor;
+ *major_version = VA_MAJOR_VERSION;
+ *minor_version = VA_MINOR_VERSION;
}
if (driver_name)
@@ -400,7 +421,7 @@ VAStatus vaTerminate (
{
VAStatus vaStatus = VA_STATUS_SUCCESS;
VADriverContextP old_ctx = CTX(dpy);
- ASSERT_CONTEXT(old_ctx);
+ CHECK_CONTEXT(old_ctx);
if (old_ctx->handle)
{
@@ -429,13 +450,38 @@ VAStatus vaTerminate (
return vaStatus;
}
+/*
+ * vaQueryVendorString returns a pointer to a zero-terminated string
+ * describing some aspects of the VA implemenation on a specific
+ * hardware accelerator. The format of the returned string is:
+ * <vendorname>-<major_version>-<minor_version>-<addtional_info>
+ * e.g. for the Intel GMA500 implementation, an example would be:
+ * "IntelGMA500-1.0-0.2-patch3
+ */
+const char *vaQueryVendorString (
+ VADisplay dpy
+)
+{
+ VADriverContextP ctx = CTX(dpy);
+ if( !vaContextIsValid(ctx) )
+ {
+ return NULL;
+ }
+
+ return ctx->str_vendor;
+}
+
+
/* Get maximum number of profiles supported by the implementation */
int vaMaxNumProfiles (
VADisplay dpy
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_profiles;
}
@@ -446,7 +492,10 @@ int vaMaxNumEntrypoints (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_entrypoints;
}
@@ -458,7 +507,10 @@ int vaMaxNumConfigAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_attributes;
}
@@ -471,7 +523,7 @@ VAStatus vaQueryConfigEntrypoints (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigEntrypoints);
return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
@@ -486,7 +538,7 @@ VAStatus vaGetConfigAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaGetConfigAttributes);
return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
@@ -499,7 +551,7 @@ VAStatus vaQueryConfigProfiles (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigProfiles);
return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
@@ -515,7 +567,7 @@ VAStatus vaCreateConfig (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaCreateConfig);
return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
@@ -527,7 +579,7 @@ VAStatus vaDestroyConfig (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDestroyConfig);
return ctx->vtable.vaDestroyConfig ( ctx, config_id );
@@ -543,7 +595,7 @@ VAStatus vaQueryConfigAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigAttributes);
return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
@@ -555,27 +607,27 @@ VAStatus vaCreateSurfaces (
int height,
int format,
int num_surfaces,
- VASurface *surfaces /* out */
+ VASurfaceID *surfaces /* out */
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaCreateSurfaces);
return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
}
-VAStatus vaDestroySurface (
+VAStatus vaDestroySurfaces (
VADisplay dpy,
- VASurface *surface_list,
+ VASurfaceID *surface_list,
int num_surfaces
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
- TRACE(vaDestroySurface);
- return ctx->vtable.vaDestroySurface( ctx, surface_list, num_surfaces );
+ TRACE(vaDestroySurfaces);
+ return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
}
VAStatus vaCreateContext (
@@ -584,13 +636,13 @@ VAStatus vaCreateContext (
int picture_width,
int picture_height,
int flag,
- VASurface *render_targets,
+ VASurfaceID *render_targets,
int num_render_targets,
- VAContext *context /* out */
+ VAContextID *context /* out */
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaCreateContext);
return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
@@ -599,11 +651,11 @@ VAStatus vaCreateContext (
VAStatus vaDestroyContext (
VADisplay dpy,
- VAContext *context
+ VAContextID context
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDestroyContext);
return ctx->vtable.vaDestroyContext( ctx, context );
@@ -611,30 +663,19 @@ VAStatus vaDestroyContext (
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);
- ASSERT_CONTEXT(ctx);
+ 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);
- ASSERT_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 (
@@ -644,7 +685,7 @@ VAStatus vaBufferSetNumElements (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaBufferSetNumElements);
return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
@@ -658,7 +699,7 @@ VAStatus vaMapBuffer (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaMapBuffer);
return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
@@ -670,7 +711,7 @@ VAStatus vaUnmapBuffer (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaUnmapBuffer);
return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
@@ -682,7 +723,7 @@ VAStatus vaDestroyBuffer (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDestroyBuffer);
return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
@@ -690,12 +731,12 @@ VAStatus vaDestroyBuffer (
VAStatus vaBeginPicture (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaBeginPicture);
return ctx->vtable.vaBeginPicture( ctx, context, render_target );
@@ -703,13 +744,13 @@ VAStatus vaBeginPicture (
VAStatus vaRenderPicture (
VADisplay dpy,
- VAContext *context,
+ VAContextID context,
VABufferID *buffers,
int num_buffers
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaRenderPicture);
return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
@@ -717,11 +758,11 @@ VAStatus vaRenderPicture (
VAStatus vaEndPicture (
VADisplay dpy,
- VAContext *context
+ VAContextID context
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaEndPicture);
return ctx->vtable.vaEndPicture( ctx, context );
@@ -729,12 +770,12 @@ VAStatus vaEndPicture (
VAStatus vaSyncSurface (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSyncSurface);
return ctx->vtable.vaSyncSurface( ctx, context, render_target );
@@ -742,21 +783,20 @@ VAStatus vaSyncSurface (
VAStatus vaQuerySurfaceStatus (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target,
+ VASurfaceID render_target,
VASurfaceStatus *status /* out */
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQuerySurfaceStatus);
- return ctx->vtable.vaQuerySurfaceStatus( ctx, context, render_target, status );
+ return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
}
VAStatus vaPutSurface (
VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
Drawable draw, /* X Drawable */
short srcx,
short srcy,
@@ -772,7 +812,7 @@ VAStatus vaPutSurface (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaPutSurface);
return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
@@ -786,7 +826,10 @@ int vaMaxNumImageFormats (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_image_formats;
}
@@ -798,7 +841,7 @@ VAStatus vaQueryImageFormats (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQueryImageFormats);
return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
@@ -821,7 +864,7 @@ VAStatus vaCreateImage (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaCreateImage);
return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
@@ -832,32 +875,45 @@ VAStatus vaCreateImage (
*/
VAStatus vaDestroyImage (
VADisplay dpy,
- VAImage *image
+ VAImageID image
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDestroyImage);
return ctx->vtable.vaDestroyImage ( ctx, image);
}
+VAStatus vaSetImagePalette (
+ VADisplay dpy,
+ VAImageID image,
+ unsigned char *palette
+)
+{
+ VADriverContextP ctx = CTX(dpy);
+ CHECK_CONTEXT(ctx);
+
+ TRACE(vaSetImagePalette);
+ return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
+}
+
/*
* Retrieve surface data into a VAImage
* Image must be in a format supported by the implementation
*/
VAStatus vaGetImage (
VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */
int y,
unsigned int width, /* width and height of the region */
unsigned int height,
- VAImage *image
+ VAImageID image
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaGetImage);
return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
@@ -869,8 +925,8 @@ VAStatus vaGetImage (
*/
VAStatus vaPutImage (
VADisplay dpy,
- VASurface *surface,
- VAImage *image,
+ VASurfaceID surface,
+ VAImageID image,
int src_x,
int src_y,
unsigned int width,
@@ -880,7 +936,7 @@ VAStatus vaPutImage (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaPutImage);
return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
@@ -892,7 +948,10 @@ int vaMaxNumSubpictureFormats (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_subpic_formats;
}
@@ -912,7 +971,7 @@ VAStatus vaQuerySubpictureFormats (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQuerySubpictureFormats);
return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
@@ -923,12 +982,12 @@ VAStatus vaQuerySubpictureFormats (
*/
VAStatus vaCreateSubpicture (
VADisplay dpy,
- VAImage *image,
- VASubpicture *subpicture /* out */
+ VAImageID image,
+ VASubpictureID *subpicture /* out */
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaCreateSubpicture);
return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
@@ -939,11 +998,11 @@ VAStatus vaCreateSubpicture (
*/
VAStatus vaDestroySubpicture (
VADisplay dpy,
- VASubpicture *subpicture
+ VASubpictureID subpicture
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDestroySubpicture);
return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
@@ -951,12 +1010,12 @@ VAStatus vaDestroySubpicture (
VAStatus vaSetSubpictureImage (
VADisplay dpy,
- VASubpicture *subpicture,
- VAImage *image
+ VASubpictureID subpicture,
+ VAImageID image
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureImage);
return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
@@ -965,7 +1024,7 @@ VAStatus vaSetSubpictureImage (
VAStatus vaSetSubpicturePalette (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
@@ -975,7 +1034,7 @@ VAStatus vaSetSubpicturePalette (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSetSubpicturePalette);
return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
@@ -987,16 +1046,17 @@ VAStatus vaSetSubpicturePalette (
*/
VAStatus vaSetSubpictureChromakey (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
unsigned int chromakey_min,
- unsigned int chromakey_max
+ unsigned int chromakey_max,
+ unsigned int chromakey_mask
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureChromakey);
- return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max );
+ return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
}
@@ -1007,12 +1067,12 @@ VAStatus vaSetSubpictureChromakey (
*/
VAStatus vaSetSubpictureGlobalAlpha (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
float global_alpha
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureGlobalAlpha);
return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
@@ -1027,8 +1087,9 @@ VAStatus vaSetSubpictureGlobalAlpha (
*/
VAStatus vaAssociateSubpicture (
VADisplay dpy,
- VASurface *target_surface,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
short dest_x, /* upper left offset in surface */
@@ -1043,19 +1104,40 @@ VAStatus vaAssociateSubpicture (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaAssociateSubpicture);
- return ctx->vtable.vaAssociateSubpicture ( ctx, target_surface, subpicture, src_x, src_y, dest_x, dest_y, width, height, flags );
+ return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
+}
+
+/*
+ * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
+ */
+VAStatus vaDeassociateSubpicture (
+ VADisplay dpy,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces
+)
+{
+ VADriverContextP ctx = CTX(dpy);
+ CHECK_CONTEXT(ctx);
+
+ TRACE(vaDeassociateSubpicture);
+ return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
}
+
/* Get maximum number of display attributes supported by the implementation */
int vaMaxNumDisplayAttributes (
VADisplay dpy
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ if( !vaContextIsValid(ctx) )
+ {
+ return 0;
+ }
return ctx->max_display_attributes;
}
@@ -1073,7 +1155,7 @@ VAStatus vaQueryDisplayAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaQueryDisplayAttributes);
return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1092,7 +1174,7 @@ VAStatus vaGetDisplayAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaGetDisplayAttributes);
return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1111,7 +1193,7 @@ VAStatus vaSetDisplayAttributes (
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaSetDisplayAttributes);
return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1120,13 +1202,13 @@ VAStatus vaSetDisplayAttributes (
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
void **buffer, /* out */
unsigned int *stride /* out */
)
{
VADriverContextP ctx = CTX(dpy);
- ASSERT_CONTEXT(ctx);
+ CHECK_CONTEXT(ctx);
TRACE(vaDbgCopySurfaceToBuffer);
return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );
diff --git a/src/va.h b/src/va.h
index 66cc7a0..49c26bd 100755
--- a/src/va.h
+++ b/src/va.h
@@ -24,7 +24,7 @@
/*
* Video Decode Acceleration API Specification
*
- * Rev. 0.24
+ * Rev. 0.25
* <jonathan.bian@intel.com>
*
* Revision History:
@@ -33,22 +33,25 @@
* rev 0.12 (02/05/2007 Jonathan Bian) - Added VC-1 data structures for slice level decode
* rev 0.13 (02/28/2007 Jonathan Bian) - Added GetDisplay()
* rev 0.14 (04/13/2007 Jonathan Bian) - Fixed MPEG-2 PictureParameter structure, cleaned up a few funcs.
- * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management
- * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration
+ * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management
+ * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration
* rev 0.17 (05/07/2007 Jonathan Bian) - Added H.264/AVC data structures for slice level decode.
* rev 0.18 (05/14/2007 Jonathan Bian) - Added data structures for MPEG-4 slice level decode
* and MPEG-2 motion compensation.
- * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data.
- * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure.
- * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support.
+ * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data.
+ * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure.
+ * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support.
* rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha.
- * rev 0.23 (09/07/2007 Jonathan Bian) - Fixed some issues with images and subpictures.
- * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes.
+ * 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.
- * Thanks to Waldo Bastian for many valuable feedbacks.
+ * Thanks to Waldo Bastian, Matt Sottek and Austin Yuan at Intel for many valuable feedbacks.
*/
+
#ifndef _VA_H_
#define _VA_H_
@@ -59,7 +62,10 @@ extern "C" {
/*
Overview
-This is currently a decode only interface (with some rendering support).
+This API is intended to provide an interface between a video decode
+application (client) and a hardware decode accelerator (server), to off-load
+video decode operations from the host to the hardware accelerator at various
+entry-points.
The basic operation steps are:
@@ -86,17 +92,22 @@ typedef void* VADisplay; /* window system dependent */
typedef int VAStatus; /* Return status type from functions */
/* Values for the return status */
#define VA_STATUS_SUCCESS 0x00000000
-#define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000001
-#define VA_STATUS_ERROR_INVALID_CONFIG 0x00000002
-#define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000003
-#define VA_STATUS_ERROR_INVALID_SURFACE 0x00000004
-#define VA_STATUS_ERROR_INVALID_BUFFER 0x00000005
-#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x00000006
-#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x00000007
-#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x00000008
-#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x00000009
-#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000a
-#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000b
+#define VA_STATUS_ERROR_OPERATION_FAILED 0x00000001
+#define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000002
+#define VA_STATUS_ERROR_INVALID_DISPLAY 0x00000003
+#define VA_STATUS_ERROR_INVALID_CONFIG 0x00000004
+#define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005
+#define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006
+#define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007
+#define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008
+#define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009
+#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a
+#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b
+#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c
+#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000d
+#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e
+#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f
+#define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010
#define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
/*
@@ -117,6 +128,9 @@ VADisplay vaGetDisplay (
NativeDisplay native_dpy /* implementation specific */
);
+/*
+ * Initialize the library
+ */
VAStatus vaInitialize (
VADisplay dpy,
int *major_version, /* out */
@@ -130,6 +144,18 @@ VAStatus vaTerminate (
VADisplay dpy
);
+/*
+ * vaQueryVendorString returns a pointer to a zero-terminated string
+ * describing some aspects of the VA implemenation on a specific
+ * hardware accelerator. The format of the returned string is:
+ * <vendorname>-<major_version>-<minor_version>-<addtional_info>
+ * e.g. for the Intel GMA500 implementation, an example would be:
+ * "IntelGMA500-1.0-0.2-patch3
+ */
+const char *vaQueryVendorString (
+ VADisplay dpy
+);
+
/* Currently defined profiles */
typedef enum
{
@@ -232,8 +258,8 @@ VAStatus vaQueryConfigEntrypoints (
/*
* Get attributes for a given profile/entrypoint pair
- * The caller must provide an “attrib_list” with all attributes to be
- * queried. Upon return, the attributes in “attrib_list” have been
+ * The caller must provide an "attrib_list" with all attributes to be
+ * retrieved. Upon return, the attributes in "attrib_list" have been
* updated with their value. Unknown attributes or attributes that are
* not supported for the given profile/entrypoint pair will have their
* value set to VA_ATTRIB_NOT_SUPPORTED
@@ -275,11 +301,11 @@ VAStatus vaDestroyConfig (
/*
* Query all attributes for a given configuration
- * The profile of the configuration is returned in “profile”
- * The entrypoint of the configuration is returned in “entrypoint”
- * The caller must provide an “attrib_list” array that can hold at least
+ * The profile of the configuration is returned in "profile"
+ * The entrypoint of the configuration is returned in "entrypoint"
+ * The caller must provide an "attrib_list" array that can hold at least
* vaMaxNumConfigAttributes() entries. The actual number of attributes
- * returned in “attrib_list” is returned in “num_attribs”
+ * returned in "attrib_list" is returned in "num_attribs"
*/
VAStatus vaQueryConfigAttributes (
VADisplay dpy,
@@ -292,9 +318,19 @@ VAStatus vaQueryConfigAttributes (
/*
- * Context
+ * Contexts and Surfaces
+ *
+ * Context represents a "virtual" video decode pipeline. Surfaces are render
+ * targets for a given context. The data in the surfaces are not accessible
+ * to the client and the internal data format of the surface is implementatin
+ * specific.
*
- * Context represents a "virtual" video decode pipeline
+ * Surfaces will be bound to a context when the context is created. Once
+ * a surface is bound to a given context, it can not be used to create
+ * another context. The association is removed when the context is destroyed
+ *
+ * Both contexts and surfaces are identified by unique IDs and its
+ * implementation specific internals are kept opaque to the clients
*/
typedef VAGenericID VAContextID;
@@ -303,97 +339,78 @@ typedef VAGenericID VASurfaceID;
#define VA_INVALID_SURFACE -1
-typedef struct _VAContext
-{
- VAContextID context_id; /* to identify this context */
- VAConfigID config_id;
- unsigned short picture_width;
- unsigned short picture_height;
- VASurfaceID *render_targets;
- int num_render_targets;
- int flags;
- void *privData;
-} VAContext;
-
-/*
- flags - Any combination of the following:
- VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
-*/
-#define VA_PROGRESSIVE 0x1
-
-/*
-
-Surface Management
-
-Surfaces are render targets for a given context. The data in the surfaces
-are not accessible to the client and the internal data format of
-the surface is implementatin specific.
-
-Question: Is there a need to know the data format (fourcc) or just
-differentiate between 420/422/444 is sufficient?
-
-*/
-
-typedef struct _VASurface
-{
- VASurfaceID surface_id; /* uniquely identify this surface */
- VAContextID context_id; /* which context does this surface belong */
- unsigned short width;
- unsigned short height;
- int format; /* 420/422/444 */
- void *privData; /* private to the library */
-} VASurface;
-
/*
- * Surfaces will be bound to a context when the context is created. Once
- * a surface is bound to a given context, it can not be used to create
- * another context. The association is removed when the context is destroyed
+ * vaCreateSurfaces - Create an array of surfaces used for decode and display
+ * dpy: display
+ * width: surface width
+ * height: surface height
+ * format: VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV422 or VA_RT_FORMAT_YUV444
+ * num_surfaces: number of surfaces to be created
+ * surfaces: array of surfaces created upon return
*/
-
-/* Surface Functions */
VAStatus vaCreateSurfaces (
VADisplay dpy,
int width,
int height,
int format,
int num_surfaces,
- VASurface *surfaces /* out */
+ VASurfaceID *surfaces /* out */
);
/*
- * surfaces can only be destroyed after the context associated has been
- * destroyed
+ * vaDestroySurfaces - Destroy resources associated with surfaces.
+ * Surfaces can only be destroyed after the context associated has been
+ * destroyed.
+ * dpy: display
+ * surfaces: array of surfaces to destroy
+ * num_surfaces: number of surfaces in the array to be destroyed.
*/
-VAStatus vaDestroySurface (
+VAStatus vaDestroySurfaces (
VADisplay dpy,
- VASurface *surface_list,
+ VASurfaceID *surfaces,
int num_surfaces
);
+#define VA_PROGRESSIVE 0x1
+/*
+ * vaCreateContext - Create a context
+ * dpy: display
+ * config_id: configuration for the context
+ * picture_width: coded picture width
+ * picture_height: coded picture height
+ * flag: any combination of the following:
+ * VA_PROGRESSIVE (only progressive frame pictures in the sequence when set)
+ * render_targets: render targets (surfaces) tied to the context
+ * num_render_targets: number of render targets in the above array
+ * context: created context id upon return
+ */
VAStatus vaCreateContext (
VADisplay dpy,
VAConfigID config_id,
int picture_width,
int picture_height,
int flag,
- VASurface *render_targets,
+ VASurfaceID *render_targets,
int num_render_targets,
- VAContext *context /* out */
+ VAContextID *context /* out */
);
+/*
+ * vaDestroyContext - Destroy a context
+ * dpy: display
+ * context: context to be destroyed
+ */
VAStatus vaDestroyContext (
VADisplay dpy,
- VAContext *context
+ VAContextID context
);
/*
- *
- * Buffers
- * Buffers are used to pass various types of data from the
- * client to the server. The server maintains a data store
- * for each buffer created, and the client idenfies a buffer
- * through a unique buffer id assigned by the server.
- *
+ * Buffers
+ * Buffers are used to pass various types of data from the
+ * client to the server. The server maintains a data store
+ * for each buffer created, and the client idenfies a buffer
+ * through a unique buffer id assigned by the server.
*/
typedef VAGenericID VABufferID;
@@ -619,7 +636,16 @@ typedef struct _VASliceParameterBufferMPEG4
/*
VC-1 data structures
*/
-
+
+typedef enum /* see 7.1.1.32 */
+{
+ VAMvMode1Mv = 0,
+ VAMvMode1MvHalfPel = 1,
+ VAMvMode1MvHalfPelBilinear = 2,
+ VAMvModeMixedMv = 3,
+ VAMvModeIntensityCompensation = 4
+} VAMvModeVC1;
+
/* VC-1 Picture Parameter Buffer */
/*
* For each picture, and before any slice data, a picture parameter
@@ -689,12 +715,12 @@ typedef struct _VAPictureParameterBufferVC1
unsigned char picture_fields;
};
union {
- struct {
+ struct {
unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */
unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */
unsigned char skip_mb : 1; /* PICTURE::SKIPMB */
unsigned char field_tx : 1; /* PICTURE::FIELDTX */
- unsigned char foward_mb : 1; /* PICTURE::FORWARDMB */
+ unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */
unsigned char ac_pred : 1; /* PICTURE::ACPRED */
unsigned char overflags : 1; /* PICTURE::OVERFLAGS */
};
@@ -702,6 +728,18 @@ typedef struct _VAPictureParameterBufferVC1
};
union {
struct {
+ unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */
+ unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */
+ unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */
+ unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */
+ unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */
+ unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */
+ unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */
+ };
+ unsigned char bitplane_present_flag; /* signal what bitplane is being passed via the bitplane buffer */
+ };
+ union {
+ struct {
unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
unsigned char reference_distance : 1;/* PICTURE_LAYER::REFDIST */
unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
@@ -711,16 +749,16 @@ typedef struct _VAPictureParameterBufferVC1
};
union {
struct {
- unsigned char mv_mode : 2; /* PICTURE_LAYER::MVMODE */
- unsigned char mv_mode2 : 2; /* PICTURE_LAYER::MVMODE2 */
- unsigned char mv_table : 3;/* PICTURE_LAYER::MVTAB/IMVTAB */
- unsigned char two_mv_block_pattern_table: 2;/* PICTURE_LAYER::2MVBPTAB */
- unsigned char four_mv_switch: 1; /* PICTURE_LAYER::4MVSWITCH */
- unsigned char four_mv_block_pattern_table : 2;/* PICTURE_LAYER::4MVBPTAB */
- unsigned char extended_mv_flag: 1;/* ENTRY_POINT_LAYER::EXTENDED_MV */
- unsigned char extended_mv_range : 2;/* PICTURE_LAYER::MVRANGE */
- unsigned char extended_dmv_flag : 1;/* ENTRY_POINT_LAYER::EXTENDED_DMV */
- unsigned char extended_dmv_range : 2;/* PICTURE_LAYER::DMVRANGE */
+ VAMvModeVC1 mv_mode : 3; /* PICTURE_LAYER::MVMODE */
+ VAMvModeVC1 mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */
+ unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
+ unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
+ unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */
+ unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
+ unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
+ unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */
+ unsigned char extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
+ unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
};
unsigned int mv_fields;
};
@@ -728,7 +766,7 @@ typedef struct _VAPictureParameterBufferVC1
struct {
unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */
unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */
- unsigned char pic_quantizer_scale : 1;/* PICTURE_LAYER::PQUANT */
+ unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */
unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */
@@ -902,31 +940,27 @@ typedef struct _VASliceParameterBufferH264
/* Buffer functions */
/*
- * Creates a buffer for storing a certain type of data, no data store allocated
- */
-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 */
);
/*
@@ -943,7 +977,7 @@ VAStatus vaBufferSetNumElements (
/*
* 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 (
@@ -964,6 +998,7 @@ VAStatus vaUnmapBuffer (
/*
* 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,
@@ -983,16 +1018,17 @@ The Begin/Render/End sequence sends the decode buffers to the server
*/
VAStatus vaBeginPicture (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
);
/*
* Send decode buffers to the server.
+ * Buffers are automatically destroyed afterwards
*/
VAStatus vaRenderPicture (
VADisplay dpy,
- VAContext *context,
+ VAContextID context,
VABufferID *buffers,
int num_buffers
);
@@ -1005,7 +1041,7 @@ VAStatus vaRenderPicture (
*/
VAStatus vaEndPicture (
VADisplay dpy,
- VAContext *context
+ VAContextID context
);
/*
@@ -1021,8 +1057,8 @@ Synchronization
*/
VAStatus vaSyncSurface (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
);
typedef enum
@@ -1039,8 +1075,7 @@ typedef enum
*/
VAStatus vaQuerySurfaceStatus (
VADisplay dpy,
- VAContext *context,
- VASurface *render_target,
+ VASurfaceID render_target,
VASurfaceStatus *status /* out */
);
@@ -1051,7 +1086,7 @@ VAStatus vaQuerySurfaceStatus (
* Caller should free the returned buffer with free() when done.
*/
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
void **buffer, /* out */
unsigned int *stride /* out */
);
@@ -1072,6 +1107,10 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
#define VA_FOURCC_AI44 0x34344149
#define VA_FOURCC_RGBA 0x41424752
+/* byte order */
+#define VA_LSB_FIRST 1
+#define VA_MSB_FIRST 2
+
typedef struct _VAImageFormat
{
unsigned int fourcc;
@@ -1094,28 +1133,38 @@ typedef struct _VAImage
VABufferID buf; /* image data buffer */
/*
* Image data will be stored in a buffer of type VAImageBufferType to facilitate
- * data store on the server side for optimal performance.
- * It is expected that the client will first call vaCreateImage which returns a VAImage
- * structure with the following fields filled by the library. It will then
- * create the "buf" with vaBufferCreate. For PutImage, then client will call
- * vaBufferData() with the image data before calling PutImage, and for GetImage
- * the client will call vaBufferData() with a NULL data pointer, and then call GetImage.
- * After that the client can use the Map/Unmap buffer functions to access the image data.
+ * data store on the server side for optimal performance. The buffer will be
+ * created by the CreateImage function, and proper storage allocated based on the image
+ * size and format. This buffer is managed by the library implementation, and
+ * accessed by the client through the buffer Map/Unmap functions.
*/
unsigned short width;
unsigned short height;
unsigned int data_size;
- unsigned int num_planes;
+ unsigned int num_planes; /* can not be greater than 3 */
/*
- * An array of size num_planes indicating the scanline pitch in bytes.
- * Each plane may have a different pitch.
+ * An array indicating the scanline pitch in bytes for each plane.
+ * Each plane may have a different pitch. Maximum 3 planes for planar formats
*/
- unsigned int *pitches;
+ unsigned int pitches[3];
/*
- * An array of size num_planes indicating the byte offset from
- * the beginning of the image data to the start of each plane.
+ * An array indicating the byte offset from the beginning of the image data
+ * to the start of each plane.
+ */
+ unsigned int offsets[3];
+
+ /* The following fields are only needed for paletted formats */
+ int num_palette_entries; /* set to zero for non-palette images */
+ /*
+ * Each component is one byte and entry_bytes indicates the number of components in
+ * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images
+ */
+ int entry_bytes;
+ /*
+ * An array of ascii characters describing the order of the components within the bytes.
+ * Only entry_bytes characters of the string are used.
*/
- unsigned int *offsets;
+ char component_order[4];
} VAImage;
/* Get maximum number of image formats supported by the implementation */
@@ -1138,11 +1187,9 @@ VAStatus vaQueryImageFormats (
/*
* Create a VAImage structure
* The width and height fields returned in the VAImage structure may get
- * enlarged for some YUV formats. The size of the data buffer that needs
- * to be allocated will be given in the "data_size" field in VAImage.
- * Image data is not allocated by this function. The client should
- * allocate the memory required for the data and fill in the data field after
- * looking at "data_size" returned from this call.
+ * enlarged for some YUV formats. Upon return from this function,
+ * image->buf has been created and proper storage allocated by the library.
+ * The client can access the image through the Map/Unmap calls.
*/
VAStatus vaCreateImage (
VADisplay dpy,
@@ -1157,7 +1204,18 @@ VAStatus vaCreateImage (
*/
VAStatus vaDestroyImage (
VADisplay dpy,
- VAImage *image
+ VAImageID image
+);
+
+VAStatus vaSetImagePalette (
+ VADisplay dpy,
+ VAImageID image,
+ /*
+ * pointer to an array holding the palette data. The size of the array is
+ * num_palette_entries * entry_bytes in size. The order of the components
+ * in the palette is described by the component_order in VAImage struct
+ */
+ unsigned char *palette
);
/*
@@ -1166,22 +1224,26 @@ VAStatus vaDestroyImage (
*/
VAStatus vaGetImage (
VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */
int y,
unsigned int width, /* width and height of the region */
unsigned int height,
- VAImage *image
+ VAImageID image
);
/*
* Copy data from a VAImage to a surface
* Image must be in a format supported by the implementation
+ * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface
+ * shouldn't be rendered into when this is called
+ * The source and destionation width and height are the same and
+ * no scaling is performed with this operation.
*/
VAStatus vaPutImage (
VADisplay dpy,
- VASurface *surface,
- VAImage *image,
+ VASurfaceID surface,
+ VAImageID image,
int src_x,
int src_y,
unsigned int width,
@@ -1199,50 +1261,23 @@ VAStatus vaPutImage (
typedef VAGenericID VASubpictureID;
-typedef struct _VASubpicture
-{
- VASubpictureID subpicture_id; /* uniquely identify this subpicture */
- VASurfaceID surface_id; /* which surface does this subpicture associate with */
- VAImageID image_id;
- /* The following fields are set by the library */
- int num_palette_entries; /* paletted formats only. set to zero for image without palettes */
- /*
- * Each component is one byte and entry_bytes indicates the number of components in
- * each entry (eg. 3 for YUV palette entries). set to zero for image without palettes
- */
- int entry_bytes;
- /*
- * An array of ascii characters describing teh order of the components within the bytes.
- * Only entry_bytes characters of the string are used.
- */
- char component_order[4];
-
- /* chromakey range */
- unsigned int chromakey_min;
- unsigned int chromakey_max;
-
- /* global alpha */
- unsigned int global_alpha;
-
- /* flags */
- unsigned int flags; /* see below */
-} VASubpicture;
-
-/* flags for subpictures */
-#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
-#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
-
/* Get maximum number of subpicture formats supported by the implementation */
int vaMaxNumSubpictureFormats (
VADisplay dpy
);
+/* flags for subpictures */
+#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
+#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
/*
* Query supported subpicture formats
* The caller must provide a "format_list" array that can hold at
* least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
* for each format to indicate additional capabilities for that format. The actual
* number of formats returned in "format_list" is returned in "num_formats".
+ * flags: returned value to indicate addtional capabilities
+ * VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
+ * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
*/
VAStatus vaQuerySubpictureFormats (
VADisplay dpy,
@@ -1256,8 +1291,8 @@ VAStatus vaQuerySubpictureFormats (
*/
VAStatus vaCreateSubpicture (
VADisplay dpy,
- VAImage *image,
- VASubpicture *subpicture /* out */
+ VAImageID image,
+ VASubpictureID *subpicture /* out */
);
/*
@@ -1265,7 +1300,7 @@ VAStatus vaCreateSubpicture (
*/
VAStatus vaDestroySubpicture (
VADisplay dpy,
- VASubpicture *subpicture
+ VASubpictureID subpicture
);
/*
@@ -1274,17 +1309,17 @@ VAStatus vaDestroySubpicture (
*/
VAStatus vaSetSubpictureImage (
VADisplay dpy,
- VASubpicture *subpicture,
- VAImage *image
+ VASubpictureID subpicture,
+ VAImageID image
);
VAStatus vaSetSubpicturePalette (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
- * in the palette is described by the component_order in VASubpicture struct
+ * in the palette is described by the component_order in VAImage struct
*/
unsigned char *palette
);
@@ -1292,12 +1327,18 @@ VAStatus vaSetSubpicturePalette (
/*
* If chromakey is enabled, then the area where the source value falls within
* the chromakey [min, max] range is transparent
+ * The chromakey component format is the following:
+ * For RGB: [0:7] Red [8:15] Blue [16:23] Green
+ * For YUV: [0:7] V [8:15] U [16:23] Y
+ * The chromakey mask can be used to mask out certain components for chromakey
+ * comparision
*/
VAStatus vaSetSubpictureChromakey (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
unsigned int chromakey_min,
- unsigned int chromakey_max
+ unsigned int chromakey_max,
+ unsigned int chromakey_mask
);
/*
@@ -1307,21 +1348,22 @@ VAStatus vaSetSubpictureChromakey (
*/
VAStatus vaSetSubpictureGlobalAlpha (
VADisplay dpy,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
float global_alpha
);
/*
- vaAssociateSubpicture associates the subpicture with the target_surface.
- It defines the region mapping between the subpicture and the target
- surface through source and destination rectangles (with the same width and height).
- Both will be displayed at the next call to vaPutSurface. Additional
- associations before the call to vaPutSurface simply overrides the association.
-*/
+ * vaAssociateSubpicture associates the subpicture with target_surfaces.
+ * It defines the region mapping between the subpicture and the target
+ * surfaces through source and destination rectangles (with the same width and height).
+ * Both will be displayed at the next call to vaPutSurface. Additional
+ * associations before the call to vaPutSurface simply overrides the association.
+ */
VAStatus vaAssociateSubpicture (
VADisplay dpy,
- VASurface *target_surface,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
short dest_x, /* upper left offset in surface */
@@ -1335,6 +1377,16 @@ VAStatus vaAssociateSubpicture (
unsigned int flags
);
+/*
+ * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
+ */
+VAStatus vaDeassociateSubpicture (
+ VADisplay dpy,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces
+);
+
typedef struct _VARectangle
{
short x;
@@ -1358,6 +1410,17 @@ typedef enum
VADisplayAttribContrast = 1,
VADisplayAttribHue = 2,
VADisplayAttribSaturation = 3,
+ /* client can specifiy a background color for the target window */
+ VADisplayAttribBackgroundColor = 4,
+ /*
+ * this is a gettable only attribute. For some implementations that use the
+ * hardware overlay, after PutSurface is called, the surface can not be
+ * re-used until after the subsequent PutSurface call. If this is the case
+ * then the value for this attribute will be set to 1 so that the client
+ * will not attempt to re-use the surface right after returning from a call
+ * to PutSurface.
+ */
+ VADisplayAttribDirectSurface = 5,
} VADisplayAttribType;
/* flags for VADisplayAttribute */
@@ -1473,21 +1536,20 @@ Mostly to demonstrate program flow with no error handling ...
* create surfaces for the current target as well as reference frames
* we can get by with 4 surfaces for MPEG-2
*/
- VASurface surfaces[4];
+ VASurfaceID surfaces[4];
vaCreateSurfaces(dpy, 720, 480, VA_RT_FORMAT_YUV420, 4, surfaces);
/*
* Create a context for this decode pipe
*/
- VAContext context;
+ VAContextID context;
vaCreateContext(dpy, config_id, 720, 480, VA_PROGRESSIVE, surfaces,
4, &context);
/* 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;
@@ -1495,18 +1557,16 @@ Mostly to demonstrate program flow with no error handling ...
/* fill in picture_coding_extension fields here */
vaUnmapBuffer(dpy, picture_buf);
-
/* 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);
/* send the picture and IQ matrix buffers to the server */
- vaBeginPicture(dpy, context, &surfaces[0]);
+ vaBeginPicture(dpy, context, surfaces[0]);
vaRenderPicture(dpy, context, &picture_buf, 1);
vaRenderPicture(dpy, context, &iq_buf, 1);
@@ -1521,8 +1581,7 @@ Mostly to demonstrate program flow with no error handling ...
/* 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 */
@@ -1537,8 +1596,7 @@ Mostly to demonstrate program flow with no error handling ...
/* 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);
@@ -1557,17 +1615,17 @@ Mostly to demonstrate program flow with no error handling ...
vaQuerySubpictureFormats(dpy, sub_formats, &num_formats);
/* Assume that we find AI44 as a subpicture format in sub_formats[0] */
VAImage sub_image;
- VASubpicture subpicture;
- unsigned char sub_data[128][16];
+ VASubpictureID subpicture;
+ unsigned char *sub_data;
/* create an image for the subtitle */
vaCreateImage(dpy, sub_formats, 128, 16, &sub_image);
- vaCreateBuffer(dpy, VAImageBufferType, &sub_image->buf);
+ vaMapBuffer(dpy, sub_image->buf, &sub_data);
/* fill the image data */
- vaBufferData(dpy, sub_image->buf, sub_image->data_size, sub_data);
- vaCreateSubpicture(dpy, &sub_image, &subpicture);
+ vaUnmapBuffer(dpy, sub_image->buf);
+ vaCreateSubpicture(dpy, sub_image, &subpicture);
unsigned char palette[3][16];
/* fill the palette data */
- vaSetSubpicturePalette(dpy, &subpicture, palette);
- vaAssociateSubpicture(dpy, surfaces, &subpicture, 0, 0, 296, 400, 128, 16);
+ vaSetSubpicturePalette(dpy, subpicture, palette);
+ vaAssociateSubpicture(dpy, subpicture, surfaces, 1, 0, 0, 296, 400, 128, 16);
vaPutSurface(dpy, surfaces, win, 0, 0, 720, 480, 100, 100, 640, 480, NULL, 0, 0);
#endif
diff --git a/src/va_backend.h b/src/va_backend.h
index 3ffb113..9304088 100755
--- a/src/va_backend.h
+++ b/src/va_backend.h
@@ -34,28 +34,14 @@
#include <stdlib.h>
+
typedef struct VADriverContext *VADriverContextP;
-struct VADriverContext
+struct VADriverVTable
{
- VADriverContextP pNext;
- Display *x11_dpy;
- int x11_screen;
- int version_major;
- int version_minor;
- int max_profiles;
- int max_entrypoints;
- int max_attributes;
- int max_image_formats;
- int max_subpic_formats;
- int max_display_attributes;
- void *handle; /* dlopen handle */
- void *pDriverData;
- struct
- {
- VAStatus (*vaTerminate) ( VADriverContextP ctx );
+ VAStatus (*vaTerminate) ( VADriverContextP ctx );
- VAStatus (*vaQueryConfigProfiles) (
+ VAStatus (*vaQueryConfigProfiles) (
VADriverContextP ctx,
VAProfile *profile_list, /* out */
int *num_profiles /* out */
@@ -105,12 +91,12 @@ struct VADriverContext
int height,
int format,
int num_surfaces,
- VASurface *surfaces /* out */
+ VASurfaceID *surfaces /* out */
);
- VAStatus (*vaDestroySurface) (
+ VAStatus (*vaDestroySurfaces) (
VADriverContextP ctx,
- VASurface *surface_list,
+ VASurfaceID *surface_list,
int num_surfaces
);
@@ -120,34 +106,30 @@ struct VADriverContext
int picture_width,
int picture_height,
int flag,
- VASurface *render_targets,
+ VASurfaceID *render_targets,
int num_render_targets,
- VAContext *context /* out */
+ VAContextID *context /* out */
);
VAStatus (*vaDestroyContext) (
VADriverContextP ctx,
- VAContext *context
+ VAContextID context
);
VAStatus (*vaCreateBuffer) (
VADriverContextP ctx,
- VABufferType type, /* in */
- VABufferID *buf_desc /* out */
- );
-
- VAStatus (*vaBufferData) (
- VADriverContextP ctx,
- VABufferID buf_id, /* in */
- unsigned int size, /* in */
- unsigned int num_elements, /* in */
- void *data /* in */
+ VAContextID context, /* in */
+ VABufferType type, /* in */
+ unsigned int size, /* in */
+ unsigned int num_elements, /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
);
VAStatus (*vaBufferSetNumElements) (
VADriverContextP ctx,
VABufferID buf_id, /* in */
- unsigned int num_elements /* in */
+ unsigned int num_elements /* in */
);
VAStatus (*vaMapBuffer) (
@@ -168,38 +150,37 @@ struct VADriverContext
VAStatus (*vaBeginPicture) (
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
);
VAStatus (*vaRenderPicture) (
VADriverContextP ctx,
- VAContext *context,
+ VAContextID context,
VABufferID *buffers,
int num_buffers
);
VAStatus (*vaEndPicture) (
VADriverContextP ctx,
- VAContext *context
+ VAContextID context
);
VAStatus (*vaSyncSurface) (
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target
+ VAContextID context,
+ VASurfaceID render_target
);
VAStatus (*vaQuerySurfaceStatus) (
VADriverContextP ctx,
- VAContext *context,
- VASurface *render_target,
+ VASurfaceID render_target,
VASurfaceStatus *status /* out */
);
VAStatus (*vaPutSurface) (
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
Drawable draw, /* X Drawable */
short srcx,
short srcy,
@@ -230,23 +211,34 @@ struct VADriverContext
VAStatus (*vaDestroyImage) (
VADriverContextP ctx,
- VAImage *image
+ VAImageID image
);
-
+
+ VAStatus (*vaSetImagePalette) (
+ VADriverContextP ctx,
+ VAImageID image,
+ /*
+ * pointer to an array holding the palette data. The size of the array is
+ * num_palette_entries * entry_bytes in size. The order of the components
+ * in the palette is described by the component_order in VAImage struct
+ */
+ unsigned char *palette
+ );
+
VAStatus (*vaGetImage) (
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */
int y,
unsigned int width, /* width and height of the region */
unsigned int height,
- VAImage *image
+ VAImageID image
);
VAStatus (*vaPutImage) (
VADriverContextP ctx,
- VASurface *surface,
- VAImage *image,
+ VASurfaceID surface,
+ VAImageID image,
int src_x,
int src_y,
unsigned int width,
@@ -264,24 +256,24 @@ struct VADriverContext
VAStatus (*vaCreateSubpicture) (
VADriverContextP ctx,
- VAImage *image,
- VASubpicture *subpicture /* out */
+ VAImageID image,
+ VASubpictureID *subpicture /* out */
);
VAStatus (*vaDestroySubpicture) (
VADriverContextP ctx,
- VASubpicture *subpicture
+ VASubpictureID subpicture
);
VAStatus (*vaSetSubpictureImage) (
VADriverContextP ctx,
- VASubpicture *subpicture,
- VAImage *image
+ VASubpictureID subpicture,
+ VAImageID image
);
VAStatus (*vaSetSubpicturePalette) (
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
@@ -292,21 +284,23 @@ struct VADriverContext
VAStatus (*vaSetSubpictureChromakey) (
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
unsigned int chromakey_min,
- unsigned int chromakey_max
+ unsigned int chromakey_max,
+ unsigned int chromakey_mask
);
VAStatus (*vaSetSubpictureGlobalAlpha) (
VADriverContextP ctx,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
float global_alpha
);
VAStatus (*vaAssociateSubpicture) (
VADriverContextP ctx,
- VASurface *target_surface,
- VASubpicture *subpicture,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
short dest_x, /* upper left offset in surface */
@@ -320,6 +314,13 @@ struct VADriverContext
unsigned int flags
);
+ VAStatus (*vaDeassociateSubpicture) (
+ VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces
+ );
+
VAStatus (*vaQueryDisplayAttributes) (
VADriverContextP ctx,
VADisplayAttribute *attr_list, /* out */
@@ -341,12 +342,33 @@ struct VADriverContext
VAStatus (*vaDbgCopySurfaceToBuffer) (
VADriverContextP ctx,
- VASurface *surface,
+ VASurfaceID surface,
void **buffer, /* out */
unsigned int *stride /* out */
);
+};
+
+struct VADriverContext
+{
+ VADriverContextP pNext;
+
+ void *pDriverData;
+ struct VADriverVTable vtable;
- } vtable;
+ Display *x11_dpy;
+ int x11_screen;
+
+ int version_major;
+ int version_minor;
+ int max_profiles;
+ int max_entrypoints;
+ int max_attributes;
+ int max_image_formats;
+ int max_subpic_formats;
+ int max_display_attributes;
+ const char *str_vendor;
+
+ void *handle; /* dlopen handle */
};
typedef VAStatus (*VADriverInit) (
diff --git a/src/va_x11.h b/src/va_x11.h
index 58b312f..fdb91ba 100755
--- a/src/va_x11.h
+++ b/src/va_x11.h
@@ -36,9 +36,16 @@ extern "C" {
#define VA_TOP_FIELD 0x00000001
#define VA_BOTTOM_FIELD 0x00000002
#define VA_FRAME_PICTURE 0x00000004 /* weave */
+/*
+ * clears the drawable with background color.
+ * for hardware overlay based implementation this flag
+ * can be used to turn off the overlay
+ */
+#define VA_CLEAR_DRAWABLE 0x00000008
+
VAStatus vaPutSurface (
VADisplay dpy,
- VASurface *surface,
+ VASurfaceID surface,
Drawable draw, /* X Drawable */
short srcx,
short srcy,
diff --git a/test/Makefile.am b/test/Makefile.am
index 13bff08..c2fb501 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,6 +23,8 @@
check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \
test_07 test_08 test_09 test_10 test_11
+bin_PROGRAMS = vainfo
+
testdir = $(bindir)
AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src
@@ -31,6 +33,9 @@ TESTS = $(check_PROGRAMS)
TEST_LIBS = ../src/libva.la
+vainfo_LDADD = ../src/libva.la
+vainfo_SOURCES = vainfo.c
+
test_01_LDADD = $(TEST_LIBS)
test_01_SOURCES = test_01.c
diff --git a/test/test.c b/test/test.c
index 70f3125..b088487 100644
--- a/test/test.c
+++ b/test/test.c
@@ -53,23 +53,23 @@ int main(int argc, const char* argv[])
printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
{
- VASurface surfaces[21];
+ VASurfaceID surfaces[21];
int i;
- surfaces[20].surface_id = -1;
+ surfaces[20] = -1;
va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( -1 == surfaces[20].surface_id ); /* bounds check */
+ ASSERT( -1 == surfaces[20] ); /* bounds check */
for(i = 0; i < 20; i++)
{
- printf("Surface %d surface_id = %08x\n", i, surfaces[i].surface_id);
+ printf("Surface %d surface_id = %08x\n", i, surfaces[i]);
}
Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0));
printf("Window = %08x\n", win);
XMapWindow(dpy, win);
XSync(dpy, False);
- vaPutSurface(va_dpy, &(surfaces[0]), win, 0, 0, 720, 480, 0, 0, 720, 480, 0);
+ vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0);
sleep(10);
va_status = vaDestroySurface(va_dpy, surfaces, 20);
@@ -94,14 +94,14 @@ int main(int argc, const char* argv[])
}
{
- VASurface surfaces[20];
- VAContext context;
+ VASurfaceID surfaces[20];
+ VAContextID context;
VAConfigAttrib attrib;
VAConfigID config_id;
int i;
attrib.type = VAConfigAttribRTFormat;
- va_status = vaQueryConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
+ va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
@@ -118,7 +118,7 @@ int main(int argc, const char* argv[])
va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context);
ASSERT( VA_STATUS_SUCCESS == va_status );
- va_status = vaDestroyContext(va_dpy, &context);
+ va_status = vaDestroyContext(va_dpy, context);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaDestroySurface(va_dpy, surfaces, 20);
diff --git a/test/test_07.c b/test/test_07.c
index 3ae8f01..cb1edce 100644
--- a/test/test_07.c
+++ b/test/test_07.c
@@ -33,7 +33,7 @@ void pre()
#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead
-void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurface *surface_list2, int surface_count2)
+void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2)
{
int i,j;
@@ -42,9 +42,9 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac
for(j = 0; j < surface_count2; j++)
{
if ((surface_list1 == surface_list2) && (i == j)) continue;
- ASSERT(surface_list1[i].surface_id != VA_INVALID_SURFACE);
- ASSERT(surface_list2[j].surface_id != VA_INVALID_SURFACE);
- ASSERT(surface_list1[i].surface_id != surface_list2[j].surface_id);
+ ASSERT(surface_list1[i] != VA_INVALID_SURFACE);
+ ASSERT(surface_list2[j] != VA_INVALID_SURFACE);
+ ASSERT(surface_list1[i] != surface_list2[j]);
}
}
}
@@ -52,10 +52,10 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac
void test()
{
- VASurface surfaces_1[1+1];
- VASurface surfaces_4[4+1];
- VASurface surfaces_16[16+1];
- VASurface surfaces_6[6+1];
+ VASurfaceID surfaces_1[1+1];
+ VASurfaceID surfaces_4[4+1];
+ VASurfaceID surfaces_16[16+1];
+ VASurfaceID surfaces_6[6+1];
memset(surfaces_1, 0xff, sizeof(surfaces_1));
memset(surfaces_4, 0xff, sizeof(surfaces_4));
@@ -63,22 +63,22 @@ void test()
memset(surfaces_6, 0xff, sizeof(surfaces_6));
status("vaCreateSurfaces 1 surface\n");
- surfaces_1[1].surface_id = DEAD_SURFACE_ID;
+ surfaces_1[1] = DEAD_SURFACE_ID;
va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( DEAD_SURFACE_ID == surfaces_1[1].surface_id ); /* bounds check */
+ ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */
status("vaCreateSurfaces 4 surfaces\n");
- surfaces_4[4].surface_id = DEAD_SURFACE_ID;
+ surfaces_4[4] = DEAD_SURFACE_ID;
va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( DEAD_SURFACE_ID == surfaces_4[4].surface_id ); /* bounds check */
+ ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */
status("vaCreateSurfaces 16 surfaces\n");
- surfaces_16[16].surface_id = DEAD_SURFACE_ID;
+ surfaces_16[16] = DEAD_SURFACE_ID;
va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( DEAD_SURFACE_ID == surfaces_16[16].surface_id ); /* bounds check */
+ ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */
test_unique_surfaces(surfaces_1, 1, surfaces_4, 4);
test_unique_surfaces(surfaces_4, 4, surfaces_16, 4);
@@ -87,29 +87,29 @@ void test()
test_unique_surfaces(surfaces_1, 16, surfaces_16, 16);
status("vaDestroySurface 4 surfaces\n");
- va_status = vaDestroySurface(va_dpy, surfaces_4, 4);
+ va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4);
ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaCreateSurfaces 6 surfaces\n");
- surfaces_6[6].surface_id = DEAD_SURFACE_ID;
+ surfaces_6[6] = DEAD_SURFACE_ID;
va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( DEAD_SURFACE_ID == surfaces_6[6].surface_id ); /* bounds check */
+ ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */
test_unique_surfaces(surfaces_1, 1, surfaces_6, 6);
test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
test_unique_surfaces(surfaces_1, 6, surfaces_16, 6);
status("vaDestroySurface 16 surfaces\n");
- va_status = vaDestroySurface(va_dpy, surfaces_16, 16);
+ va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16);
ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaDestroySurface 1 surface\n");
- va_status = vaDestroySurface(va_dpy, surfaces_1, 1);
+ va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaDestroySurface 6 surfaces\n");
- va_status = vaDestroySurface(va_dpy, surfaces_6, 6);
+ va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6);
ASSERT( VA_STATUS_SUCCESS == va_status );
}
diff --git a/test/test_08.c b/test/test_08.c
index ce4932d..8c743b6 100644
--- a/test/test_08.c
+++ b/test/test_08.c
@@ -33,17 +33,17 @@ void pre()
#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead
-void test_unique_surfaces(VASurface *surface_list, int surface_count)
+void test_unique_surfaces(VASurfaceID *surface_list, int surface_count)
{
int i,j;
for(i = 0; i < surface_count; i++)
{
- ASSERT(surface_list[i].surface_id != VA_INVALID_SURFACE);
+ ASSERT(surface_list[i] != VA_INVALID_SURFACE);
for(j = 0; j < i; j++)
{
if (i == j) continue;
- ASSERT(surface_list[i].surface_id != surface_list[j].surface_id);
+ ASSERT(surface_list[i] != surface_list[j]);
}
}
}
@@ -65,7 +65,7 @@ test_size_t test_sizes[] = {
void test()
{
- VASurface surfaces[NUM_SIZES+1];
+ VASurfaceID surfaces[NUM_SIZES+1];
int i;
memset(surfaces, 0xff, sizeof(surfaces));
@@ -73,16 +73,16 @@ void test()
for(i = 0; i < NUM_SIZES; i++)
{
status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h);
- surfaces[i+1].surface_id = DEAD_SURFACE_ID;
+ surfaces[i+1] = DEAD_SURFACE_ID;
va_status = vaCreateSurfaces(va_dpy, test_sizes[i].w, test_sizes[i].h, VA_RT_FORMAT_YUV420, 1, &surfaces[i]);
ASSERT( VA_STATUS_SUCCESS == va_status );
- ASSERT( DEAD_SURFACE_ID == surfaces[i+1].surface_id );
+ ASSERT( DEAD_SURFACE_ID == surfaces[i+1] );
}
test_unique_surfaces(surfaces, NUM_SIZES);
status("vaDestroySurface all surfaces\n");
- va_status = vaDestroySurface(va_dpy, surfaces, NUM_SIZES);
+ va_status = vaDestroySurfaces(va_dpy, surfaces, NUM_SIZES);
ASSERT( VA_STATUS_SUCCESS == va_status );
}
diff --git a/test/test_09.c b/test/test_09.c
index c3d5b18..7d6cd4b 100644
--- a/test/test_09.c
+++ b/test/test_09.c
@@ -44,7 +44,7 @@ void test()
ASSERT(entrypoints);
VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID));
- VAContext *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContext));
+ VAContextID *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContextID));
for(i = 0; i < num_profiles; i++)
{
@@ -66,7 +66,7 @@ void test()
int surface_count = 4;
int total_surfaces = config_count * surface_count;
- VASurface *surfaces = malloc(total_surfaces * sizeof(VASurface));
+ VASurfaceID *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);
@@ -82,8 +82,8 @@ void test()
for(i = 0; i < config_count; i++)
{
- status("vaDestroyContext for context %08x\n", contexts[i].context_id);
- va_status = vaDestroyContext( va_dpy, &contexts[i] );
+ status("vaDestroyContext for context %08x\n", contexts[i]);
+ va_status = vaDestroyContext( va_dpy, contexts[i] );
ASSERT( VA_STATUS_SUCCESS == va_status );
}
@@ -94,7 +94,7 @@ void test()
ASSERT( VA_STATUS_SUCCESS == va_status );
}
- va_status = vaDestroySurface(va_dpy, surfaces, total_surfaces);
+ va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
ASSERT( VA_STATUS_SUCCESS == va_status );
free(contexts);
diff --git a/test/test_10.c b/test/test_10.c
index 3158184..6a7b978 100644
--- a/test/test_10.c
+++ b/test/test_10.c
@@ -26,9 +26,34 @@
#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)
@@ -55,9 +80,22 @@ VABufferType buffer_types[] =
VAMacroblockParameterBufferType,
VAResidualDataBufferType,
VADeblockingParameterBufferType,
- VAImageBufferType
};
+unsigned int buffer_sizes[] =
+{
+ sizeof(VAPictureParameterBufferMPEG4),
+ sizeof(VAIQMatrixBufferH264),
+ 32*1024,
+ 48*1024,
+ sizeof(VASliceParameterBufferMPEG2),
+ 128*1024,
+ sizeof(VAMacroblockParameterBufferMPEG2),
+ 32*1024,
+ 15*1024,
+};
+
+
#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType))
#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff)
@@ -70,7 +108,7 @@ void test()
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 */
}
@@ -85,5 +123,18 @@ void test()
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();
}
diff --git a/test/test_11.c b/test/test_11.c
index 53a1bd5..8f3c4b8 100644
--- a/test/test_11.c
+++ b/test/test_11.c
@@ -26,9 +26,47 @@
#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[] =
@@ -42,7 +80,6 @@ VABufferType buffer_types[] =
VAMacroblockParameterBufferType,
VAResidualDataBufferType,
VADeblockingParameterBufferType,
- VAImageBufferType
};
unsigned int buffer_sizes[] =
@@ -56,11 +93,13 @@ unsigned int buffer_sizes[] =
sizeof(VAMacroblockParameterBufferMPEG2),
32*1024,
15*1024,
- 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];
@@ -70,9 +109,6 @@ void test()
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]);
@@ -88,9 +124,10 @@ void test()
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]);
@@ -101,9 +138,6 @@ void test()
{
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]);
@@ -124,7 +158,22 @@ void test()
}
}
+
+
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();
}
diff --git a/test/vainfo.c b/test/vainfo.c
new file mode 100644
index 0000000..a793e14
--- /dev/null
+++ b/test/vainfo.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "va.h"
+#include "X11/Xlib.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int main(int argc, const char* argv[])
+{
+ Display *dpy;
+ VADisplay va_dpy;
+ VAStatus va_status;
+ int major_version, minor_version;
+ const char *driver;
+ const char *display = getenv("DISPLAY");
+ const char *name = rindex(argv[0], '/');
+
+ if (name)
+ name++;
+ else
+ name = argv[0];
+
+ dpy = XOpenDisplay(NULL);
+ if (NULL == dpy)
+ {
+ fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
+ return 1;
+ }
+
+ va_dpy = vaGetDisplay(dpy);
+ if (NULL == va_dpy)
+ {
+ fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
+ return 2;
+ }
+
+ va_status = vaInitialize(va_dpy, &major_version, &minor_version);
+ if (VA_STATUS_SUCCESS != va_status )
+ {
+ fprintf(stderr, "%s: vaInitialize failed with error code %d (%s)\n",
+ name, va_status, vaErrorStr(va_status));
+ }
+ printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
+ driver = vaQueryVendorString(va_dpy);
+ printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
+ vaTerminate(va_dpy);
+ return 0;
+}