From 4a9db08281a992fcb51e34a77bf3f4ce94d687fc Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Mon, 29 Oct 2007 16:17:23 -0700 Subject: [PATCH] Update to VA API v0.25 --- dummy_drv_video/dummy_drv_video.c | 203 ++++++++--------- dummy_drv_video/dummy_drv_video.h | 12 +- src/va.c | 146 +++++++++---- src/va.h | 443 +++++++++++++++++++++----------------- src/va_backend.h | 130 ++++++----- src/va_x11.h | 9 +- test/test.c | 18 +- test/test_07.c | 40 ++-- test/test_08.c | 14 +- test/test_09.c | 10 +- 10 files changed, 597 insertions(+), 428 deletions(-) diff --git a/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c index 4ec2a55..bc86a7b 100644 --- a/dummy_drv_video/dummy_drv_video.c +++ b/dummy_drv_video/dummy_drv_video.c @@ -366,7 +366,7 @@ VAStatus dummy_CreateSurfaces( int height, int format, int num_surfaces, - VASurface *surfaces /* out */ + VASurfaceID *surfaces /* out */ ) { INIT_DRIVER_DATA @@ -388,13 +388,8 @@ VAStatus dummy_CreateSurfaces( vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; break; } - obj_surface->surface = &(surfaces[i]); - obj_surface->surface->surface_id = surfaceID; - obj_surface->surface->context_id = -1; - obj_surface->surface->width = width; - obj_surface->surface->height = height; - obj_surface->surface->format = format; - obj_surface->surface->privData = NULL; + obj_surface->surface_id = surfaceID; + surfaces[i] = surfaceID; } /* Error recovery */ @@ -403,8 +398,8 @@ VAStatus dummy_CreateSurfaces( /* surfaces[i-1] was the last successful allocation */ for(; i--; ) { - object_surface_p obj_surface = SURFACE(surfaces[i].surface_id); - surfaces[i].surface_id = -1; + object_surface_p obj_surface = SURFACE(surfaces[i]); + surfaces[i] = VA_INVALID_SURFACE; ASSERT(obj_surface); object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); } @@ -413,9 +408,9 @@ VAStatus dummy_CreateSurfaces( return vaStatus; } -VAStatus dummy_DestroySurface( +VAStatus dummy_DestroySurfaces( VADriverContextP ctx, - VASurface *surface_list, + VASurfaceID *surface_list, int num_surfaces ) { @@ -423,7 +418,7 @@ VAStatus dummy_DestroySurface( int i; for(i = num_surfaces; i--; ) { - object_surface_p obj_surface = SURFACE(surface_list[i].surface_id); + object_surface_p obj_surface = SURFACE(surface_list[i]); ASSERT(obj_surface); object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); } @@ -458,7 +453,19 @@ VAStatus dummy_CreateImage( VAStatus dummy_DestroyImage( VADriverContextP ctx, - VAImage *image + VAImageID image +) +{ + INIT_DRIVER_DATA + + /* TODO */ + return VA_STATUS_SUCCESS; +} + +VAStatus dummy_SetImagePalette( + VADriverContextP ctx, + VAImageID image, + unsigned char *palette ) { INIT_DRIVER_DATA @@ -469,12 +476,12 @@ VAStatus dummy_DestroyImage( VAStatus dummy_GetImage( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, int x, /* coordinates of the upper left source pixel */ int y, unsigned int width, /* width and height of the region */ unsigned int height, - VAImage *image + VAImageID image ) { INIT_DRIVER_DATA @@ -485,8 +492,8 @@ VAStatus dummy_GetImage( VAStatus dummy_PutImage( VADriverContextP ctx, - VASurface *surface, - VAImage *image, + VASurfaceID surface, + VAImageID image, int src_x, int src_y, unsigned int width, @@ -516,8 +523,8 @@ VAStatus dummy_QuerySubpictureFormats( VAStatus dummy_CreateSubpicture( VADriverContextP ctx, - VAImage *image, - VASubpicture *subpicture /* out */ + VAImageID image, + VASubpictureID *subpicture /* out */ ) { INIT_DRIVER_DATA @@ -528,7 +535,7 @@ VAStatus dummy_CreateSubpicture( VAStatus dummy_DestroySubpicture( VADriverContextP ctx, - VASubpicture *subpicture + VASubpictureID subpicture ) { INIT_DRIVER_DATA @@ -539,8 +546,8 @@ VAStatus dummy_DestroySubpicture( VAStatus dummy_SetSubpictureImage( VADriverContextP ctx, - VASubpicture *subpicture, - VAImage *image + VASubpictureID subpicture, + VAImageID image ) { INIT_DRIVER_DATA @@ -551,7 +558,7 @@ VAStatus dummy_SetSubpictureImage( VAStatus dummy_SetSubpicturePalette( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, /* * pointer to an array holding the palette data. The size of the array is * num_palette_entries * entry_bytes in size. The order of the components @@ -568,9 +575,10 @@ VAStatus dummy_SetSubpicturePalette( VAStatus dummy_SetSubpictureChromakey( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, unsigned int chromakey_min, - unsigned int chromakey_max + unsigned int chromakey_max, + unsigned int chromakey_mask ) { INIT_DRIVER_DATA @@ -581,7 +589,7 @@ VAStatus dummy_SetSubpictureChromakey( VAStatus dummy_SetSubpictureGlobalAlpha( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, float global_alpha ) { @@ -593,8 +601,9 @@ VAStatus dummy_SetSubpictureGlobalAlpha( VAStatus dummy_AssociateSubpicture( VADriverContextP ctx, - VASurface *target_surface, - VASubpicture *subpicture, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, short src_x, /* upper left offset in subpicture */ short src_y, short dest_x, /* upper left offset in surface */ @@ -614,15 +623,28 @@ VAStatus dummy_AssociateSubpicture( return VA_STATUS_SUCCESS; } +VAStatus dummy_DeassociateSubpicture( + VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces +) +{ + INIT_DRIVER_DATA + + /* TODO */ + return VA_STATUS_SUCCESS; +} + VAStatus dummy_CreateContext( VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height, int flag, - VASurface *render_targets, + VASurfaceID *render_targets, int num_render_targets, - VAContext *context /* out */ + VAContextID *context /* out */ ) { INIT_DRIVER_DATA @@ -648,41 +670,34 @@ VAStatus dummy_CreateContext( return vaStatus; } - obj_context->context = context; + obj_context->context_id = contextID; + *context = contextID; obj_context->current_render_target = -1; - - obj_context->context->context_id = contextID; - obj_context->context->config_id = config_id; - obj_context->context->picture_width = picture_width; - obj_context->context->picture_height = picture_height; - obj_context->context->num_render_targets = num_render_targets; - obj_context->context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); + obj_context->config_id = config_id; + obj_context->picture_width = picture_width; + obj_context->picture_height = picture_height; + obj_context->num_render_targets = num_render_targets; + obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); for(i = 0; i < num_render_targets; i++) { - if (NULL == SURFACE(render_targets[i].surface_id)) + if (NULL == SURFACE(render_targets[i])) { vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; break; } - obj_context->context->render_targets[i] = render_targets[i].surface_id; + obj_context->render_targets[i] = render_targets[i]; } - obj_context->context->flags = flag; - obj_context->context->privData = NULL; + obj_context->flags = flag; /* Error recovery */ if (VA_STATUS_SUCCESS != vaStatus) { - free(obj_context->context->render_targets); - obj_context->context->render_targets = NULL; - obj_context->context->context_id = -1; - obj_context->context->config_id = -1; - obj_context->context->picture_width = 0; - obj_context->context->picture_height = 0; - free(obj_context->context->render_targets); - obj_context->context->render_targets = NULL; - obj_context->context->num_render_targets = 0; - obj_context->context->flags = 0; - obj_context->context->privData = NULL; + obj_context->context_id = -1; + obj_context->config_id = -1; + free(obj_context->render_targets); + obj_context->render_targets = NULL; + obj_context->num_render_targets = 0; + obj_context->flags = 0; object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); } @@ -692,27 +707,25 @@ VAStatus dummy_CreateContext( VAStatus dummy_DestroyContext( VADriverContextP ctx, - VAContext *context + VAContextID context ) { INIT_DRIVER_DATA - object_context_p obj_context = CONTEXT(context->context_id); + object_context_p obj_context = CONTEXT(context); ASSERT(obj_context); - obj_context->context->context_id = -1; - obj_context->context->config_id = -1; - obj_context->context->picture_width = 0; - obj_context->context->picture_height = 0; - if (obj_context->context->render_targets) + obj_context->context_id = -1; + obj_context->config_id = -1; + obj_context->picture_width = 0; + obj_context->picture_height = 0; + if (obj_context->render_targets) { - free(obj_context->context->render_targets); + free(obj_context->render_targets); } - obj_context->context->render_targets = NULL; - obj_context->context->num_render_targets = 0; - obj_context->context->flags = 0; - obj_context->context->privData = NULL; + obj_context->render_targets = NULL; + obj_context->num_render_targets = 0; + obj_context->flags = 0; - obj_context->context = NULL; obj_context->current_render_target = -1; object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); @@ -888,8 +901,8 @@ VAStatus dummy_DestroyBuffer( VAStatus dummy_BeginPicture( VADriverContextP ctx, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ) { INIT_DRIVER_DATA @@ -897,10 +910,10 @@ VAStatus dummy_BeginPicture( object_context_p obj_context; object_surface_p obj_surface; - obj_context = CONTEXT(context->context_id); + obj_context = CONTEXT(context); ASSERT(obj_context); - obj_surface = SURFACE(render_target->surface_id); + obj_surface = SURFACE(render_target); ASSERT(obj_surface); obj_context->current_render_target = obj_surface->base.id; @@ -910,7 +923,7 @@ VAStatus dummy_BeginPicture( VAStatus dummy_RenderPicture( VADriverContextP ctx, - VAContext *context, + VAContextID context, VABufferID *buffers, int num_buffers ) @@ -921,7 +934,7 @@ VAStatus dummy_RenderPicture( object_surface_p obj_surface; int i; - obj_context = CONTEXT(context->context_id); + obj_context = CONTEXT(context); ASSERT(obj_context); obj_surface = SURFACE(obj_context->current_render_target); @@ -944,7 +957,7 @@ VAStatus dummy_RenderPicture( VAStatus dummy_EndPicture( VADriverContextP ctx, - VAContext *context + VAContextID context ) { INIT_DRIVER_DATA @@ -952,7 +965,7 @@ VAStatus dummy_EndPicture( object_context_p obj_context; object_surface_p obj_surface; - obj_context = CONTEXT(context->context_id); + obj_context = CONTEXT(context); ASSERT(obj_context); obj_surface = SURFACE(obj_context->current_render_target); @@ -967,8 +980,8 @@ VAStatus dummy_EndPicture( VAStatus dummy_SyncSurface( VADriverContextP ctx, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ) { INIT_DRIVER_DATA @@ -976,10 +989,10 @@ VAStatus dummy_SyncSurface( object_context_p obj_context; object_surface_p obj_surface; - obj_context = CONTEXT(context->context_id); + obj_context = CONTEXT(context); ASSERT(obj_context); - obj_surface = SURFACE(render_target->surface_id); + obj_surface = SURFACE(render_target); ASSERT(obj_surface); /* Assume that this shouldn't be called before vaEndPicture() */ @@ -990,38 +1003,25 @@ VAStatus dummy_SyncSurface( VAStatus dummy_QuerySurfaceStatus( VADriverContextP ctx, - VAContext *context, - VASurface *render_target, + VASurfaceID render_target, VASurfaceStatus *status /* out */ ) { INIT_DRIVER_DATA VAStatus vaStatus = VA_STATUS_SUCCESS; - object_context_p obj_context; object_surface_p obj_surface; - obj_context = CONTEXT(context->context_id); - ASSERT(obj_context); - - obj_surface = SURFACE(render_target->surface_id); + obj_surface = SURFACE(render_target); ASSERT(obj_surface); - /* Assume that we are busy until vaEndPicture() is called */ - if ( obj_context->current_render_target == obj_surface->base.id ) - { - *status = VASurfaceRendering; - } - else - { - *status = VASurfaceReady; - } + *status = VASurfaceReady; return vaStatus; } VAStatus dummy_PutSurface( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, Drawable draw, /* X Drawable */ short srcx, short srcy, @@ -1091,7 +1091,7 @@ VAStatus dummy_SetDisplayAttributes ( VAStatus dummy_DbgCopySurfaceToBuffer( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, void **buffer, /* out */ unsigned int *stride /* out */ ) @@ -1140,7 +1140,7 @@ VAStatus dummy_Terminate( VADriverContextP ctx ) return VA_STATUS_SUCCESS; } -VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) +VAStatus __vaDriverInit_0_25( VADriverContextP ctx ) { object_base_p obj; int result; @@ -1148,13 +1148,14 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) int i; ctx->version_major = 0; - ctx->version_minor = 24; + ctx->version_minor = 25; ctx->max_profiles = DUMMY_MAX_PROFILES; ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS; ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES; ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS; ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS; ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES; + ctx->str_vendor = DUMMY_STR_VENDOR; ctx->vtable.vaTerminate = dummy_Terminate; ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; @@ -1165,7 +1166,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ctx->vtable.vaDestroyConfig = dummy_DestroyConfig; ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes; ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces; - ctx->vtable.vaDestroySurface = dummy_DestroySurface; + ctx->vtable.vaDestroySurfaces = dummy_DestroySurfaces; ctx->vtable.vaCreateContext = dummy_CreateContext; ctx->vtable.vaDestroyContext = dummy_DestroyContext; ctx->vtable.vaCreateBuffer = dummy_CreateBuffer; @@ -1183,6 +1184,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats; ctx->vtable.vaCreateImage = dummy_CreateImage; ctx->vtable.vaDestroyImage = dummy_DestroyImage; + ctx->vtable.vaSetImagePalette = dummy_SetImagePalette; ctx->vtable.vaGetImage = dummy_GetImage; ctx->vtable.vaPutImage = dummy_PutImage; ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats; @@ -1193,6 +1195,7 @@ VAStatus __vaDriverInit_0_24( VADriverContextP ctx ) ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey; ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha; ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture; + ctx->vtable.vaDeassociateSubpicture = dummy_DeassociateSubpicture; ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes; ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes; ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes; diff --git a/dummy_drv_video/dummy_drv_video.h b/dummy_drv_video/dummy_drv_video.h index 81a9a44..d1920ab 100644 --- a/dummy_drv_video/dummy_drv_video.h +++ b/dummy_drv_video/dummy_drv_video.h @@ -34,6 +34,7 @@ #define DUMMY_MAX_IMAGE_FORMATS 10 #define DUMMY_MAX_SUBPIC_FORMATS 4 #define DUMMY_MAX_DISPLAY_ATTRIBUTES 4 +#define DUMMY_STR_VENDOR "Dummy-dummy-1.0-dummy" struct dummy_driver_data { struct object_heap config_heap; @@ -52,14 +53,19 @@ struct object_config { struct object_context { struct object_base base; - VAContext *context; - VAConfigID config; + VAContextID context_id; + VAConfigID config_id; VASurfaceID current_render_target; + int picture_width; + int picture_height; + int num_render_targets; + int flags; + VASurfaceID *render_targets; }; struct object_surface { struct object_base base; - VASurface *surface; + VASurfaceID surface_id; }; struct object_buffer { diff --git a/src/va.c b/src/va.c index 0a9f6cc..2e4fd5e 100644 --- a/src/va.c +++ b/src/va.c @@ -36,13 +36,14 @@ #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri" #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 CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } #define ASSERT assert #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; +#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func); @@ -134,6 +135,16 @@ static Bool va_checkMaximum(int value, char *variable) return True; } +static Bool va_checkString(const char* value, char *variable) +{ + if (!value) + { + va_errorMessage("Failed to define str_%s in init\n", variable); + return False; + } + return True; +} + static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name) { VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; @@ -255,6 +266,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) CHECK_MAXIMUM(vaStatus, ctx, image_formats); CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); CHECK_MAXIMUM(vaStatus, ctx, display_attributes); + CHECK_STRING(vaStatus, ctx, vendor); CHECK_VTABLE(vaStatus, ctx, Terminate); CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); @@ -263,7 +275,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) CHECK_VTABLE(vaStatus, ctx, DestroyConfig); CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes); CHECK_VTABLE(vaStatus, ctx, CreateSurfaces); - CHECK_VTABLE(vaStatus, ctx, DestroySurface); + CHECK_VTABLE(vaStatus, ctx, DestroySurfaces); CHECK_VTABLE(vaStatus, ctx, CreateContext); CHECK_VTABLE(vaStatus, ctx, DestroyContext); CHECK_VTABLE(vaStatus, ctx, CreateBuffer); @@ -281,6 +293,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) CHECK_VTABLE(vaStatus, ctx, QueryImageFormats); CHECK_VTABLE(vaStatus, ctx, CreateImage); CHECK_VTABLE(vaStatus, ctx, DestroyImage); + CHECK_VTABLE(vaStatus, ctx, SetImagePalette); CHECK_VTABLE(vaStatus, ctx, GetImage); CHECK_VTABLE(vaStatus, ctx, PutImage); CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats); @@ -291,6 +304,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey); CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha); CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture); + CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture); CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes); CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes); CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); @@ -429,6 +443,28 @@ VAStatus vaTerminate ( return vaStatus; } +/* + * vaQueryVendorString returns a pointer to a zero-terminated string + * describing some aspects of the VA implemenation on a specific + * hardware accelerator. The format of the returned string is: + * --- + * e.g. for the Intel GMA500 implementation, an example would be: + * "IntelGMA500-1.0-0.2-patch3 + */ +const char *vaQueryVendorString ( + VADisplay dpy +) +{ + VADriverContextP ctx = CTX(dpy); + if( !vaContextIsValid(ctx) ) + { + return NULL; + } + + return ctx->str_vendor; +} + + /* Get maximum number of profiles supported by the implementation */ int vaMaxNumProfiles ( VADisplay dpy @@ -564,7 +600,7 @@ VAStatus vaCreateSurfaces ( int height, int format, int num_surfaces, - VASurface *surfaces /* out */ + VASurfaceID *surfaces /* out */ ) { VADriverContextP ctx = CTX(dpy); @@ -574,17 +610,17 @@ VAStatus vaCreateSurfaces ( return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces ); } -VAStatus vaDestroySurface ( +VAStatus vaDestroySurfaces ( VADisplay dpy, - VASurface *surface_list, + VASurfaceID *surface_list, int num_surfaces ) { VADriverContextP ctx = CTX(dpy); CHECK_CONTEXT(ctx); - TRACE(vaDestroySurface); - return ctx->vtable.vaDestroySurface( ctx, surface_list, num_surfaces ); + TRACE(vaDestroySurfaces); + return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces ); } VAStatus vaCreateContext ( @@ -593,9 +629,9 @@ VAStatus vaCreateContext ( int picture_width, int picture_height, int flag, - VASurface *render_targets, + VASurfaceID *render_targets, int num_render_targets, - VAContext *context /* out */ + VAContextID *context /* out */ ) { VADriverContextP ctx = CTX(dpy); @@ -608,7 +644,7 @@ VAStatus vaCreateContext ( VAStatus vaDestroyContext ( VADisplay dpy, - VAContext *context + VAContextID context ) { VADriverContextP ctx = CTX(dpy); @@ -699,8 +735,8 @@ VAStatus vaDestroyBuffer ( VAStatus vaBeginPicture ( VADisplay dpy, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ) { VADriverContextP ctx = CTX(dpy); @@ -712,7 +748,7 @@ VAStatus vaBeginPicture ( VAStatus vaRenderPicture ( VADisplay dpy, - VAContext *context, + VAContextID context, VABufferID *buffers, int num_buffers ) @@ -726,7 +762,7 @@ VAStatus vaRenderPicture ( VAStatus vaEndPicture ( VADisplay dpy, - VAContext *context + VAContextID context ) { VADriverContextP ctx = CTX(dpy); @@ -738,8 +774,8 @@ VAStatus vaEndPicture ( VAStatus vaSyncSurface ( VADisplay dpy, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ) { VADriverContextP ctx = CTX(dpy); @@ -751,8 +787,7 @@ VAStatus vaSyncSurface ( VAStatus vaQuerySurfaceStatus ( VADisplay dpy, - VAContext *context, - VASurface *render_target, + VASurfaceID render_target, VASurfaceStatus *status /* out */ ) { @@ -760,12 +795,12 @@ VAStatus vaQuerySurfaceStatus ( CHECK_CONTEXT(ctx); TRACE(vaQuerySurfaceStatus); - return ctx->vtable.vaQuerySurfaceStatus( ctx, context, render_target, status ); + return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status ); } VAStatus vaPutSurface ( VADisplay dpy, - VASurface *surface, + VASurfaceID surface, Drawable draw, /* X Drawable */ short srcx, short srcy, @@ -844,7 +879,7 @@ VAStatus vaCreateImage ( */ VAStatus vaDestroyImage ( VADisplay dpy, - VAImage *image + VAImageID image ) { VADriverContextP ctx = CTX(dpy); @@ -854,18 +889,31 @@ VAStatus vaDestroyImage ( return ctx->vtable.vaDestroyImage ( ctx, image); } +VAStatus vaSetImagePalette ( + VADisplay dpy, + VAImageID image, + unsigned char *palette +) +{ + VADriverContextP ctx = CTX(dpy); + CHECK_CONTEXT(ctx); + + TRACE(vaSetImagePalette); + return ctx->vtable.vaSetImagePalette ( ctx, image, palette); +} + /* * Retrieve surface data into a VAImage * Image must be in a format supported by the implementation */ VAStatus vaGetImage ( VADisplay dpy, - VASurface *surface, + VASurfaceID surface, int x, /* coordinates of the upper left source pixel */ int y, unsigned int width, /* width and height of the region */ unsigned int height, - VAImage *image + VAImageID image ) { VADriverContextP ctx = CTX(dpy); @@ -881,8 +929,8 @@ VAStatus vaGetImage ( */ VAStatus vaPutImage ( VADisplay dpy, - VASurface *surface, - VAImage *image, + VASurfaceID surface, + VAImageID image, int src_x, int src_y, unsigned int width, @@ -938,8 +986,8 @@ VAStatus vaQuerySubpictureFormats ( */ VAStatus vaCreateSubpicture ( VADisplay dpy, - VAImage *image, - VASubpicture *subpicture /* out */ + VAImageID image, + VASubpictureID *subpicture /* out */ ) { VADriverContextP ctx = CTX(dpy); @@ -954,7 +1002,7 @@ VAStatus vaCreateSubpicture ( */ VAStatus vaDestroySubpicture ( VADisplay dpy, - VASubpicture *subpicture + VASubpictureID subpicture ) { VADriverContextP ctx = CTX(dpy); @@ -966,8 +1014,8 @@ VAStatus vaDestroySubpicture ( VAStatus vaSetSubpictureImage ( VADisplay dpy, - VASubpicture *subpicture, - VAImage *image + VASubpictureID subpicture, + VAImageID image ) { VADriverContextP ctx = CTX(dpy); @@ -980,7 +1028,7 @@ VAStatus vaSetSubpictureImage ( VAStatus vaSetSubpicturePalette ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, /* * pointer to an array holding the palette data. The size of the array is * num_palette_entries * entry_bytes in size. The order of the components @@ -1002,16 +1050,17 @@ VAStatus vaSetSubpicturePalette ( */ VAStatus vaSetSubpictureChromakey ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, unsigned int chromakey_min, - unsigned int chromakey_max + unsigned int chromakey_max, + unsigned int chromakey_mask ) { VADriverContextP ctx = CTX(dpy); CHECK_CONTEXT(ctx); TRACE(vaSetSubpictureChromakey); - return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max ); + return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask ); } @@ -1022,7 +1071,7 @@ VAStatus vaSetSubpictureChromakey ( */ VAStatus vaSetSubpictureGlobalAlpha ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, float global_alpha ) { @@ -1042,8 +1091,9 @@ VAStatus vaSetSubpictureGlobalAlpha ( */ VAStatus vaAssociateSubpicture ( VADisplay dpy, - VASurface *target_surface, - VASubpicture *subpicture, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, short src_x, /* upper left offset in subpicture */ short src_y, short dest_x, /* upper left offset in surface */ @@ -1061,9 +1111,27 @@ VAStatus vaAssociateSubpicture ( CHECK_CONTEXT(ctx); TRACE(vaAssociateSubpicture); - return ctx->vtable.vaAssociateSubpicture ( ctx, target_surface, subpicture, src_x, src_y, dest_x, dest_y, width, height, flags ); + return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags ); } +/* + * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces. + */ +VAStatus vaDeassociateSubpicture ( + VADisplay dpy, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces +) +{ + VADriverContextP ctx = CTX(dpy); + CHECK_CONTEXT(ctx); + + TRACE(vaDeassociateSubpicture); + return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces ); +} + + /* Get maximum number of display attributes supported by the implementation */ int vaMaxNumDisplayAttributes ( VADisplay dpy @@ -1138,7 +1206,7 @@ VAStatus vaSetDisplayAttributes ( VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, - VASurface *surface, + VASurfaceID surface, void **buffer, /* out */ unsigned int *stride /* out */ ) diff --git a/src/va.h b/src/va.h index c158923..01c5b87 100755 --- a/src/va.h +++ b/src/va.h @@ -24,7 +24,7 @@ /* * Video Decode Acceleration API Specification * - * Rev. 0.24 + * Rev. 0.25 * * * Revision History: @@ -33,22 +33,24 @@ * rev 0.12 (02/05/2007 Jonathan Bian) - Added VC-1 data structures for slice level decode * rev 0.13 (02/28/2007 Jonathan Bian) - Added GetDisplay() * rev 0.14 (04/13/2007 Jonathan Bian) - Fixed MPEG-2 PictureParameter structure, cleaned up a few funcs. - * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management - * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration + * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management + * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration * rev 0.17 (05/07/2007 Jonathan Bian) - Added H.264/AVC data structures for slice level decode. * rev 0.18 (05/14/2007 Jonathan Bian) - Added data structures for MPEG-4 slice level decode * and MPEG-2 motion compensation. - * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data. - * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure. - * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support. + * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data. + * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure. + * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support. * rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha. - * rev 0.23 (09/07/2007 Jonathan Bian) - Fixed some issues with images and subpictures. - * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes. + * rev 0.23 (09/11/2007 Jonathan Bian) - Fixed some issues with images and subpictures. + * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes. + * rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types. * * Acknowledgements: * Some concepts borrowed from XvMC and XvImage. - * Thanks to Waldo Bastian for many valuable feedbacks. + * Thanks to Waldo Bastian, Matt Sottek and Austin Yuan at Intel for many valuable feedbacks. */ + #ifndef _VA_H_ #define _VA_H_ @@ -59,7 +61,10 @@ extern "C" { /* Overview -This is currently a decode only interface (with some rendering support). +This API is intended to provide an interface between a video decode +application (client) and a hardware decode accelerator (server), to off-load +video decode operations from the host to the hardware accelerator at various +entry-points. The basic operation steps are: @@ -93,12 +98,15 @@ typedef int VAStatus; /* Return status type from functions */ #define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005 #define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006 #define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007 -#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x00000008 -#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x00000009 -#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000a -#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000b -#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000c -#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000d +#define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008 +#define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009 +#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a +#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b +#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c +#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000d +#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e +#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f +#define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF /* @@ -119,6 +127,9 @@ VADisplay vaGetDisplay ( NativeDisplay native_dpy /* implementation specific */ ); +/* + * Initialize the library + */ VAStatus vaInitialize ( VADisplay dpy, int *major_version, /* out */ @@ -132,6 +143,18 @@ VAStatus vaTerminate ( VADisplay dpy ); +/* + * vaQueryVendorString returns a pointer to a zero-terminated string + * describing some aspects of the VA implemenation on a specific + * hardware accelerator. The format of the returned string is: + * --- + * e.g. for the Intel GMA500 implementation, an example would be: + * "IntelGMA500-1.0-0.2-patch3 + */ +const char *vaQueryVendorString ( + VADisplay dpy +); + /* Currently defined profiles */ typedef enum { @@ -234,8 +257,8 @@ VAStatus vaQueryConfigEntrypoints ( /* * Get attributes for a given profile/entrypoint pair - * The caller must provide an “attrib_list” with all attributes to be - * queried. Upon return, the attributes in “attrib_list” have been + * The caller must provide an "attrib_list" with all attributes to be + * retrieved. Upon return, the attributes in "attrib_list" have been * updated with their value. Unknown attributes or attributes that are * not supported for the given profile/entrypoint pair will have their * value set to VA_ATTRIB_NOT_SUPPORTED @@ -277,11 +300,11 @@ VAStatus vaDestroyConfig ( /* * Query all attributes for a given configuration - * The profile of the configuration is returned in “profile” - * The entrypoint of the configuration is returned in “entrypoint” - * The caller must provide an “attrib_list” array that can hold at least + * The profile of the configuration is returned in "profile" + * The entrypoint of the configuration is returned in "entrypoint" + * The caller must provide an "attrib_list" array that can hold at least * vaMaxNumConfigAttributes() entries. The actual number of attributes - * returned in “attrib_list” is returned in “num_attribs” + * returned in "attrib_list" is returned in "num_attribs" */ VAStatus vaQueryConfigAttributes ( VADisplay dpy, @@ -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. * - * Context represents a "virtual" video decode pipeline + * Surfaces will be bound to a context when the context is created. Once + * a surface is bound to a given context, it can not be used to create + * another context. The association is removed when the context is destroyed + * + * Both contexts and surfaces are identified by unique IDs and its + * implementation specific internals are kept opaque to the clients */ typedef VAGenericID VAContextID; @@ -305,97 +338,78 @@ typedef VAGenericID VASurfaceID; #define VA_INVALID_SURFACE -1 -typedef struct _VAContext -{ - VAContextID context_id; /* to identify this context */ - VAConfigID config_id; - unsigned short picture_width; - unsigned short picture_height; - VASurfaceID *render_targets; - int num_render_targets; - int flags; - void *privData; -} VAContext; - -/* - flags - Any combination of the following: - VA_PROGRESSIVE (only progressive frame pictures in the sequence when set) -*/ -#define VA_PROGRESSIVE 0x1 - -/* - -Surface Management - -Surfaces are render targets for a given context. The data in the surfaces -are not accessible to the client and the internal data format of -the surface is implementatin specific. - -Question: Is there a need to know the data format (fourcc) or just -differentiate between 420/422/444 is sufficient? - -*/ - -typedef struct _VASurface -{ - VASurfaceID surface_id; /* uniquely identify this surface */ - VAContextID context_id; /* which context does this surface belong */ - unsigned short width; - unsigned short height; - int format; /* 420/422/444 */ - void *privData; /* private to the library */ -} VASurface; - /* - * Surfaces will be bound to a context when the context is created. Once - * a surface is bound to a given context, it can not be used to create - * another context. The association is removed when the context is destroyed + * vaCreateSurfaces - Create an array of surfaces used for decode and display + * dpy: display + * width: surface width + * height: surface height + * format: VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV422 or VA_RT_FORMAT_YUV444 + * num_surfaces: number of surfaces to be created + * surfaces: array of surfaces created upon return */ - -/* Surface Functions */ VAStatus vaCreateSurfaces ( VADisplay dpy, int width, int height, int format, int num_surfaces, - VASurface *surfaces /* out */ + VASurfaceID *surfaces /* out */ ); /* - * surfaces can only be destroyed after the context associated has been - * destroyed + * vaDestroySurfaces - Destroy resources associated with surfaces. + * Surfaces can only be destroyed after the context associated has been + * destroyed. + * dpy: display + * surfaces: array of surfaces to destroy + * num_surfaces: number of surfaces in the array to be destroyed. */ -VAStatus vaDestroySurface ( +VAStatus vaDestroySurfaces ( VADisplay dpy, - VASurface *surface_list, + VASurfaceID *surfaces, int num_surfaces ); +#define VA_PROGRESSIVE 0x1 +/* + * vaCreateContext - Create a context + * dpy: display + * config_id: configuration for the context + * picture_width: coded picture width + * picture_height: coded picture height + * flag: any combination of the following: + * VA_PROGRESSIVE (only progressive frame pictures in the sequence when set) + * render_targets: render targets (surfaces) tied to the context + * num_render_targets: number of render targets in the above array + * context: created context id upon return + */ VAStatus vaCreateContext ( VADisplay dpy, VAConfigID config_id, int picture_width, int picture_height, int flag, - VASurface *render_targets, + VASurfaceID *render_targets, int num_render_targets, - VAContext *context /* out */ + VAContextID *context /* out */ ); +/* + * vaDestroyContext - Destroy a context + * dpy: display + * context: context to be destroyed + */ VAStatus vaDestroyContext ( VADisplay dpy, - VAContext *context + VAContextID context ); /* - * - * Buffers - * Buffers are used to pass various types of data from the - * client to the server. The server maintains a data store - * for each buffer created, and the client idenfies a buffer - * through a unique buffer id assigned by the server. - * + * Buffers + * Buffers are used to pass various types of data from the + * client to the server. The server maintains a data store + * for each buffer created, and the client idenfies a buffer + * through a unique buffer id assigned by the server. */ typedef VAGenericID VABufferID; @@ -621,7 +635,16 @@ typedef struct _VASliceParameterBufferMPEG4 /* VC-1 data structures */ - + +typedef enum /* see 7.1.1.32 */ +{ + VAMvMode1Mv = 0, + VAMvMode1MvHalfPel = 1, + VAMvMode1MvHalfPelBilinear = 2, + VAMvModeMixedMv = 3, + VAMvModeIntensityCompensation = 4 +} VAMvModeVC1; + /* VC-1 Picture Parameter Buffer */ /* * For each picture, and before any slice data, a picture parameter @@ -691,7 +714,7 @@ typedef struct _VAPictureParameterBufferVC1 unsigned char picture_fields; }; union { - struct { + struct { unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ @@ -704,6 +727,18 @@ typedef struct _VAPictureParameterBufferVC1 }; union { struct { + unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ + unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ + unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ + unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ + unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ + unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ + unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ + }; + unsigned char bitplane_present_flag; /* signal what bitplane is being passed via the bitplane buffer */ + }; + union { + struct { unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ unsigned char reference_distance : 1;/* PICTURE_LAYER::REFDIST */ unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ @@ -713,16 +748,16 @@ typedef struct _VAPictureParameterBufferVC1 }; union { struct { - unsigned char mv_mode : 3; /* PICTURE_LAYER::MVMODE */ - unsigned char mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ - unsigned char mv_table : 3;/* PICTURE_LAYER::MVTAB/IMVTAB */ - unsigned char two_mv_block_pattern_table: 2;/* PICTURE_LAYER::2MVBPTAB */ - unsigned char four_mv_switch: 1; /* PICTURE_LAYER::4MVSWITCH */ - unsigned char four_mv_block_pattern_table : 2;/* PICTURE_LAYER::4MVBPTAB */ - unsigned char extended_mv_flag: 1;/* ENTRY_POINT_LAYER::EXTENDED_MV */ - unsigned char extended_mv_range : 2;/* PICTURE_LAYER::MVRANGE */ - unsigned char extended_dmv_flag : 1;/* ENTRY_POINT_LAYER::EXTENDED_DMV */ - unsigned char extended_dmv_range : 2;/* PICTURE_LAYER::DMVRANGE */ + VAMvModeVC1 mv_mode : 3; /* PICTURE_LAYER::MVMODE */ + VAMvModeVC1 mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ + unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ + unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ + unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ + unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ + unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ + unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ + unsigned char extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */ + unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ }; unsigned int mv_fields; }; @@ -905,6 +940,8 @@ typedef struct _VASliceParameterBufferH264 /* * Creates a buffer for storing a certain type of data, no data store allocated + * Note: image buffers are created by the library, not the client. Please see + * vaCreateImage on how image buffers are managed. */ VAStatus vaCreateBuffer ( VADisplay dpy, @@ -985,8 +1022,8 @@ The Begin/Render/End sequence sends the decode buffers to the server */ VAStatus vaBeginPicture ( VADisplay dpy, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ); /* @@ -994,7 +1031,7 @@ VAStatus vaBeginPicture ( */ VAStatus vaRenderPicture ( VADisplay dpy, - VAContext *context, + VAContextID context, VABufferID *buffers, int num_buffers ); @@ -1007,7 +1044,7 @@ VAStatus vaRenderPicture ( */ VAStatus vaEndPicture ( VADisplay dpy, - VAContext *context + VAContextID context ); /* @@ -1023,8 +1060,8 @@ Synchronization */ VAStatus vaSyncSurface ( VADisplay dpy, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ); typedef enum @@ -1041,8 +1078,7 @@ typedef enum */ VAStatus vaQuerySurfaceStatus ( VADisplay dpy, - VAContext *context, - VASurface *render_target, + VASurfaceID render_target, VASurfaceStatus *status /* out */ ); @@ -1053,7 +1089,7 @@ VAStatus vaQuerySurfaceStatus ( * Caller should free the returned buffer with free() when done. */ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, - VASurface *surface, + VASurfaceID surface, void **buffer, /* out */ unsigned int *stride /* out */ ); @@ -1096,28 +1132,38 @@ typedef struct _VAImage VABufferID buf; /* image data buffer */ /* * Image data will be stored in a buffer of type VAImageBufferType to facilitate - * data store on the server side for optimal performance. - * It is expected that the client will first call vaCreateImage which returns a VAImage - * structure with the following fields filled by the library. It will then - * create the "buf" with vaBufferCreate. For PutImage, then client will call - * vaBufferData() with the image data before calling PutImage, and for GetImage - * the client will call vaBufferData() with a NULL data pointer, and then call GetImage. - * After that the client can use the Map/Unmap buffer functions to access the image data. + * data store on the server side for optimal performance. The buffer will be + * created by the CreateImage function, and proper storage allocated based on the image + * size and format. This buffer is managed by the library implementation, and + * accessed by the client through the buffer Map/Unmap functions. */ unsigned short width; unsigned short height; unsigned int data_size; - unsigned int num_planes; + unsigned int num_planes; /* can not be greater than 3 */ + /* + * An array indicating the scanline pitch in bytes for each plane. + * Each plane may have a different pitch. Maximum 3 planes for planar formats + */ + unsigned int pitches[3]; /* - * An array of size num_planes indicating the scanline pitch in bytes. - * Each plane may have a different pitch. + * An array indicating the byte offset from the beginning of the image data + * to the start of each plane. */ - unsigned int *pitches; + unsigned int offsets[3]; + + /* The following fields are only needed for paletted formats */ + int num_palette_entries; /* set to zero for non-palette images */ /* - * An array of size num_planes indicating the byte offset from - * the beginning of the image data to the start of each plane. + * Each component is one byte and entry_bytes indicates the number of components in + * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images + */ + int entry_bytes; + /* + * An array of ascii characters describing the order of the components within the bytes. + * Only entry_bytes characters of the string are used. */ - unsigned int *offsets; + char component_order[4]; } VAImage; /* Get maximum number of image formats supported by the implementation */ @@ -1140,11 +1186,9 @@ VAStatus vaQueryImageFormats ( /* * Create a VAImage structure * The width and height fields returned in the VAImage structure may get - * enlarged for some YUV formats. The size of the data buffer that needs - * to be allocated will be given in the "data_size" field in VAImage. - * Image data is not allocated by this function. The client should - * allocate the memory required for the data and fill in the data field after - * looking at "data_size" returned from this call. + * enlarged for some YUV formats. Upon return from this function, + * image->buf has been created and proper storage allocated by the library. + * The client can access the image through the Map/Unmap calls. */ VAStatus vaCreateImage ( VADisplay dpy, @@ -1159,7 +1203,18 @@ VAStatus vaCreateImage ( */ VAStatus vaDestroyImage ( VADisplay dpy, - VAImage *image + VAImageID image +); + +VAStatus vaSetImagePalette ( + VADisplay dpy, + VAImageID image, + /* + * pointer to an array holding the palette data. The size of the array is + * num_palette_entries * entry_bytes in size. The order of the components + * in the palette is described by the component_order in VAImage struct + */ + unsigned char *palette ); /* @@ -1168,22 +1223,26 @@ VAStatus vaDestroyImage ( */ VAStatus vaGetImage ( VADisplay dpy, - VASurface *surface, + VASurfaceID surface, int x, /* coordinates of the upper left source pixel */ int y, unsigned int width, /* width and height of the region */ unsigned int height, - VAImage *image + VAImageID image ); /* * Copy data from a VAImage to a surface * Image must be in a format supported by the implementation + * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface + * shouldn't be rendered into when this is called + * The source and destionation width and height are the same and + * no scaling is performed with this operation. */ VAStatus vaPutImage ( VADisplay dpy, - VASurface *surface, - VAImage *image, + VASurfaceID surface, + VAImageID image, int src_x, int src_y, unsigned int width, @@ -1201,50 +1260,23 @@ VAStatus vaPutImage ( typedef VAGenericID VASubpictureID; -typedef struct _VASubpicture -{ - VASubpictureID subpicture_id; /* uniquely identify this subpicture */ - VASurfaceID surface_id; /* which surface does this subpicture associate with */ - VAImageID image_id; - /* The following fields are set by the library */ - int num_palette_entries; /* paletted formats only. set to zero for image without palettes */ - /* - * Each component is one byte and entry_bytes indicates the number of components in - * each entry (eg. 3 for YUV palette entries). set to zero for image without palettes - */ - int entry_bytes; - /* - * An array of ascii characters describing teh order of the components within the bytes. - * Only entry_bytes characters of the string are used. - */ - char component_order[4]; - - /* chromakey range */ - unsigned int chromakey_min; - unsigned int chromakey_max; - - /* global alpha */ - unsigned int global_alpha; - - /* flags */ - unsigned int flags; /* see below */ -} VASubpicture; - -/* flags for subpictures */ -#define VA_SUBPICTURE_CHROMA_KEYING 0x0001 -#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002 - /* Get maximum number of subpicture formats supported by the implementation */ int vaMaxNumSubpictureFormats ( VADisplay dpy ); +/* flags for subpictures */ +#define VA_SUBPICTURE_CHROMA_KEYING 0x0001 +#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002 /* * Query supported subpicture formats * The caller must provide a "format_list" array that can hold at * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag * for each format to indicate additional capabilities for that format. The actual * number of formats returned in "format_list" is returned in "num_formats". + * flags: returned value to indicate addtional capabilities + * VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying + * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha */ VAStatus vaQuerySubpictureFormats ( VADisplay dpy, @@ -1258,8 +1290,8 @@ VAStatus vaQuerySubpictureFormats ( */ VAStatus vaCreateSubpicture ( VADisplay dpy, - VAImage *image, - VASubpicture *subpicture /* out */ + VAImageID image, + VASubpictureID *subpicture /* out */ ); /* @@ -1267,7 +1299,7 @@ VAStatus vaCreateSubpicture ( */ VAStatus vaDestroySubpicture ( VADisplay dpy, - VASubpicture *subpicture + VASubpictureID subpicture ); /* @@ -1276,17 +1308,17 @@ VAStatus vaDestroySubpicture ( */ VAStatus vaSetSubpictureImage ( VADisplay dpy, - VASubpicture *subpicture, - VAImage *image + VASubpictureID subpicture, + VAImageID image ); VAStatus vaSetSubpicturePalette ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, /* * pointer to an array holding the palette data. The size of the array is * num_palette_entries * entry_bytes in size. The order of the components - * in the palette is described by the component_order in VASubpicture struct + * in the palette is described by the component_order in VAImage struct */ unsigned char *palette ); @@ -1294,12 +1326,18 @@ VAStatus vaSetSubpicturePalette ( /* * If chromakey is enabled, then the area where the source value falls within * the chromakey [min, max] range is transparent + * The chromakey component format is the following: + * For RGB: [0:7] Red [8:15] Blue [16:23] Green + * For YUV: [0:7] V [8:15] U [16:23] Y + * The chromakey mask can be used to mask out certain components for chromakey + * comparision */ VAStatus vaSetSubpictureChromakey ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, unsigned int chromakey_min, - unsigned int chromakey_max + unsigned int chromakey_max, + unsigned int chromakey_mask ); /* @@ -1309,21 +1347,22 @@ VAStatus vaSetSubpictureChromakey ( */ VAStatus vaSetSubpictureGlobalAlpha ( VADisplay dpy, - VASubpicture *subpicture, + VASubpictureID subpicture, float global_alpha ); /* - vaAssociateSubpicture associates the subpicture with the target_surface. - It defines the region mapping between the subpicture and the target - surface through source and destination rectangles (with the same width and height). - Both will be displayed at the next call to vaPutSurface. Additional - associations before the call to vaPutSurface simply overrides the association. -*/ + * vaAssociateSubpicture associates the subpicture with target_surfaces. + * It defines the region mapping between the subpicture and the target + * surfaces through source and destination rectangles (with the same width and height). + * Both will be displayed at the next call to vaPutSurface. Additional + * associations before the call to vaPutSurface simply overrides the association. + */ VAStatus vaAssociateSubpicture ( VADisplay dpy, - VASurface *target_surface, - VASubpicture *subpicture, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, short src_x, /* upper left offset in subpicture */ short src_y, short dest_x, /* upper left offset in surface */ @@ -1337,6 +1376,16 @@ VAStatus vaAssociateSubpicture ( unsigned int flags ); +/* + * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces. + */ +VAStatus vaDeassociateSubpicture ( + VADisplay dpy, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces +); + typedef struct _VARectangle { short x; @@ -1360,6 +1409,17 @@ typedef enum VADisplayAttribContrast = 1, VADisplayAttribHue = 2, VADisplayAttribSaturation = 3, + /* client can specifiy a background color for the target window */ + VADisplayAttribBackgroundColor = 4, + /* + * this is a gettable only attribute. For some implementations that use the + * hardware overlay, after PutSurface is called, the surface can not be + * re-used until after the subsequent PutSurface call. If this is the case + * then the value for this attribute will be set to 1 so that the client + * will not attempt to re-use the surface right after returning from a call + * to PutSurface. + */ + VADisplayAttribDirectSurface = 5, } VADisplayAttribType; /* flags for VADisplayAttribute */ @@ -1475,13 +1535,13 @@ Mostly to demonstrate program flow with no error handling ... * create surfaces for the current target as well as reference frames * we can get by with 4 surfaces for MPEG-2 */ - VASurface surfaces[4]; + VASurfaceID surfaces[4]; vaCreateSurfaces(dpy, 720, 480, VA_RT_FORMAT_YUV420, 4, surfaces); /* * Create a context for this decode pipe */ - VAContext context; + VAContextID context; vaCreateContext(dpy, config_id, 720, 480, VA_PROGRESSIVE, surfaces, 4, &context); @@ -1497,7 +1557,6 @@ Mostly to demonstrate program flow with no error handling ... /* fill in picture_coding_extension fields here */ vaUnmapBuffer(dpy, picture_buf); - /* Create an IQ matrix buffer for this frame */ VABufferID iq_buf; VAIQMatrixBufferMPEG2 *iq_matrix; @@ -1508,7 +1567,7 @@ Mostly to demonstrate program flow with no error handling ... vaUnmapBuffer(dpy, iq_buf); /* send the picture and IQ matrix buffers to the server */ - vaBeginPicture(dpy, context, &surfaces[0]); + vaBeginPicture(dpy, context, surfaces[0]); vaRenderPicture(dpy, context, &picture_buf, 1); vaRenderPicture(dpy, context, &iq_buf, 1); @@ -1559,17 +1618,17 @@ Mostly to demonstrate program flow with no error handling ... vaQuerySubpictureFormats(dpy, sub_formats, &num_formats); /* Assume that we find AI44 as a subpicture format in sub_formats[0] */ VAImage sub_image; - VASubpicture subpicture; - unsigned char sub_data[128][16]; + VASubpictureID subpicture; + unsigned char *sub_data; /* create an image for the subtitle */ vaCreateImage(dpy, sub_formats, 128, 16, &sub_image); - vaCreateBuffer(dpy, VAImageBufferType, &sub_image->buf); + vaMapBuffer(dpy, sub_image->buf, &sub_data); /* fill the image data */ - vaBufferData(dpy, sub_image->buf, sub_image->data_size, sub_data); - vaCreateSubpicture(dpy, &sub_image, &subpicture); + vaUnmapBuffer(dpy, sub_image->buf); + vaCreateSubpicture(dpy, sub_image, &subpicture); unsigned char palette[3][16]; /* fill the palette data */ - vaSetSubpicturePalette(dpy, &subpicture, palette); - vaAssociateSubpicture(dpy, surfaces, &subpicture, 0, 0, 296, 400, 128, 16); + vaSetSubpicturePalette(dpy, subpicture, palette); + vaAssociateSubpicture(dpy, subpicture, surfaces, 1, 0, 0, 296, 400, 128, 16); vaPutSurface(dpy, surfaces, win, 0, 0, 720, 480, 100, 100, 640, 480, NULL, 0, 0); #endif diff --git a/src/va_backend.h b/src/va_backend.h index 68149e4..890b07e 100755 --- a/src/va_backend.h +++ b/src/va_backend.h @@ -34,28 +34,14 @@ #include + 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) ( VADriverContextP ctx, VAProfile *profile_list, /* out */ int *num_profiles /* out */ @@ -105,12 +91,12 @@ struct VADriverContext int height, int format, int num_surfaces, - VASurface *surfaces /* out */ + VASurfaceID *surfaces /* out */ ); - VAStatus (*vaDestroySurface) ( + VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, - VASurface *surface_list, + VASurfaceID *surface_list, int num_surfaces ); @@ -120,14 +106,14 @@ struct VADriverContext int picture_width, int picture_height, int flag, - VASurface *render_targets, + VASurfaceID *render_targets, int num_render_targets, - VAContext *context /* out */ + VAContextID *context /* out */ ); VAStatus (*vaDestroyContext) ( VADriverContextP ctx, - VAContext *context + VAContextID context ); VAStatus (*vaCreateBuffer) ( @@ -168,38 +154,37 @@ struct VADriverContext VAStatus (*vaBeginPicture) ( VADriverContextP ctx, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ); VAStatus (*vaRenderPicture) ( VADriverContextP ctx, - VAContext *context, + VAContextID context, VABufferID *buffers, int num_buffers ); VAStatus (*vaEndPicture) ( VADriverContextP ctx, - VAContext *context + VAContextID context ); VAStatus (*vaSyncSurface) ( VADriverContextP ctx, - VAContext *context, - VASurface *render_target + VAContextID context, + VASurfaceID render_target ); VAStatus (*vaQuerySurfaceStatus) ( VADriverContextP ctx, - VAContext *context, - VASurface *render_target, + VASurfaceID render_target, VASurfaceStatus *status /* out */ ); VAStatus (*vaPutSurface) ( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, Drawable draw, /* X Drawable */ short srcx, short srcy, @@ -230,23 +215,34 @@ struct VADriverContext VAStatus (*vaDestroyImage) ( VADriverContextP ctx, - VAImage *image + VAImageID image ); - + + VAStatus (*vaSetImagePalette) ( + VADriverContextP ctx, + VAImageID image, + /* + * pointer to an array holding the palette data. The size of the array is + * num_palette_entries * entry_bytes in size. The order of the components + * in the palette is described by the component_order in VAImage struct + */ + unsigned char *palette + ); + VAStatus (*vaGetImage) ( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, int x, /* coordinates of the upper left source pixel */ int y, unsigned int width, /* width and height of the region */ unsigned int height, - VAImage *image + VAImageID image ); VAStatus (*vaPutImage) ( VADriverContextP ctx, - VASurface *surface, - VAImage *image, + VASurfaceID surface, + VAImageID image, int src_x, int src_y, unsigned int width, @@ -264,24 +260,24 @@ struct VADriverContext VAStatus (*vaCreateSubpicture) ( VADriverContextP ctx, - VAImage *image, - VASubpicture *subpicture /* out */ + VAImageID image, + VASubpictureID *subpicture /* out */ ); VAStatus (*vaDestroySubpicture) ( VADriverContextP ctx, - VASubpicture *subpicture + VASubpictureID subpicture ); VAStatus (*vaSetSubpictureImage) ( VADriverContextP ctx, - VASubpicture *subpicture, - VAImage *image + VASubpictureID subpicture, + VAImageID image ); VAStatus (*vaSetSubpicturePalette) ( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, /* * pointer to an array holding the palette data. The size of the array is * num_palette_entries * entry_bytes in size. The order of the components @@ -292,21 +288,23 @@ struct VADriverContext VAStatus (*vaSetSubpictureChromakey) ( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, unsigned int chromakey_min, - unsigned int chromakey_max + unsigned int chromakey_max, + unsigned int chromakey_mask ); VAStatus (*vaSetSubpictureGlobalAlpha) ( VADriverContextP ctx, - VASubpicture *subpicture, + VASubpictureID subpicture, float global_alpha ); VAStatus (*vaAssociateSubpicture) ( VADriverContextP ctx, - VASurface *target_surface, - VASubpicture *subpicture, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces, short src_x, /* upper left offset in subpicture */ short src_y, short dest_x, /* upper left offset in surface */ @@ -320,6 +318,13 @@ struct VADriverContext unsigned int flags ); + VAStatus (*vaDeassociateSubpicture) ( + VADriverContextP ctx, + VASubpictureID subpicture, + VASurfaceID *target_surfaces, + int num_surfaces + ); + VAStatus (*vaQueryDisplayAttributes) ( VADriverContextP ctx, VADisplayAttribute *attr_list, /* out */ @@ -341,12 +346,33 @@ struct VADriverContext VAStatus (*vaDbgCopySurfaceToBuffer) ( VADriverContextP ctx, - VASurface *surface, + VASurfaceID surface, void **buffer, /* out */ unsigned int *stride /* out */ ); +}; + +struct VADriverContext +{ + VADriverContextP pNext; + + void *pDriverData; + struct VADriverVTable vtable; + + Display *x11_dpy; + int x11_screen; - } vtable; + int version_major; + int version_minor; + int max_profiles; + int max_entrypoints; + int max_attributes; + int max_image_formats; + int max_subpic_formats; + int max_display_attributes; + const char *str_vendor; + + void *handle; /* dlopen handle */ }; typedef VAStatus (*VADriverInit) ( diff --git a/src/va_x11.h b/src/va_x11.h index 58b312f..fdb91ba 100755 --- a/src/va_x11.h +++ b/src/va_x11.h @@ -36,9 +36,16 @@ extern "C" { #define VA_TOP_FIELD 0x00000001 #define VA_BOTTOM_FIELD 0x00000002 #define VA_FRAME_PICTURE 0x00000004 /* weave */ +/* + * clears the drawable with background color. + * for hardware overlay based implementation this flag + * can be used to turn off the overlay + */ +#define VA_CLEAR_DRAWABLE 0x00000008 + VAStatus vaPutSurface ( VADisplay dpy, - VASurface *surface, + VASurfaceID surface, Drawable draw, /* X Drawable */ short srcx, short srcy, diff --git a/test/test.c b/test/test.c index 70f3125..b088487 100644 --- a/test/test.c +++ b/test/test.c @@ -53,23 +53,23 @@ int main(int argc, const char* argv[]) printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version); { - VASurface surfaces[21]; + VASurfaceID surfaces[21]; int i; - surfaces[20].surface_id = -1; + surfaces[20] = -1; va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( -1 == surfaces[20].surface_id ); /* bounds check */ + ASSERT( -1 == surfaces[20] ); /* bounds check */ for(i = 0; i < 20; i++) { - printf("Surface %d surface_id = %08x\n", i, surfaces[i].surface_id); + printf("Surface %d surface_id = %08x\n", i, surfaces[i]); } Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0)); printf("Window = %08x\n", win); XMapWindow(dpy, win); XSync(dpy, False); - vaPutSurface(va_dpy, &(surfaces[0]), win, 0, 0, 720, 480, 0, 0, 720, 480, 0); + vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0); sleep(10); va_status = vaDestroySurface(va_dpy, surfaces, 20); @@ -94,14 +94,14 @@ int main(int argc, const char* argv[]) } { - VASurface surfaces[20]; - VAContext context; + VASurfaceID surfaces[20]; + VAContextID context; VAConfigAttrib attrib; VAConfigID config_id; int i; attrib.type = VAConfigAttribRTFormat; - va_status = vaQueryConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, + va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1); ASSERT( VA_STATUS_SUCCESS == va_status ); @@ -118,7 +118,7 @@ int main(int argc, const char* argv[]) va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context); ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaDestroyContext(va_dpy, &context); + va_status = vaDestroyContext(va_dpy, context); ASSERT( VA_STATUS_SUCCESS == va_status ); va_status = vaDestroySurface(va_dpy, surfaces, 20); diff --git a/test/test_07.c b/test/test_07.c index 3ae8f01..cb1edce 100644 --- a/test/test_07.c +++ b/test/test_07.c @@ -33,7 +33,7 @@ void pre() #define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead -void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurface *surface_list2, int surface_count2) +void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2) { int i,j; @@ -42,9 +42,9 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac for(j = 0; j < surface_count2; j++) { if ((surface_list1 == surface_list2) && (i == j)) continue; - ASSERT(surface_list1[i].surface_id != VA_INVALID_SURFACE); - ASSERT(surface_list2[j].surface_id != VA_INVALID_SURFACE); - ASSERT(surface_list1[i].surface_id != surface_list2[j].surface_id); + ASSERT(surface_list1[i] != VA_INVALID_SURFACE); + ASSERT(surface_list2[j] != VA_INVALID_SURFACE); + ASSERT(surface_list1[i] != surface_list2[j]); } } } @@ -52,10 +52,10 @@ void test_unique_surfaces(VASurface *surface_list1, int surface_count1, VASurfac void test() { - VASurface surfaces_1[1+1]; - VASurface surfaces_4[4+1]; - VASurface surfaces_16[16+1]; - VASurface surfaces_6[6+1]; + VASurfaceID surfaces_1[1+1]; + VASurfaceID surfaces_4[4+1]; + VASurfaceID surfaces_16[16+1]; + VASurfaceID surfaces_6[6+1]; memset(surfaces_1, 0xff, sizeof(surfaces_1)); memset(surfaces_4, 0xff, sizeof(surfaces_4)); @@ -63,22 +63,22 @@ void test() memset(surfaces_6, 0xff, sizeof(surfaces_6)); status("vaCreateSurfaces 1 surface\n"); - surfaces_1[1].surface_id = DEAD_SURFACE_ID; + surfaces_1[1] = DEAD_SURFACE_ID; va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_1[1].surface_id ); /* bounds check */ + ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */ status("vaCreateSurfaces 4 surfaces\n"); - surfaces_4[4].surface_id = DEAD_SURFACE_ID; + surfaces_4[4] = DEAD_SURFACE_ID; va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_4[4].surface_id ); /* bounds check */ + ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */ status("vaCreateSurfaces 16 surfaces\n"); - surfaces_16[16].surface_id = DEAD_SURFACE_ID; + surfaces_16[16] = DEAD_SURFACE_ID; va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_16[16].surface_id ); /* bounds check */ + ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */ test_unique_surfaces(surfaces_1, 1, surfaces_4, 4); test_unique_surfaces(surfaces_4, 4, surfaces_16, 4); @@ -87,29 +87,29 @@ void test() test_unique_surfaces(surfaces_1, 16, surfaces_16, 16); status("vaDestroySurface 4 surfaces\n"); - va_status = vaDestroySurface(va_dpy, surfaces_4, 4); + va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4); ASSERT( VA_STATUS_SUCCESS == va_status ); status("vaCreateSurfaces 6 surfaces\n"); - surfaces_6[6].surface_id = DEAD_SURFACE_ID; + surfaces_6[6] = DEAD_SURFACE_ID; va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_6[6].surface_id ); /* bounds check */ + ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */ test_unique_surfaces(surfaces_1, 1, surfaces_6, 6); test_unique_surfaces(surfaces_6, 6, surfaces_16, 16); test_unique_surfaces(surfaces_1, 6, surfaces_16, 6); status("vaDestroySurface 16 surfaces\n"); - va_status = vaDestroySurface(va_dpy, surfaces_16, 16); + va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16); ASSERT( VA_STATUS_SUCCESS == va_status ); status("vaDestroySurface 1 surface\n"); - va_status = vaDestroySurface(va_dpy, surfaces_1, 1); + va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1); ASSERT( VA_STATUS_SUCCESS == va_status ); status("vaDestroySurface 6 surfaces\n"); - va_status = vaDestroySurface(va_dpy, surfaces_6, 6); + va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6); ASSERT( VA_STATUS_SUCCESS == va_status ); } diff --git a/test/test_08.c b/test/test_08.c index ce4932d..8c743b6 100644 --- a/test/test_08.c +++ b/test/test_08.c @@ -33,17 +33,17 @@ void pre() #define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead -void test_unique_surfaces(VASurface *surface_list, int surface_count) +void test_unique_surfaces(VASurfaceID *surface_list, int surface_count) { int i,j; for(i = 0; i < surface_count; i++) { - ASSERT(surface_list[i].surface_id != VA_INVALID_SURFACE); + ASSERT(surface_list[i] != VA_INVALID_SURFACE); for(j = 0; j < i; j++) { if (i == j) continue; - ASSERT(surface_list[i].surface_id != surface_list[j].surface_id); + ASSERT(surface_list[i] != surface_list[j]); } } } @@ -65,7 +65,7 @@ test_size_t test_sizes[] = { void test() { - VASurface surfaces[NUM_SIZES+1]; + VASurfaceID surfaces[NUM_SIZES+1]; int i; memset(surfaces, 0xff, sizeof(surfaces)); @@ -73,16 +73,16 @@ void test() for(i = 0; i < NUM_SIZES; i++) { status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h); - surfaces[i+1].surface_id = DEAD_SURFACE_ID; + surfaces[i+1] = DEAD_SURFACE_ID; va_status = vaCreateSurfaces(va_dpy, test_sizes[i].w, test_sizes[i].h, VA_RT_FORMAT_YUV420, 1, &surfaces[i]); ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces[i+1].surface_id ); + ASSERT( DEAD_SURFACE_ID == surfaces[i+1] ); } test_unique_surfaces(surfaces, NUM_SIZES); status("vaDestroySurface all surfaces\n"); - va_status = vaDestroySurface(va_dpy, surfaces, NUM_SIZES); + va_status = vaDestroySurfaces(va_dpy, surfaces, NUM_SIZES); ASSERT( VA_STATUS_SUCCESS == va_status ); } diff --git a/test/test_09.c b/test/test_09.c index c3d5b18..7d6cd4b 100644 --- a/test/test_09.c +++ b/test/test_09.c @@ -44,7 +44,7 @@ void test() ASSERT(entrypoints); VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - VAContext *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContext)); + VAContextID *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContextID)); for(i = 0; i < num_profiles; i++) { @@ -66,7 +66,7 @@ void test() int surface_count = 4; int total_surfaces = config_count * surface_count; - VASurface *surfaces = malloc(total_surfaces * sizeof(VASurface)); + VASurfaceID *surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); @@ -82,8 +82,8 @@ void test() for(i = 0; i < config_count; i++) { - status("vaDestroyContext for context %08x\n", contexts[i].context_id); - va_status = vaDestroyContext( va_dpy, &contexts[i] ); + status("vaDestroyContext for context %08x\n", contexts[i]); + va_status = vaDestroyContext( va_dpy, contexts[i] ); ASSERT( VA_STATUS_SUCCESS == va_status ); } @@ -94,7 +94,7 @@ void test() ASSERT( VA_STATUS_SUCCESS == va_status ); } - va_status = vaDestroySurface(va_dpy, surfaces, total_surfaces); + va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); ASSERT( VA_STATUS_SUCCESS == va_status ); free(contexts); -- 2.7.4