Commit 4a9db082 authored by Waldo Bastian's avatar Waldo Bastian

Update to VA API v0.25

parent 12e8a228
...@@ -366,7 +366,7 @@ VAStatus dummy_CreateSurfaces( ...@@ -366,7 +366,7 @@ VAStatus dummy_CreateSurfaces(
int height, int height,
int format, int format,
int num_surfaces, int num_surfaces,
VASurface *surfaces /* out */ VASurfaceID *surfaces /* out */
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -388,13 +388,8 @@ VAStatus dummy_CreateSurfaces( ...@@ -388,13 +388,8 @@ VAStatus dummy_CreateSurfaces(
vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
break; break;
} }
obj_surface->surface = &(surfaces[i]); obj_surface->surface_id = surfaceID;
obj_surface->surface->surface_id = surfaceID; surfaces[i] = 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;
} }
/* Error recovery */ /* Error recovery */
...@@ -403,8 +398,8 @@ VAStatus dummy_CreateSurfaces( ...@@ -403,8 +398,8 @@ VAStatus dummy_CreateSurfaces(
/* surfaces[i-1] was the last successful allocation */ /* surfaces[i-1] was the last successful allocation */
for(; i--; ) for(; i--; )
{ {
object_surface_p obj_surface = SURFACE(surfaces[i].surface_id); object_surface_p obj_surface = SURFACE(surfaces[i]);
surfaces[i].surface_id = -1; surfaces[i] = VA_INVALID_SURFACE;
ASSERT(obj_surface); ASSERT(obj_surface);
object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
} }
...@@ -413,9 +408,9 @@ VAStatus dummy_CreateSurfaces( ...@@ -413,9 +408,9 @@ VAStatus dummy_CreateSurfaces(
return vaStatus; return vaStatus;
} }
VAStatus dummy_DestroySurface( VAStatus dummy_DestroySurfaces(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface_list, VASurfaceID *surface_list,
int num_surfaces int num_surfaces
) )
{ {
...@@ -423,7 +418,7 @@ VAStatus dummy_DestroySurface( ...@@ -423,7 +418,7 @@ VAStatus dummy_DestroySurface(
int i; int i;
for(i = num_surfaces; 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); ASSERT(obj_surface);
object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
} }
...@@ -458,7 +453,19 @@ VAStatus dummy_CreateImage( ...@@ -458,7 +453,19 @@ VAStatus dummy_CreateImage(
VAStatus dummy_DestroyImage( VAStatus dummy_DestroyImage(
VADriverContextP ctx, 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 INIT_DRIVER_DATA
...@@ -469,12 +476,12 @@ VAStatus dummy_DestroyImage( ...@@ -469,12 +476,12 @@ VAStatus dummy_DestroyImage(
VAStatus dummy_GetImage( VAStatus dummy_GetImage(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */ int x, /* coordinates of the upper left source pixel */
int y, int y,
unsigned int width, /* width and height of the region */ unsigned int width, /* width and height of the region */
unsigned int height, unsigned int height,
VAImage *image VAImageID image
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -485,8 +492,8 @@ VAStatus dummy_GetImage( ...@@ -485,8 +492,8 @@ VAStatus dummy_GetImage(
VAStatus dummy_PutImage( VAStatus dummy_PutImage(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
VAImage *image, VAImageID image,
int src_x, int src_x,
int src_y, int src_y,
unsigned int width, unsigned int width,
...@@ -516,8 +523,8 @@ VAStatus dummy_QuerySubpictureFormats( ...@@ -516,8 +523,8 @@ VAStatus dummy_QuerySubpictureFormats(
VAStatus dummy_CreateSubpicture( VAStatus dummy_CreateSubpicture(
VADriverContextP ctx, VADriverContextP ctx,
VAImage *image, VAImageID image,
VASubpicture *subpicture /* out */ VASubpictureID *subpicture /* out */
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -528,7 +535,7 @@ VAStatus dummy_CreateSubpicture( ...@@ -528,7 +535,7 @@ VAStatus dummy_CreateSubpicture(
VAStatus dummy_DestroySubpicture( VAStatus dummy_DestroySubpicture(
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture VASubpictureID subpicture
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -539,8 +546,8 @@ VAStatus dummy_DestroySubpicture( ...@@ -539,8 +546,8 @@ VAStatus dummy_DestroySubpicture(
VAStatus dummy_SetSubpictureImage( VAStatus dummy_SetSubpictureImage(
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
VAImage *image VAImageID image
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -551,7 +558,7 @@ VAStatus dummy_SetSubpictureImage( ...@@ -551,7 +558,7 @@ VAStatus dummy_SetSubpictureImage(
VAStatus dummy_SetSubpicturePalette( VAStatus dummy_SetSubpicturePalette(
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
/* /*
* pointer to an array holding the palette data. The size of the array is * 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 * num_palette_entries * entry_bytes in size. The order of the components
...@@ -568,9 +575,10 @@ VAStatus dummy_SetSubpicturePalette( ...@@ -568,9 +575,10 @@ VAStatus dummy_SetSubpicturePalette(
VAStatus dummy_SetSubpictureChromakey( VAStatus dummy_SetSubpictureChromakey(
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
unsigned int chromakey_min, unsigned int chromakey_min,
unsigned int chromakey_max unsigned int chromakey_max,
unsigned int chromakey_mask
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -581,7 +589,7 @@ VAStatus dummy_SetSubpictureChromakey( ...@@ -581,7 +589,7 @@ VAStatus dummy_SetSubpictureChromakey(
VAStatus dummy_SetSubpictureGlobalAlpha( VAStatus dummy_SetSubpictureGlobalAlpha(
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
float global_alpha float global_alpha
) )
{ {
...@@ -593,8 +601,9 @@ VAStatus dummy_SetSubpictureGlobalAlpha( ...@@ -593,8 +601,9 @@ VAStatus dummy_SetSubpictureGlobalAlpha(
VAStatus dummy_AssociateSubpicture( VAStatus dummy_AssociateSubpicture(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *target_surface, VASubpictureID subpicture,
VASubpicture *subpicture, VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */ short src_x, /* upper left offset in subpicture */
short src_y, short src_y,
short dest_x, /* upper left offset in surface */ short dest_x, /* upper left offset in surface */
...@@ -614,15 +623,28 @@ VAStatus dummy_AssociateSubpicture( ...@@ -614,15 +623,28 @@ VAStatus dummy_AssociateSubpicture(
return VA_STATUS_SUCCESS; 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( VAStatus dummy_CreateContext(
VADriverContextP ctx, VADriverContextP ctx,
VAConfigID config_id, VAConfigID config_id,
int picture_width, int picture_width,
int picture_height, int picture_height,
int flag, int flag,
VASurface *render_targets, VASurfaceID *render_targets,
int num_render_targets, int num_render_targets,
VAContext *context /* out */ VAContextID *context /* out */
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -648,41 +670,34 @@ VAStatus dummy_CreateContext( ...@@ -648,41 +670,34 @@ VAStatus dummy_CreateContext(
return vaStatus; return vaStatus;
} }
obj_context->context = context; obj_context->context_id = contextID;
*context = contextID;
obj_context->current_render_target = -1; obj_context->current_render_target = -1;
obj_context->config_id = config_id;
obj_context->context->context_id = contextID; obj_context->picture_width = picture_width;
obj_context->context->config_id = config_id; obj_context->picture_height = picture_height;
obj_context->context->picture_width = picture_width; obj_context->num_render_targets = num_render_targets;
obj_context->context->picture_height = picture_height; obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
obj_context->context->num_render_targets = num_render_targets;
obj_context->context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
for(i = 0; i < num_render_targets; i++) 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; vaStatus = VA_STATUS_ERROR_INVALID_SURFACE;
break; 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->flags = flag;
obj_context->context->privData = NULL;
/* Error recovery */ /* Error recovery */
if (VA_STATUS_SUCCESS != vaStatus) if (VA_STATUS_SUCCESS != vaStatus)
{ {
free(obj_context->context->render_targets); obj_context->context_id = -1;
obj_context->context->render_targets = NULL; obj_context->config_id = -1;
obj_context->context->context_id = -1; free(obj_context->render_targets);
obj_context->context->config_id = -1; obj_context->render_targets = NULL;
obj_context->context->picture_width = 0; obj_context->num_render_targets = 0;
obj_context->context->picture_height = 0; obj_context->flags = 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;
object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
} }
...@@ -692,27 +707,25 @@ VAStatus dummy_CreateContext( ...@@ -692,27 +707,25 @@ VAStatus dummy_CreateContext(
VAStatus dummy_DestroyContext( VAStatus dummy_DestroyContext(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context VAContextID context
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
object_context_p obj_context = CONTEXT(context->context_id); object_context_p obj_context = CONTEXT(context);
ASSERT(obj_context); ASSERT(obj_context);
obj_context->context->context_id = -1; obj_context->context_id = -1;
obj_context->context->config_id = -1; obj_context->config_id = -1;
obj_context->context->picture_width = 0; obj_context->picture_width = 0;
obj_context->context->picture_height = 0; obj_context->picture_height = 0;
if (obj_context->context->render_targets) if (obj_context->render_targets)
{ {
free(obj_context->context->render_targets); free(obj_context->render_targets);
} }
obj_context->context->render_targets = NULL; obj_context->render_targets = NULL;
obj_context->context->num_render_targets = 0; obj_context->num_render_targets = 0;
obj_context->context->flags = 0; obj_context->flags = 0;
obj_context->context->privData = NULL;
obj_context->context = NULL;
obj_context->current_render_target = -1; obj_context->current_render_target = -1;
object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
...@@ -888,8 +901,8 @@ VAStatus dummy_DestroyBuffer( ...@@ -888,8 +901,8 @@ VAStatus dummy_DestroyBuffer(
VAStatus dummy_BeginPicture( VAStatus dummy_BeginPicture(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -897,10 +910,10 @@ VAStatus dummy_BeginPicture( ...@@ -897,10 +910,10 @@ VAStatus dummy_BeginPicture(
object_context_p obj_context; object_context_p obj_context;
object_surface_p obj_surface; object_surface_p obj_surface;
obj_context = CONTEXT(context->context_id); obj_context = CONTEXT(context);
ASSERT(obj_context); ASSERT(obj_context);
obj_surface = SURFACE(render_target->surface_id); obj_surface = SURFACE(render_target);
ASSERT(obj_surface); ASSERT(obj_surface);
obj_context->current_render_target = obj_surface->base.id; obj_context->current_render_target = obj_surface->base.id;
...@@ -910,7 +923,7 @@ VAStatus dummy_BeginPicture( ...@@ -910,7 +923,7 @@ VAStatus dummy_BeginPicture(
VAStatus dummy_RenderPicture( VAStatus dummy_RenderPicture(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VABufferID *buffers, VABufferID *buffers,
int num_buffers int num_buffers
) )
...@@ -921,7 +934,7 @@ VAStatus dummy_RenderPicture( ...@@ -921,7 +934,7 @@ VAStatus dummy_RenderPicture(
object_surface_p obj_surface; object_surface_p obj_surface;
int i; int i;
obj_context = CONTEXT(context->context_id); obj_context = CONTEXT(context);
ASSERT(obj_context); ASSERT(obj_context);
obj_surface = SURFACE(obj_context->current_render_target); obj_surface = SURFACE(obj_context->current_render_target);
...@@ -944,7 +957,7 @@ VAStatus dummy_RenderPicture( ...@@ -944,7 +957,7 @@ VAStatus dummy_RenderPicture(
VAStatus dummy_EndPicture( VAStatus dummy_EndPicture(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context VAContextID context
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -952,7 +965,7 @@ VAStatus dummy_EndPicture( ...@@ -952,7 +965,7 @@ VAStatus dummy_EndPicture(
object_context_p obj_context; object_context_p obj_context;
object_surface_p obj_surface; object_surface_p obj_surface;
obj_context = CONTEXT(context->context_id); obj_context = CONTEXT(context);
ASSERT(obj_context); ASSERT(obj_context);
obj_surface = SURFACE(obj_context->current_render_target); obj_surface = SURFACE(obj_context->current_render_target);
...@@ -967,8 +980,8 @@ VAStatus dummy_EndPicture( ...@@ -967,8 +980,8 @@ VAStatus dummy_EndPicture(
VAStatus dummy_SyncSurface( VAStatus dummy_SyncSurface(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
...@@ -976,10 +989,10 @@ VAStatus dummy_SyncSurface( ...@@ -976,10 +989,10 @@ VAStatus dummy_SyncSurface(
object_context_p obj_context; object_context_p obj_context;
object_surface_p obj_surface; object_surface_p obj_surface;
obj_context = CONTEXT(context->context_id); obj_context = CONTEXT(context);
ASSERT(obj_context); ASSERT(obj_context);
obj_surface = SURFACE(render_target->surface_id); obj_surface = SURFACE(render_target);
ASSERT(obj_surface); ASSERT(obj_surface);
/* Assume that this shouldn't be called before vaEndPicture() */ /* Assume that this shouldn't be called before vaEndPicture() */
...@@ -990,38 +1003,25 @@ VAStatus dummy_SyncSurface( ...@@ -990,38 +1003,25 @@ VAStatus dummy_SyncSurface(
VAStatus dummy_QuerySurfaceStatus( VAStatus dummy_QuerySurfaceStatus(
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VASurfaceID render_target,
VASurface *render_target,
VASurfaceStatus *status /* out */ VASurfaceStatus *status /* out */
) )
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
object_context_p obj_context;
object_surface_p obj_surface; object_surface_p obj_surface;
obj_context = CONTEXT(context->context_id); obj_surface = SURFACE(render_target);
ASSERT(obj_context);
obj_surface = SURFACE(render_target->surface_id);
ASSERT(obj_surface); 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; return vaStatus;
} }
VAStatus dummy_PutSurface( VAStatus dummy_PutSurface(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
Drawable draw, /* X Drawable */ Drawable draw, /* X Drawable */
short srcx, short srcx,
short srcy, short srcy,
...@@ -1091,7 +1091,7 @@ VAStatus dummy_SetDisplayAttributes ( ...@@ -1091,7 +1091,7 @@ VAStatus dummy_SetDisplayAttributes (
VAStatus dummy_DbgCopySurfaceToBuffer( VAStatus dummy_DbgCopySurfaceToBuffer(
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
void **buffer, /* out */ void **buffer, /* out */
unsigned int *stride /* out */ unsigned int *stride /* out */
) )
...@@ -1140,7 +1140,7 @@ VAStatus dummy_Terminate( VADriverContextP ctx ) ...@@ -1140,7 +1140,7 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) VAStatus __vaDriverInit_0_25( VADriverContextP ctx )
{ {
object_base_p obj; object_base_p obj;
int result; int result;
...@@ -1148,13 +1148,14 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ...@@ -1148,13 +1148,14 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
int i; int i;
ctx->version_major = 0; ctx->version_major = 0;
ctx->version_minor = 24; ctx->version_minor = 25;
ctx->max_profiles = DUMMY_MAX_PROFILES; ctx->max_profiles = DUMMY_MAX_PROFILES;
ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS; ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES; ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS; ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS;
ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS; ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS;
ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES; ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES;
ctx->str_vendor = DUMMY_STR_VENDOR;
ctx->vtable.vaTerminate = dummy_Terminate; ctx->vtable.vaTerminate = dummy_Terminate;
ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
...@@ -1165,7 +1166,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ...@@ -1165,7 +1166,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaDestroyConfig = dummy_DestroyConfig; ctx->vtable.vaDestroyConfig = dummy_DestroyConfig;
ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes; ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes;
ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces; ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces;
ctx->vtable.vaDestroySurface = dummy_DestroySurface; ctx->vtable.vaDestroySurfaces = dummy_DestroySurfaces;
ctx->vtable.vaCreateContext = dummy_CreateContext; ctx->vtable.vaCreateContext = dummy_CreateContext;
ctx->vtable.vaDestroyContext = dummy_DestroyContext; ctx->vtable.vaDestroyContext = dummy_DestroyContext;
ctx->vtable.vaCreateBuffer = dummy_CreateBuffer; ctx->vtable.vaCreateBuffer = dummy_CreateBuffer;
...@@ -1183,6 +1184,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ...@@ -1183,6 +1184,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats; ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats;
ctx->vtable.vaCreateImage = dummy_CreateImage; ctx->vtable.vaCreateImage = dummy_CreateImage;
ctx->vtable.vaDestroyImage = dummy_DestroyImage; ctx->vtable.vaDestroyImage = dummy_DestroyImage;
ctx->vtable.vaSetImagePalette = dummy_SetImagePalette;
ctx->vtable.vaGetImage = dummy_GetImage; ctx->vtable.vaGetImage = dummy_GetImage;
ctx->vtable.vaPutImage = dummy_PutImage; ctx->vtable.vaPutImage = dummy_PutImage;
ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats; ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
...@@ -1193,6 +1195,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ...@@ -1193,6 +1195,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx )
ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey; ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha; ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture; ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
ctx->vtable.vaDeassociateSubpicture = dummy_DeassociateSubpicture;
ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes; ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes;
ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes; ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes;
ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes; ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define DUMMY_MAX_IMAGE_FORMATS 10 #define DUMMY_MAX_IMAGE_FORMATS 10
#define DUMMY_MAX_SUBPIC_FORMATS 4 #define DUMMY_MAX_SUBPIC_FORMATS 4
#define DUMMY_MAX_DISPLAY_ATTRIBUTES 4 #define DUMMY_MAX_DISPLAY_ATTRIBUTES 4
#define DUMMY_STR_VENDOR "Dummy-dummy-1.0-dummy"
struct dummy_driver_data { struct dummy_driver_data {
struct object_heap config_heap; struct object_heap config_heap;
...@@ -52,14 +53,19 @@ struct object_config { ...@@ -52,14 +53,19 @@ struct object_config {
struct object_context { struct object_context {
struct object_base base; struct object_base base;
VAContext *context; VAContextID context_id;
VAConfigID config; VAConfigID config_id;
VASurfaceID current_render_target; VASurfaceID current_render_target;
int picture_width;
int picture_height;
int num_render_targets;
int flags;
VASurfaceID *render_targets;
}; };
struct object_surface { struct object_surface {
struct object_base base; struct object_base base;
VASurface *surface; VASurfaceID surface_id;
}; };
struct object_buffer { struct object_buffer {
......
...@@ -36,13 +36,14 @@ ...@@ -36,13 +36,14 @@
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri" #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
#define DRIVER_EXTENSION "_drv_video.so" #define DRIVER_EXTENSION "_drv_video.so"
#define DRIVER_INIT_FUNC "__vaDriverInit_0_24" #define DRIVER_INIT_FUNC "__vaDriverInit_0_25"
#define CTX(dpy) ((VADriverContextP) dpy ); #define CTX(dpy) ((VADriverContextP) dpy );
#define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } #define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
#define ASSERT assert #define ASSERT assert
#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; #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_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); #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
...@@ -134,6 +135,16 @@ static Bool va_checkMaximum(int value, char *variable) ...@@ -134,6 +135,16 @@ static Bool va_checkMaximum(int value, char *variable)
return True; 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) static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
{ {
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
...@@ -255,6 +266,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) ...@@ -255,6 +266,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_MAXIMUM(vaStatus, ctx, image_formats); CHECK_MAXIMUM(vaStatus, ctx, image_formats);
CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
CHECK_MAXIMUM(vaStatus, ctx, display_attributes); CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
CHECK_STRING(vaStatus, ctx, vendor);
CHECK_VTABLE(vaStatus, ctx, Terminate); CHECK_VTABLE(vaStatus, ctx, Terminate);
CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
...@@ -263,7 +275,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) ...@@ -263,7 +275,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, DestroyConfig); CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes); CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
CHECK_VTABLE(vaStatus, ctx, CreateSurfaces); CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
CHECK_VTABLE(vaStatus, ctx, DestroySurface); CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
CHECK_VTABLE(vaStatus, ctx, CreateContext); CHECK_VTABLE(vaStatus, ctx, CreateContext);
CHECK_VTABLE(vaStatus, ctx, DestroyContext); CHECK_VTABLE(vaStatus, ctx, DestroyContext);
CHECK_VTABLE(vaStatus, ctx, CreateBuffer); CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
...@@ -281,6 +293,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) ...@@ -281,6 +293,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, QueryImageFormats); CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
CHECK_VTABLE(vaStatus, ctx, CreateImage); CHECK_VTABLE(vaStatus, ctx, CreateImage);
CHECK_VTABLE(vaStatus, ctx, DestroyImage); CHECK_VTABLE(vaStatus, ctx, DestroyImage);
CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
CHECK_VTABLE(vaStatus, ctx, GetImage); CHECK_VTABLE(vaStatus, ctx, GetImage);
CHECK_VTABLE(vaStatus, ctx, PutImage); CHECK_VTABLE(vaStatus, ctx, PutImage);
CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats); CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
...@@ -291,6 +304,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) ...@@ -291,6 +304,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey); CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha); CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture); CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes); CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes); CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
...@@ -429,6 +443,28 @@ VAStatus vaTerminate ( ...@@ -429,6 +443,28 @@ VAStatus vaTerminate (
return vaStatus; 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 */ /* Get maximum number of profiles supported by the implementation */
int vaMaxNumProfiles ( int vaMaxNumProfiles (
VADisplay dpy VADisplay dpy
...@@ -564,7 +600,7 @@ VAStatus vaCreateSurfaces ( ...@@ -564,7 +600,7 @@ VAStatus vaCreateSurfaces (
int height, int height,
int format, int format,
int num_surfaces, int num_surfaces,
VASurface *surfaces /* out */ VASurfaceID *surfaces /* out */
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -574,17 +610,17 @@ VAStatus vaCreateSurfaces ( ...@@ -574,17 +610,17 @@ VAStatus vaCreateSurfaces (
return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces ); return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
} }
VAStatus vaDestroySurface ( VAStatus vaDestroySurfaces (
VADisplay dpy, VADisplay dpy,
VASurface *surface_list, VASurfaceID *surface_list,
int num_surfaces int num_surfaces
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroySurface); TRACE(vaDestroySurfaces);
return ctx->vtable.vaDestroySurface( ctx, surface_list, num_surfaces ); return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
} }
VAStatus vaCreateContext ( VAStatus vaCreateContext (
...@@ -593,9 +629,9 @@ VAStatus vaCreateContext ( ...@@ -593,9 +629,9 @@ VAStatus vaCreateContext (
int picture_width, int picture_width,
int picture_height, int picture_height,
int flag, int flag,
VASurface *render_targets, VASurfaceID *render_targets,
int num_render_targets, int num_render_targets,
VAContext *context /* out */ VAContextID *context /* out */
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -608,7 +644,7 @@ VAStatus vaCreateContext ( ...@@ -608,7 +644,7 @@ VAStatus vaCreateContext (
VAStatus vaDestroyContext ( VAStatus vaDestroyContext (
VADisplay dpy, VADisplay dpy,
VAContext *context VAContextID context
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -699,8 +735,8 @@ VAStatus vaDestroyBuffer ( ...@@ -699,8 +735,8 @@ VAStatus vaDestroyBuffer (
VAStatus vaBeginPicture ( VAStatus vaBeginPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -712,7 +748,7 @@ VAStatus vaBeginPicture ( ...@@ -712,7 +748,7 @@ VAStatus vaBeginPicture (
VAStatus vaRenderPicture ( VAStatus vaRenderPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VABufferID *buffers, VABufferID *buffers,
int num_buffers int num_buffers
) )
...@@ -726,7 +762,7 @@ VAStatus vaRenderPicture ( ...@@ -726,7 +762,7 @@ VAStatus vaRenderPicture (
VAStatus vaEndPicture ( VAStatus vaEndPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context VAContextID context
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -738,8 +774,8 @@ VAStatus vaEndPicture ( ...@@ -738,8 +774,8 @@ VAStatus vaEndPicture (
VAStatus vaSyncSurface ( VAStatus vaSyncSurface (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -751,8 +787,7 @@ VAStatus vaSyncSurface ( ...@@ -751,8 +787,7 @@ VAStatus vaSyncSurface (
VAStatus vaQuerySurfaceStatus ( VAStatus vaQuerySurfaceStatus (
VADisplay dpy, VADisplay dpy,
VAContext *context, VASurfaceID render_target,
VASurface *render_target,
VASurfaceStatus *status /* out */ VASurfaceStatus *status /* out */
) )
{ {
...@@ -760,12 +795,12 @@ VAStatus vaQuerySurfaceStatus ( ...@@ -760,12 +795,12 @@ VAStatus vaQuerySurfaceStatus (
CHECK_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQuerySurfaceStatus); TRACE(vaQuerySurfaceStatus);
return ctx->vtable.vaQuerySurfaceStatus( ctx, context, render_target, status ); return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
} }
VAStatus vaPutSurface ( VAStatus vaPutSurface (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
Drawable draw, /* X Drawable */ Drawable draw, /* X Drawable */
short srcx, short srcx,
short srcy, short srcy,
...@@ -844,7 +879,7 @@ VAStatus vaCreateImage ( ...@@ -844,7 +879,7 @@ VAStatus vaCreateImage (
*/ */
VAStatus vaDestroyImage ( VAStatus vaDestroyImage (
VADisplay dpy, VADisplay dpy,
VAImage *image VAImageID image
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -854,18 +889,31 @@ VAStatus vaDestroyImage ( ...@@ -854,18 +889,31 @@ VAStatus vaDestroyImage (
return ctx->vtable.vaDestroyImage ( ctx, image); 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 * Retrieve surface data into a VAImage
* Image must be in a format supported by the implementation * Image must be in a format supported by the implementation
*/ */
VAStatus vaGetImage ( VAStatus vaGetImage (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */ int x, /* coordinates of the upper left source pixel */
int y, int y,
unsigned int width, /* width and height of the region */ unsigned int width, /* width and height of the region */
unsigned int height, unsigned int height,
VAImage *image VAImageID image
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -881,8 +929,8 @@ VAStatus vaGetImage ( ...@@ -881,8 +929,8 @@ VAStatus vaGetImage (
*/ */
VAStatus vaPutImage ( VAStatus vaPutImage (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
VAImage *image, VAImageID image,
int src_x, int src_x,
int src_y, int src_y,
unsigned int width, unsigned int width,
...@@ -938,8 +986,8 @@ VAStatus vaQuerySubpictureFormats ( ...@@ -938,8 +986,8 @@ VAStatus vaQuerySubpictureFormats (
*/ */
VAStatus vaCreateSubpicture ( VAStatus vaCreateSubpicture (
VADisplay dpy, VADisplay dpy,
VAImage *image, VAImageID image,
VASubpicture *subpicture /* out */ VASubpictureID *subpicture /* out */
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -954,7 +1002,7 @@ VAStatus vaCreateSubpicture ( ...@@ -954,7 +1002,7 @@ VAStatus vaCreateSubpicture (
*/ */
VAStatus vaDestroySubpicture ( VAStatus vaDestroySubpicture (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture VASubpictureID subpicture
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -966,8 +1014,8 @@ VAStatus vaDestroySubpicture ( ...@@ -966,8 +1014,8 @@ VAStatus vaDestroySubpicture (
VAStatus vaSetSubpictureImage ( VAStatus vaSetSubpictureImage (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
VAImage *image VAImageID image
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
...@@ -980,7 +1028,7 @@ VAStatus vaSetSubpictureImage ( ...@@ -980,7 +1028,7 @@ VAStatus vaSetSubpictureImage (
VAStatus vaSetSubpicturePalette ( VAStatus vaSetSubpicturePalette (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
/* /*
* pointer to an array holding the palette data. The size of the array is * 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 * num_palette_entries * entry_bytes in size. The order of the components
...@@ -1002,16 +1050,17 @@ VAStatus vaSetSubpicturePalette ( ...@@ -1002,16 +1050,17 @@ VAStatus vaSetSubpicturePalette (
*/ */
VAStatus vaSetSubpictureChromakey ( VAStatus vaSetSubpictureChromakey (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
unsigned int chromakey_min, unsigned int chromakey_min,
unsigned int chromakey_max unsigned int chromakey_max,
unsigned int chromakey_mask
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureChromakey); TRACE(vaSetSubpictureChromakey);
return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max ); return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
} }
...@@ -1022,7 +1071,7 @@ VAStatus vaSetSubpictureChromakey ( ...@@ -1022,7 +1071,7 @@ VAStatus vaSetSubpictureChromakey (
*/ */
VAStatus vaSetSubpictureGlobalAlpha ( VAStatus vaSetSubpictureGlobalAlpha (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
float global_alpha float global_alpha
) )
{ {
...@@ -1042,8 +1091,9 @@ VAStatus vaSetSubpictureGlobalAlpha ( ...@@ -1042,8 +1091,9 @@ VAStatus vaSetSubpictureGlobalAlpha (
*/ */
VAStatus vaAssociateSubpicture ( VAStatus vaAssociateSubpicture (
VADisplay dpy, VADisplay dpy,
VASurface *target_surface, VASubpictureID subpicture,
VASubpicture *subpicture, VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */ short src_x, /* upper left offset in subpicture */
short src_y, short src_y,
short dest_x, /* upper left offset in surface */ short dest_x, /* upper left offset in surface */
...@@ -1061,9 +1111,27 @@ VAStatus vaAssociateSubpicture ( ...@@ -1061,9 +1111,27 @@ VAStatus vaAssociateSubpicture (
CHECK_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaAssociateSubpicture); 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 */ /* Get maximum number of display attributes supported by the implementation */
int vaMaxNumDisplayAttributes ( int vaMaxNumDisplayAttributes (
VADisplay dpy VADisplay dpy
...@@ -1138,7 +1206,7 @@ VAStatus vaSetDisplayAttributes ( ...@@ -1138,7 +1206,7 @@ VAStatus vaSetDisplayAttributes (
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
VASurface *surface, VASurfaceID surface,
void **buffer, /* out */ void **buffer, /* out */
unsigned int *stride /* out */ unsigned int *stride /* out */
) )
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
/* /*
* Video Decode Acceleration API Specification * Video Decode Acceleration API Specification
* *
* Rev. 0.24 * Rev. 0.25
* <jonathan.bian@intel.com> * <jonathan.bian@intel.com>
* *
* Revision History: * Revision History:
...@@ -42,13 +42,15 @@ ...@@ -42,13 +42,15 @@
* rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure. * 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.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.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.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.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.
* *
* Acknowledgements: * Acknowledgements:
* Some concepts borrowed from XvMC and XvImage. * 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_ #ifndef _VA_H_
#define _VA_H_ #define _VA_H_
...@@ -59,7 +61,10 @@ extern "C" { ...@@ -59,7 +61,10 @@ extern "C" {
/* /*
Overview 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: The basic operation steps are:
...@@ -93,12 +98,15 @@ typedef int VAStatus; /* Return status type from functions */ ...@@ -93,12 +98,15 @@ typedef int VAStatus; /* Return status type from functions */
#define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005 #define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005
#define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006 #define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006
#define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007 #define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007
#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x00000008 #define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008
#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x00000009 #define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009
#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000a #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a
#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000b #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b
#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000c #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c
#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000d #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 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
/* /*
...@@ -119,6 +127,9 @@ VADisplay vaGetDisplay ( ...@@ -119,6 +127,9 @@ VADisplay vaGetDisplay (
NativeDisplay native_dpy /* implementation specific */ NativeDisplay native_dpy /* implementation specific */
); );
/*
* Initialize the library
*/
VAStatus vaInitialize ( VAStatus vaInitialize (
VADisplay dpy, VADisplay dpy,
int *major_version, /* out */ int *major_version, /* out */
...@@ -132,6 +143,18 @@ VAStatus vaTerminate ( ...@@ -132,6 +143,18 @@ VAStatus vaTerminate (
VADisplay dpy 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 */ /* Currently defined profiles */
typedef enum typedef enum
{ {
...@@ -234,8 +257,8 @@ VAStatus vaQueryConfigEntrypoints ( ...@@ -234,8 +257,8 @@ VAStatus vaQueryConfigEntrypoints (
/* /*
* Get attributes for a given profile/entrypoint pair * Get attributes for a given profile/entrypoint pair
* The caller must provide an “attrib_list” with all attributes to be * The caller must provide an "attrib_list" with all attributes to be
* queried. Upon return, the attributes in “attrib_list” have been * retrieved. Upon return, the attributes in "attrib_list" have been
* updated with their value. Unknown attributes or attributes that are * updated with their value. Unknown attributes or attributes that are
* not supported for the given profile/entrypoint pair will have their * not supported for the given profile/entrypoint pair will have their
* value set to VA_ATTRIB_NOT_SUPPORTED * value set to VA_ATTRIB_NOT_SUPPORTED
...@@ -277,11 +300,11 @@ VAStatus vaDestroyConfig ( ...@@ -277,11 +300,11 @@ VAStatus vaDestroyConfig (
/* /*
* Query all attributes for a given configuration * Query all attributes for a given configuration
* The profile of the configuration is returned in “profile” * The profile of the configuration is returned in "profile"
* The entrypoint of the configuration is returned in “entrypoint” * The entrypoint of the configuration is returned in "entrypoint"
* The caller must provide an “attrib_list” array that can hold at least * The caller must provide an "attrib_list" array that can hold at least
* vaMaxNumConfigAttributes() entries. The actual number of attributes * 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 ( VAStatus vaQueryConfigAttributes (
VADisplay dpy, VADisplay dpy,
...@@ -294,9 +317,19 @@ VAStatus vaQueryConfigAttributes ( ...@@ -294,9 +317,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.
*
* 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
* *
* Context represents a "virtual" video decode pipeline * Both contexts and surfaces are identified by unique IDs and its
* implementation specific internals are kept opaque to the clients
*/ */
typedef VAGenericID VAContextID; typedef VAGenericID VAContextID;
...@@ -305,97 +338,78 @@ typedef VAGenericID VASurfaceID; ...@@ -305,97 +338,78 @@ typedef VAGenericID VASurfaceID;
#define VA_INVALID_SURFACE -1 #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 * vaCreateSurfaces - Create an array of surfaces used for decode and display
* a surface is bound to a given context, it can not be used to create * dpy: display
* another context. The association is removed when the context is destroyed * 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 ( VAStatus vaCreateSurfaces (
VADisplay dpy, VADisplay dpy,
int width, int width,
int height, int height,
int format, int format,
int num_surfaces, int num_surfaces,
VASurface *surfaces /* out */ VASurfaceID *surfaces /* out */
); );
/* /*
* surfaces can only be destroyed after the context associated has been * vaDestroySurfaces - Destroy resources associated with surfaces.
* destroyed * Surfaces can only be destroyed after the context associated has been
*/ * destroyed.
VAStatus vaDestroySurface ( * dpy: display
* surfaces: array of surfaces to destroy
* num_surfaces: number of surfaces in the array to be destroyed.
*/
VAStatus vaDestroySurfaces (
VADisplay dpy, VADisplay dpy,
VASurface *surface_list, VASurfaceID *surfaces,
int num_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 ( VAStatus vaCreateContext (
VADisplay dpy, VADisplay dpy,
VAConfigID config_id, VAConfigID config_id,
int picture_width, int picture_width,
int picture_height, int picture_height,
int flag, int flag,
VASurface *render_targets, VASurfaceID *render_targets,
int num_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 ( VAStatus vaDestroyContext (
VADisplay dpy, VADisplay dpy,
VAContext *context VAContextID context
); );
/* /*
*
* Buffers * Buffers
* Buffers are used to pass various types of data from the * Buffers are used to pass various types of data from the
* client to the server. The server maintains a data store * client to the server. The server maintains a data store
* for each buffer created, and the client idenfies a buffer * for each buffer created, and the client idenfies a buffer
* through a unique buffer id assigned by the server. * through a unique buffer id assigned by the server.
*
*/ */
typedef VAGenericID VABufferID; typedef VAGenericID VABufferID;
...@@ -622,6 +636,15 @@ typedef struct _VASliceParameterBufferMPEG4 ...@@ -622,6 +636,15 @@ typedef struct _VASliceParameterBufferMPEG4
VC-1 data structures 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 */ /* VC-1 Picture Parameter Buffer */
/* /*
* For each picture, and before any slice data, a picture parameter * For each picture, and before any slice data, a picture parameter
...@@ -702,6 +725,18 @@ typedef struct _VAPictureParameterBufferVC1 ...@@ -702,6 +725,18 @@ typedef struct _VAPictureParameterBufferVC1
}; };
unsigned char raw_coding_flag; unsigned char raw_coding_flag;
}; };
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 { union {
struct { struct {
unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
...@@ -713,16 +748,16 @@ typedef struct _VAPictureParameterBufferVC1 ...@@ -713,16 +748,16 @@ typedef struct _VAPictureParameterBufferVC1
}; };
union { union {
struct { struct {
unsigned char mv_mode : 3; /* PICTURE_LAYER::MVMODE */ VAMvModeVC1 mv_mode : 3; /* PICTURE_LAYER::MVMODE */
unsigned char mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ VAMvModeVC1 mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */
unsigned char mv_table : 3;/* PICTURE_LAYER::MVTAB/IMVTAB */ unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
unsigned char two_mv_block_pattern_table: 2;/* PICTURE_LAYER::2MVBPTAB */ unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
unsigned char four_mv_switch: 1; /* PICTURE_LAYER::4MVSWITCH */ unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */
unsigned char four_mv_block_pattern_table : 2;/* PICTURE_LAYER::4MVBPTAB */ 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_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
unsigned char extended_mv_range : 2;/* PICTURE_LAYER::MVRANGE */ unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */
unsigned char extended_dmv_flag : 1;/* ENTRY_POINT_LAYER::EXTENDED_DMV */ unsigned char extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
unsigned char extended_dmv_range : 2;/* PICTURE_LAYER::DMVRANGE */ unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
}; };
unsigned int mv_fields; unsigned int mv_fields;
}; };
...@@ -905,6 +940,8 @@ typedef struct _VASliceParameterBufferH264 ...@@ -905,6 +940,8 @@ typedef struct _VASliceParameterBufferH264
/* /*
* Creates a buffer for storing a certain type of data, no data store allocated * Creates a buffer for storing a certain type of data, no data store allocated
* Note: image buffers are created by the library, not the client. Please see
* vaCreateImage on how image buffers are managed.
*/ */
VAStatus vaCreateBuffer ( VAStatus vaCreateBuffer (
VADisplay dpy, VADisplay dpy,
...@@ -985,8 +1022,8 @@ The Begin/Render/End sequence sends the decode buffers to the server ...@@ -985,8 +1022,8 @@ The Begin/Render/End sequence sends the decode buffers to the server
*/ */
VAStatus vaBeginPicture ( VAStatus vaBeginPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
); );
/* /*
...@@ -994,7 +1031,7 @@ VAStatus vaBeginPicture ( ...@@ -994,7 +1031,7 @@ VAStatus vaBeginPicture (
*/ */
VAStatus vaRenderPicture ( VAStatus vaRenderPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VABufferID *buffers, VABufferID *buffers,
int num_buffers int num_buffers
); );
...@@ -1007,7 +1044,7 @@ VAStatus vaRenderPicture ( ...@@ -1007,7 +1044,7 @@ VAStatus vaRenderPicture (
*/ */
VAStatus vaEndPicture ( VAStatus vaEndPicture (
VADisplay dpy, VADisplay dpy,
VAContext *context VAContextID context
); );
/* /*
...@@ -1023,8 +1060,8 @@ Synchronization ...@@ -1023,8 +1060,8 @@ Synchronization
*/ */
VAStatus vaSyncSurface ( VAStatus vaSyncSurface (
VADisplay dpy, VADisplay dpy,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
); );
typedef enum typedef enum
...@@ -1041,8 +1078,7 @@ typedef enum ...@@ -1041,8 +1078,7 @@ typedef enum
*/ */
VAStatus vaQuerySurfaceStatus ( VAStatus vaQuerySurfaceStatus (
VADisplay dpy, VADisplay dpy,
VAContext *context, VASurfaceID render_target,
VASurface *render_target,
VASurfaceStatus *status /* out */ VASurfaceStatus *status /* out */
); );
...@@ -1053,7 +1089,7 @@ VAStatus vaQuerySurfaceStatus ( ...@@ -1053,7 +1089,7 @@ VAStatus vaQuerySurfaceStatus (
* Caller should free the returned buffer with free() when done. * Caller should free the returned buffer with free() when done.
*/ */
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
VASurface *surface, VASurfaceID surface,
void **buffer, /* out */ void **buffer, /* out */
unsigned int *stride /* out */ unsigned int *stride /* out */
); );
...@@ -1096,28 +1132,38 @@ typedef struct _VAImage ...@@ -1096,28 +1132,38 @@ typedef struct _VAImage
VABufferID buf; /* image data buffer */ VABufferID buf; /* image data buffer */
/* /*
* Image data will be stored in a buffer of type VAImageBufferType to facilitate * Image data will be stored in a buffer of type VAImageBufferType to facilitate
* data store on the server side for optimal performance. * data store on the server side for optimal performance. The buffer will be
* It is expected that the client will first call vaCreateImage which returns a VAImage * created by the CreateImage function, and proper storage allocated based on the image
* structure with the following fields filled by the library. It will then * size and format. This buffer is managed by the library implementation, and
* create the "buf" with vaBufferCreate. For PutImage, then client will call * accessed by the client through the buffer Map/Unmap functions.
* 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.
*/ */
unsigned short width; unsigned short width;
unsigned short height; unsigned short height;
unsigned int data_size; 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. * An array indicating the scanline pitch in bytes for each plane.
* Each plane may have a different pitch. * 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 * An array indicating the byte offset from the beginning of the image data
* the beginning of the image data to the start of each plane. * to the start of each plane.
*/ */
unsigned int *offsets; 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.
*/
char component_order[4];
} VAImage; } VAImage;
/* Get maximum number of image formats supported by the implementation */ /* Get maximum number of image formats supported by the implementation */
...@@ -1140,11 +1186,9 @@ VAStatus vaQueryImageFormats ( ...@@ -1140,11 +1186,9 @@ VAStatus vaQueryImageFormats (
/* /*
* Create a VAImage structure * Create a VAImage structure
* The width and height fields returned in the VAImage structure may get * 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 * enlarged for some YUV formats. Upon return from this function,
* to be allocated will be given in the "data_size" field in VAImage. * image->buf has been created and proper storage allocated by the library.
* Image data is not allocated by this function. The client should * The client can access the image through the Map/Unmap calls.
* allocate the memory required for the data and fill in the data field after
* looking at "data_size" returned from this call.
*/ */
VAStatus vaCreateImage ( VAStatus vaCreateImage (
VADisplay dpy, VADisplay dpy,
...@@ -1159,7 +1203,18 @@ VAStatus vaCreateImage ( ...@@ -1159,7 +1203,18 @@ VAStatus vaCreateImage (
*/ */
VAStatus vaDestroyImage ( VAStatus vaDestroyImage (
VADisplay dpy, 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
); );
/* /*
...@@ -1168,22 +1223,26 @@ VAStatus vaDestroyImage ( ...@@ -1168,22 +1223,26 @@ VAStatus vaDestroyImage (
*/ */
VAStatus vaGetImage ( VAStatus vaGetImage (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */ int x, /* coordinates of the upper left source pixel */
int y, int y,
unsigned int width, /* width and height of the region */ unsigned int width, /* width and height of the region */
unsigned int height, unsigned int height,
VAImage *image VAImageID image
); );
/* /*
* Copy data from a VAImage to a surface * Copy data from a VAImage to a surface
* Image must be in a format supported by the implementation * 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 ( VAStatus vaPutImage (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
VAImage *image, VAImageID image,
int src_x, int src_x,
int src_y, int src_y,
unsigned int width, unsigned int width,
...@@ -1201,50 +1260,23 @@ VAStatus vaPutImage ( ...@@ -1201,50 +1260,23 @@ VAStatus vaPutImage (
typedef VAGenericID VASubpictureID; 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 */ /* Get maximum number of subpicture formats supported by the implementation */
int vaMaxNumSubpictureFormats ( int vaMaxNumSubpictureFormats (
VADisplay dpy VADisplay dpy
); );
/* flags for subpictures */
#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
/* /*
* Query supported subpicture formats * Query supported subpicture formats
* The caller must provide a "format_list" array that can hold at * The caller must provide a "format_list" array that can hold at
* least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
* for each format to indicate additional capabilities for that format. The actual * for each format to indicate additional capabilities for that format. The actual
* number of formats returned in "format_list" is returned in "num_formats". * 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 ( VAStatus vaQuerySubpictureFormats (
VADisplay dpy, VADisplay dpy,
...@@ -1258,8 +1290,8 @@ VAStatus vaQuerySubpictureFormats ( ...@@ -1258,8 +1290,8 @@ VAStatus vaQuerySubpictureFormats (
*/ */
VAStatus vaCreateSubpicture ( VAStatus vaCreateSubpicture (
VADisplay dpy, VADisplay dpy,
VAImage *image, VAImageID image,
VASubpicture *subpicture /* out */ VASubpictureID *subpicture /* out */
); );
/* /*
...@@ -1267,7 +1299,7 @@ VAStatus vaCreateSubpicture ( ...@@ -1267,7 +1299,7 @@ VAStatus vaCreateSubpicture (
*/ */
VAStatus vaDestroySubpicture ( VAStatus vaDestroySubpicture (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture VASubpictureID subpicture
); );
/* /*
...@@ -1276,17 +1308,17 @@ VAStatus vaDestroySubpicture ( ...@@ -1276,17 +1308,17 @@ VAStatus vaDestroySubpicture (
*/ */
VAStatus vaSetSubpictureImage ( VAStatus vaSetSubpictureImage (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
VAImage *image VAImageID image
); );
VAStatus vaSetSubpicturePalette ( VAStatus vaSetSubpicturePalette (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
/* /*
* pointer to an array holding the palette data. The size of the array is * 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 * 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 unsigned char *palette
); );
...@@ -1294,12 +1326,18 @@ VAStatus vaSetSubpicturePalette ( ...@@ -1294,12 +1326,18 @@ VAStatus vaSetSubpicturePalette (
/* /*
* If chromakey is enabled, then the area where the source value falls within * If chromakey is enabled, then the area where the source value falls within
* the chromakey [min, max] range is transparent * 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 ( VAStatus vaSetSubpictureChromakey (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
unsigned int chromakey_min, unsigned int chromakey_min,
unsigned int chromakey_max unsigned int chromakey_max,
unsigned int chromakey_mask
); );
/* /*
...@@ -1309,21 +1347,22 @@ VAStatus vaSetSubpictureChromakey ( ...@@ -1309,21 +1347,22 @@ VAStatus vaSetSubpictureChromakey (
*/ */
VAStatus vaSetSubpictureGlobalAlpha ( VAStatus vaSetSubpictureGlobalAlpha (
VADisplay dpy, VADisplay dpy,
VASubpicture *subpicture, VASubpictureID subpicture,
float global_alpha float global_alpha
); );
/* /*
vaAssociateSubpicture associates the subpicture with the target_surface. * vaAssociateSubpicture associates the subpicture with target_surfaces.
It defines the region mapping between the subpicture and the target * It defines the region mapping between the subpicture and the target
surface through source and destination rectangles (with the same width and height). * surfaces through source and destination rectangles (with the same width and height).
Both will be displayed at the next call to vaPutSurface. Additional * Both will be displayed at the next call to vaPutSurface. Additional
associations before the call to vaPutSurface simply overrides the association. * associations before the call to vaPutSurface simply overrides the association.
*/ */
VAStatus vaAssociateSubpicture ( VAStatus vaAssociateSubpicture (
VADisplay dpy, VADisplay dpy,
VASurface *target_surface, VASubpictureID subpicture,
VASubpicture *subpicture, VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */ short src_x, /* upper left offset in subpicture */
short src_y, short src_y,
short dest_x, /* upper left offset in surface */ short dest_x, /* upper left offset in surface */
...@@ -1337,6 +1376,16 @@ VAStatus vaAssociateSubpicture ( ...@@ -1337,6 +1376,16 @@ VAStatus vaAssociateSubpicture (
unsigned int flags 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 typedef struct _VARectangle
{ {
short x; short x;
...@@ -1360,6 +1409,17 @@ typedef enum ...@@ -1360,6 +1409,17 @@ typedef enum
VADisplayAttribContrast = 1, VADisplayAttribContrast = 1,
VADisplayAttribHue = 2, VADisplayAttribHue = 2,
VADisplayAttribSaturation = 3, 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; } VADisplayAttribType;
/* flags for VADisplayAttribute */ /* flags for VADisplayAttribute */
...@@ -1475,13 +1535,13 @@ Mostly to demonstrate program flow with no error handling ... ...@@ -1475,13 +1535,13 @@ Mostly to demonstrate program flow with no error handling ...
* create surfaces for the current target as well as reference frames * create surfaces for the current target as well as reference frames
* we can get by with 4 surfaces for MPEG-2 * 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); vaCreateSurfaces(dpy, 720, 480, VA_RT_FORMAT_YUV420, 4, surfaces);
/* /*
* Create a context for this decode pipe * Create a context for this decode pipe
*/ */
VAContext context; VAContextID context;
vaCreateContext(dpy, config_id, 720, 480, VA_PROGRESSIVE, surfaces, vaCreateContext(dpy, config_id, 720, 480, VA_PROGRESSIVE, surfaces,
4, &context); 4, &context);
...@@ -1497,7 +1557,6 @@ Mostly to demonstrate program flow with no error handling ... ...@@ -1497,7 +1557,6 @@ Mostly to demonstrate program flow with no error handling ...
/* fill in picture_coding_extension fields here */ /* fill in picture_coding_extension fields here */
vaUnmapBuffer(dpy, picture_buf); vaUnmapBuffer(dpy, picture_buf);
/* Create an IQ matrix buffer for this frame */ /* Create an IQ matrix buffer for this frame */
VABufferID iq_buf; VABufferID iq_buf;
VAIQMatrixBufferMPEG2 *iq_matrix; VAIQMatrixBufferMPEG2 *iq_matrix;
...@@ -1508,7 +1567,7 @@ Mostly to demonstrate program flow with no error handling ... ...@@ -1508,7 +1567,7 @@ Mostly to demonstrate program flow with no error handling ...
vaUnmapBuffer(dpy, iq_buf); vaUnmapBuffer(dpy, iq_buf);
/* send the picture and IQ matrix buffers to the server */ /* 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, &picture_buf, 1);
vaRenderPicture(dpy, context, &iq_buf, 1); vaRenderPicture(dpy, context, &iq_buf, 1);
...@@ -1559,17 +1618,17 @@ Mostly to demonstrate program flow with no error handling ... ...@@ -1559,17 +1618,17 @@ Mostly to demonstrate program flow with no error handling ...
vaQuerySubpictureFormats(dpy, sub_formats, &num_formats); vaQuerySubpictureFormats(dpy, sub_formats, &num_formats);
/* Assume that we find AI44 as a subpicture format in sub_formats[0] */ /* Assume that we find AI44 as a subpicture format in sub_formats[0] */
VAImage sub_image; VAImage sub_image;
VASubpicture subpicture; VASubpictureID subpicture;
unsigned char sub_data[128][16]; unsigned char *sub_data;
/* create an image for the subtitle */ /* create an image for the subtitle */
vaCreateImage(dpy, sub_formats, 128, 16, &sub_image); 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 */ /* fill the image data */
vaBufferData(dpy, sub_image->buf, sub_image->data_size, sub_data); vaUnmapBuffer(dpy, sub_image->buf);
vaCreateSubpicture(dpy, &sub_image, &subpicture); vaCreateSubpicture(dpy, sub_image, &subpicture);
unsigned char palette[3][16]; unsigned char palette[3][16];
/* fill the palette data */ /* fill the palette data */
vaSetSubpicturePalette(dpy, &subpicture, palette); vaSetSubpicturePalette(dpy, subpicture, palette);
vaAssociateSubpicture(dpy, surfaces, &subpicture, 0, 0, 296, 400, 128, 16); 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); vaPutSurface(dpy, surfaces, win, 0, 0, 720, 480, 100, 100, 640, 480, NULL, 0, 0);
#endif #endif
...@@ -34,25 +34,11 @@ ...@@ -34,25 +34,11 @@
#include <stdlib.h> #include <stdlib.h>
typedef struct VADriverContext *VADriverContextP; 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 VADriverVTable
{
VAStatus (*vaTerminate) ( VADriverContextP ctx ); VAStatus (*vaTerminate) ( VADriverContextP ctx );
VAStatus (*vaQueryConfigProfiles) ( VAStatus (*vaQueryConfigProfiles) (
...@@ -105,12 +91,12 @@ struct VADriverContext ...@@ -105,12 +91,12 @@ struct VADriverContext
int height, int height,
int format, int format,
int num_surfaces, int num_surfaces,
VASurface *surfaces /* out */ VASurfaceID *surfaces /* out */
); );
VAStatus (*vaDestroySurface) ( VAStatus (*vaDestroySurfaces) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface_list, VASurfaceID *surface_list,
int num_surfaces int num_surfaces
); );
...@@ -120,14 +106,14 @@ struct VADriverContext ...@@ -120,14 +106,14 @@ struct VADriverContext
int picture_width, int picture_width,
int picture_height, int picture_height,
int flag, int flag,
VASurface *render_targets, VASurfaceID *render_targets,
int num_render_targets, int num_render_targets,
VAContext *context /* out */ VAContextID *context /* out */
); );
VAStatus (*vaDestroyContext) ( VAStatus (*vaDestroyContext) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context VAContextID context
); );
VAStatus (*vaCreateBuffer) ( VAStatus (*vaCreateBuffer) (
...@@ -168,38 +154,37 @@ struct VADriverContext ...@@ -168,38 +154,37 @@ struct VADriverContext
VAStatus (*vaBeginPicture) ( VAStatus (*vaBeginPicture) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
); );
VAStatus (*vaRenderPicture) ( VAStatus (*vaRenderPicture) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VABufferID *buffers, VABufferID *buffers,
int num_buffers int num_buffers
); );
VAStatus (*vaEndPicture) ( VAStatus (*vaEndPicture) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context VAContextID context
); );
VAStatus (*vaSyncSurface) ( VAStatus (*vaSyncSurface) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VAContextID context,
VASurface *render_target VASurfaceID render_target
); );
VAStatus (*vaQuerySurfaceStatus) ( VAStatus (*vaQuerySurfaceStatus) (
VADriverContextP ctx, VADriverContextP ctx,
VAContext *context, VASurfaceID render_target,
VASurface *render_target,
VASurfaceStatus *status /* out */ VASurfaceStatus *status /* out */
); );
VAStatus (*vaPutSurface) ( VAStatus (*vaPutSurface) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
Drawable draw, /* X Drawable */ Drawable draw, /* X Drawable */
short srcx, short srcx,
short srcy, short srcy,
...@@ -230,23 +215,34 @@ struct VADriverContext ...@@ -230,23 +215,34 @@ struct VADriverContext
VAStatus (*vaDestroyImage) ( VAStatus (*vaDestroyImage) (
VADriverContextP ctx, 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) ( VAStatus (*vaGetImage) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
int x, /* coordinates of the upper left source pixel */ int x, /* coordinates of the upper left source pixel */
int y, int y,
unsigned int width, /* width and height of the region */ unsigned int width, /* width and height of the region */
unsigned int height, unsigned int height,
VAImage *image VAImageID image
); );
VAStatus (*vaPutImage) ( VAStatus (*vaPutImage) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
VAImage *image, VAImageID image,
int src_x, int src_x,
int src_y, int src_y,
unsigned int width, unsigned int width,
...@@ -264,24 +260,24 @@ struct VADriverContext ...@@ -264,24 +260,24 @@ struct VADriverContext
VAStatus (*vaCreateSubpicture) ( VAStatus (*vaCreateSubpicture) (
VADriverContextP ctx, VADriverContextP ctx,
VAImage *image, VAImageID image,
VASubpicture *subpicture /* out */ VASubpictureID *subpicture /* out */
); );
VAStatus (*vaDestroySubpicture) ( VAStatus (*vaDestroySubpicture) (
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture VASubpictureID subpicture
); );
VAStatus (*vaSetSubpictureImage) ( VAStatus (*vaSetSubpictureImage) (
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
VAImage *image VAImageID image
); );
VAStatus (*vaSetSubpicturePalette) ( VAStatus (*vaSetSubpicturePalette) (
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
/* /*
* pointer to an array holding the palette data. The size of the array is * 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 * num_palette_entries * entry_bytes in size. The order of the components
...@@ -292,21 +288,23 @@ struct VADriverContext ...@@ -292,21 +288,23 @@ struct VADriverContext
VAStatus (*vaSetSubpictureChromakey) ( VAStatus (*vaSetSubpictureChromakey) (
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
unsigned int chromakey_min, unsigned int chromakey_min,
unsigned int chromakey_max unsigned int chromakey_max,
unsigned int chromakey_mask
); );
VAStatus (*vaSetSubpictureGlobalAlpha) ( VAStatus (*vaSetSubpictureGlobalAlpha) (
VADriverContextP ctx, VADriverContextP ctx,
VASubpicture *subpicture, VASubpictureID subpicture,
float global_alpha float global_alpha
); );
VAStatus (*vaAssociateSubpicture) ( VAStatus (*vaAssociateSubpicture) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *target_surface, VASubpictureID subpicture,
VASubpicture *subpicture, VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */ short src_x, /* upper left offset in subpicture */
short src_y, short src_y,
short dest_x, /* upper left offset in surface */ short dest_x, /* upper left offset in surface */
...@@ -320,6 +318,13 @@ struct VADriverContext ...@@ -320,6 +318,13 @@ struct VADriverContext
unsigned int flags unsigned int flags
); );
VAStatus (*vaDeassociateSubpicture) (
VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces
);
VAStatus (*vaQueryDisplayAttributes) ( VAStatus (*vaQueryDisplayAttributes) (
VADriverContextP ctx, VADriverContextP ctx,
VADisplayAttribute *attr_list, /* out */ VADisplayAttribute *attr_list, /* out */
...@@ -341,12 +346,33 @@ struct VADriverContext ...@@ -341,12 +346,33 @@ struct VADriverContext
VAStatus (*vaDbgCopySurfaceToBuffer) ( VAStatus (*vaDbgCopySurfaceToBuffer) (
VADriverContextP ctx, VADriverContextP ctx,
VASurface *surface, VASurfaceID surface,
void **buffer, /* out */ void **buffer, /* out */
unsigned int *stride /* out */ unsigned int *stride /* out */
); );
};
struct VADriverContext
{
VADriverContextP pNext;
void *pDriverData;
struct VADriverVTable 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;
} vtable; void *handle; /* dlopen handle */
}; };
typedef VAStatus (*VADriverInit) ( typedef VAStatus (*VADriverInit) (
......
...@@ -36,9 +36,16 @@ extern "C" { ...@@ -36,9 +36,16 @@ extern "C" {
#define VA_TOP_FIELD 0x00000001 #define VA_TOP_FIELD 0x00000001
#define VA_BOTTOM_FIELD 0x00000002 #define VA_BOTTOM_FIELD 0x00000002
#define VA_FRAME_PICTURE 0x00000004 /* weave */ #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 ( VAStatus vaPutSurface (
VADisplay dpy, VADisplay dpy,
VASurface *surface, VASurfaceID surface,
Drawable draw, /* X Drawable */ Drawable draw, /* X Drawable */
short srcx, short srcx,
short srcy, short srcy,
......
...@@ -53,23 +53,23 @@ int main(int argc, const char* argv[]) ...@@ -53,23 +53,23 @@ int main(int argc, const char* argv[])
printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version); printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
{ {
VASurface surfaces[21]; VASurfaceID surfaces[21];
int i; int i;
surfaces[20].surface_id = -1; surfaces[20] = -1;
va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces);
ASSERT( VA_STATUS_SUCCESS == va_status ); 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++) 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)); Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0));
printf("Window = %08x\n", win); printf("Window = %08x\n", win);
XMapWindow(dpy, win); XMapWindow(dpy, win);
XSync(dpy, False); 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); sleep(10);
va_status = vaDestroySurface(va_dpy, surfaces, 20); va_status = vaDestroySurface(va_dpy, surfaces, 20);
...@@ -94,14 +94,14 @@ int main(int argc, const char* argv[]) ...@@ -94,14 +94,14 @@ int main(int argc, const char* argv[])
} }
{ {
VASurface surfaces[20]; VASurfaceID surfaces[20];
VAContext context; VAContextID context;
VAConfigAttrib attrib; VAConfigAttrib attrib;
VAConfigID config_id; VAConfigID config_id;
int i; int i;
attrib.type = VAConfigAttribRTFormat; attrib.type = VAConfigAttribRTFormat;
va_status = vaQueryConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1); &attrib, 1);
ASSERT( VA_STATUS_SUCCESS == va_status ); ASSERT( VA_STATUS_SUCCESS == va_status );
...@@ -118,7 +118,7 @@ int main(int argc, const char* argv[]) ...@@ -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); va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context);
ASSERT( VA_STATUS_SUCCESS == va_status ); ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaDestroyContext(va_dpy, &context); va_status = vaDestroyContext(va_dpy, context);
ASSERT( VA_STATUS_SUCCESS == va_status ); ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaDestroySurface(va_dpy, surfaces, 20); va_status = vaDestroySurface(va_dpy, surfaces, 20);
......
...@@ -33,7 +33,7 @@ void pre() ...@@ -33,7 +33,7 @@ void pre()
#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead #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; int i,j;
...@@ -42,9 +42,9 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac ...@@ -42,9 +42,9 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac
for(j = 0; j < surface_count2; j++) for(j = 0; j < surface_count2; j++)
{ {
if ((surface_list1 == surface_list2) && (i == j)) continue; if ((surface_list1 == surface_list2) && (i == j)) continue;
ASSERT(surface_list1[i].surface_id != VA_INVALID_SURFACE); ASSERT(surface_list1[i] != VA_INVALID_SURFACE);
ASSERT(surface_list2[j].surface_id != VA_INVALID_SURFACE); ASSERT(surface_list2[j] != VA_INVALID_SURFACE);
ASSERT(surface_list1[i].surface_id != surface_list2[j].surface_id); ASSERT(surface_list1[i] != surface_list2[j]);
} }
} }
} }
...@@ -52,10 +52,10 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac ...@@ -52,10 +52,10 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac
void test() void test()
{ {
VASurface surfaces_1[1+1]; VASurfaceID surfaces_1[1+1];
VASurface surfaces_4[4+1]; VASurfaceID surfaces_4[4+1];
VASurface surfaces_16[16+1]; VASurfaceID surfaces_16[16+1];
VASurface surfaces_6[6+1]; VASurfaceID surfaces_6[6+1];
memset(surfaces_1, 0xff, sizeof(surfaces_1)); memset(surfaces_1, 0xff, sizeof(surfaces_1));
memset(surfaces_4, 0xff, sizeof(surfaces_4)); memset(surfaces_4, 0xff, sizeof(surfaces_4));
...@@ -63,22 +63,22 @@ void test() ...@@ -63,22 +63,22 @@ void test()
memset(surfaces_6, 0xff, sizeof(surfaces_6)); memset(surfaces_6, 0xff, sizeof(surfaces_6));
status("vaCreateSurfaces 1 surface\n"); 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); va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1);
ASSERT( VA_STATUS_SUCCESS == va_status ); 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"); 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); va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4);
ASSERT( VA_STATUS_SUCCESS == va_status ); 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"); 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); va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16);
ASSERT( VA_STATUS_SUCCESS == va_status ); 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_1, 1, surfaces_4, 4);
test_unique_surfaces(surfaces_4, 4, surfaces_16, 4); test_unique_surfaces(surfaces_4, 4, surfaces_16, 4);
...@@ -87,29 +87,29 @@ void test() ...@@ -87,29 +87,29 @@ void test()
test_unique_surfaces(surfaces_1, 16, surfaces_16, 16); test_unique_surfaces(surfaces_1, 16, surfaces_16, 16);
status("vaDestroySurface 4 surfaces\n"); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaCreateSurfaces 6 surfaces\n"); 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); va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6);
ASSERT( VA_STATUS_SUCCESS == va_status ); 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_1, 1, surfaces_6, 6);
test_unique_surfaces(surfaces_6, 6, surfaces_16, 16); test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
test_unique_surfaces(surfaces_1, 6, surfaces_16, 6); test_unique_surfaces(surfaces_1, 6, surfaces_16, 6);
status("vaDestroySurface 16 surfaces\n"); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaDestroySurface 1 surface\n"); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
status("vaDestroySurface 6 surfaces\n"); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
} }
......
...@@ -33,17 +33,17 @@ void pre() ...@@ -33,17 +33,17 @@ void pre()
#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead #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; int i,j;
for(i = 0; i < surface_count; i++) 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++) for(j = 0; j < i; j++)
{ {
if (i == j) continue; 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[] = { ...@@ -65,7 +65,7 @@ test_size_t test_sizes[] = {
void test() void test()
{ {
VASurface surfaces[NUM_SIZES+1]; VASurfaceID surfaces[NUM_SIZES+1];
int i; int i;
memset(surfaces, 0xff, sizeof(surfaces)); memset(surfaces, 0xff, sizeof(surfaces));
...@@ -73,16 +73,16 @@ void test() ...@@ -73,16 +73,16 @@ void test()
for(i = 0; i < NUM_SIZES; i++) for(i = 0; i < NUM_SIZES; i++)
{ {
status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h); 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]); 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( 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); test_unique_surfaces(surfaces, NUM_SIZES);
status("vaDestroySurface all surfaces\n"); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
} }
......
...@@ -44,7 +44,7 @@ void test() ...@@ -44,7 +44,7 @@ void test()
ASSERT(entrypoints); ASSERT(entrypoints);
VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); 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++) for(i = 0; i < num_profiles; i++)
{ {
...@@ -66,7 +66,7 @@ void test() ...@@ -66,7 +66,7 @@ void test()
int surface_count = 4; int surface_count = 4;
int total_surfaces = config_count * surface_count; 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 // 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); va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces);
...@@ -82,8 +82,8 @@ void test() ...@@ -82,8 +82,8 @@ void test()
for(i = 0; i < config_count; i++) for(i = 0; i < config_count; i++)
{ {
status("vaDestroyContext for context %08x\n", contexts[i].context_id); status("vaDestroyContext for context %08x\n", contexts[i]);
va_status = vaDestroyContext( va_dpy, &contexts[i] ); va_status = vaDestroyContext( va_dpy, contexts[i] );
ASSERT( VA_STATUS_SUCCESS == va_status ); ASSERT( VA_STATUS_SUCCESS == va_status );
} }
...@@ -94,7 +94,7 @@ void test() ...@@ -94,7 +94,7 @@ void test()
ASSERT( VA_STATUS_SUCCESS == va_status ); 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 ); ASSERT( VA_STATUS_SUCCESS == va_status );
free(contexts); free(contexts);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment