Commit 12e8a228 authored by Waldo Bastian's avatar Waldo Bastian

* Improve validation of input parameters & error reporting

parent 8f82bf2b
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#define DRIVER_INIT_FUNC "__vaDriverInit_0_24" #define DRIVER_INIT_FUNC "__vaDriverInit_0_24"
#define CTX(dpy) ((VADriverContextP) dpy ); #define CTX(dpy) ((VADriverContextP) dpy );
#define ASSERT_CONTEXT(dpy) assert( vaDbgContextIsValid(dpy) ) #define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
#define ASSERT assert #define 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;
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
static VADriverContextP pDriverContexts = NULL; static VADriverContextP pDriverContexts = NULL;
static int va_debug_trace = 0; static int va_debug_trace = 0;
static Bool vaDbgContextIsValid(VADriverContextP arg_ctx) static Bool vaContextIsValid(VADriverContextP arg_ctx)
{ {
VADriverContextP ctx = pDriverContexts; VADriverContextP ctx = pDriverContexts;
...@@ -70,7 +70,7 @@ VADisplay vaGetDisplay ( ...@@ -70,7 +70,7 @@ VADisplay vaGetDisplay (
{ {
VADisplay dpy = NULL; VADisplay dpy = NULL;
VADriverContextP ctx = pDriverContexts; VADriverContextP ctx = pDriverContexts;
while (ctx) while (ctx)
{ {
if (ctx->x11_dpy == (Display *)native_dpy) if (ctx->x11_dpy == (Display *)native_dpy)
...@@ -367,7 +367,7 @@ VAStatus vaInitialize ( ...@@ -367,7 +367,7 @@ VAStatus vaInitialize (
char *driver_name = NULL; char *driver_name = NULL;
VAStatus vaStatus; VAStatus vaStatus;
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
...@@ -400,7 +400,7 @@ VAStatus vaTerminate ( ...@@ -400,7 +400,7 @@ VAStatus vaTerminate (
{ {
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
VADriverContextP old_ctx = CTX(dpy); VADriverContextP old_ctx = CTX(dpy);
ASSERT_CONTEXT(old_ctx); CHECK_CONTEXT(old_ctx);
if (old_ctx->handle) if (old_ctx->handle)
{ {
...@@ -435,7 +435,10 @@ int vaMaxNumProfiles ( ...@@ -435,7 +435,10 @@ int vaMaxNumProfiles (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_profiles; return ctx->max_profiles;
} }
...@@ -446,7 +449,10 @@ int vaMaxNumEntrypoints ( ...@@ -446,7 +449,10 @@ int vaMaxNumEntrypoints (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_entrypoints; return ctx->max_entrypoints;
} }
...@@ -458,7 +464,10 @@ int vaMaxNumConfigAttributes ( ...@@ -458,7 +464,10 @@ int vaMaxNumConfigAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_attributes; return ctx->max_attributes;
} }
...@@ -471,7 +480,7 @@ VAStatus vaQueryConfigEntrypoints ( ...@@ -471,7 +480,7 @@ VAStatus vaQueryConfigEntrypoints (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigEntrypoints); TRACE(vaQueryConfigEntrypoints);
return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints); return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
...@@ -486,7 +495,7 @@ VAStatus vaGetConfigAttributes ( ...@@ -486,7 +495,7 @@ VAStatus vaGetConfigAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaGetConfigAttributes); TRACE(vaGetConfigAttributes);
return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs ); return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
...@@ -499,7 +508,7 @@ VAStatus vaQueryConfigProfiles ( ...@@ -499,7 +508,7 @@ VAStatus vaQueryConfigProfiles (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigProfiles); TRACE(vaQueryConfigProfiles);
return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles ); return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
...@@ -515,7 +524,7 @@ VAStatus vaCreateConfig ( ...@@ -515,7 +524,7 @@ VAStatus vaCreateConfig (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateConfig); TRACE(vaCreateConfig);
return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id ); return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
...@@ -527,7 +536,7 @@ VAStatus vaDestroyConfig ( ...@@ -527,7 +536,7 @@ VAStatus vaDestroyConfig (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroyConfig); TRACE(vaDestroyConfig);
return ctx->vtable.vaDestroyConfig ( ctx, config_id ); return ctx->vtable.vaDestroyConfig ( ctx, config_id );
...@@ -543,7 +552,7 @@ VAStatus vaQueryConfigAttributes ( ...@@ -543,7 +552,7 @@ VAStatus vaQueryConfigAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQueryConfigAttributes); TRACE(vaQueryConfigAttributes);
return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs); return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
...@@ -559,7 +568,7 @@ VAStatus vaCreateSurfaces ( ...@@ -559,7 +568,7 @@ VAStatus vaCreateSurfaces (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateSurfaces); TRACE(vaCreateSurfaces);
return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces ); return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
...@@ -572,7 +581,7 @@ VAStatus vaDestroySurface ( ...@@ -572,7 +581,7 @@ VAStatus vaDestroySurface (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroySurface); TRACE(vaDestroySurface);
return ctx->vtable.vaDestroySurface( ctx, surface_list, num_surfaces ); return ctx->vtable.vaDestroySurface( ctx, surface_list, num_surfaces );
...@@ -590,7 +599,7 @@ VAStatus vaCreateContext ( ...@@ -590,7 +599,7 @@ VAStatus vaCreateContext (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateContext); TRACE(vaCreateContext);
return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height, return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
...@@ -603,7 +612,7 @@ VAStatus vaDestroyContext ( ...@@ -603,7 +612,7 @@ VAStatus vaDestroyContext (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroyContext); TRACE(vaDestroyContext);
return ctx->vtable.vaDestroyContext( ctx, context ); return ctx->vtable.vaDestroyContext( ctx, context );
...@@ -616,7 +625,7 @@ VAStatus vaCreateBuffer ( ...@@ -616,7 +625,7 @@ VAStatus vaCreateBuffer (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateBuffer); TRACE(vaCreateBuffer);
return ctx->vtable.vaCreateBuffer( ctx, type, buf_id); return ctx->vtable.vaCreateBuffer( ctx, type, buf_id);
...@@ -631,7 +640,7 @@ VAStatus vaBufferData ( ...@@ -631,7 +640,7 @@ VAStatus vaBufferData (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaBufferData); TRACE(vaBufferData);
return ctx->vtable.vaBufferData( ctx, buf_id, size, num_elements, data); return ctx->vtable.vaBufferData( ctx, buf_id, size, num_elements, data);
...@@ -644,7 +653,7 @@ VAStatus vaBufferSetNumElements ( ...@@ -644,7 +653,7 @@ VAStatus vaBufferSetNumElements (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaBufferSetNumElements); TRACE(vaBufferSetNumElements);
return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements ); return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
...@@ -658,7 +667,7 @@ VAStatus vaMapBuffer ( ...@@ -658,7 +667,7 @@ VAStatus vaMapBuffer (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaMapBuffer); TRACE(vaMapBuffer);
return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf ); return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
...@@ -670,7 +679,7 @@ VAStatus vaUnmapBuffer ( ...@@ -670,7 +679,7 @@ VAStatus vaUnmapBuffer (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaUnmapBuffer); TRACE(vaUnmapBuffer);
return ctx->vtable.vaUnmapBuffer( ctx, buf_id ); return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
...@@ -682,7 +691,7 @@ VAStatus vaDestroyBuffer ( ...@@ -682,7 +691,7 @@ VAStatus vaDestroyBuffer (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroyBuffer); TRACE(vaDestroyBuffer);
return ctx->vtable.vaDestroyBuffer( ctx, buffer_id ); return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
...@@ -695,7 +704,7 @@ VAStatus vaBeginPicture ( ...@@ -695,7 +704,7 @@ VAStatus vaBeginPicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaBeginPicture); TRACE(vaBeginPicture);
return ctx->vtable.vaBeginPicture( ctx, context, render_target ); return ctx->vtable.vaBeginPicture( ctx, context, render_target );
...@@ -709,7 +718,7 @@ VAStatus vaRenderPicture ( ...@@ -709,7 +718,7 @@ VAStatus vaRenderPicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaRenderPicture); TRACE(vaRenderPicture);
return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers ); return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
...@@ -721,7 +730,7 @@ VAStatus vaEndPicture ( ...@@ -721,7 +730,7 @@ VAStatus vaEndPicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaEndPicture); TRACE(vaEndPicture);
return ctx->vtable.vaEndPicture( ctx, context ); return ctx->vtable.vaEndPicture( ctx, context );
...@@ -734,7 +743,7 @@ VAStatus vaSyncSurface ( ...@@ -734,7 +743,7 @@ VAStatus vaSyncSurface (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSyncSurface); TRACE(vaSyncSurface);
return ctx->vtable.vaSyncSurface( ctx, context, render_target ); return ctx->vtable.vaSyncSurface( ctx, context, render_target );
...@@ -748,7 +757,7 @@ VAStatus vaQuerySurfaceStatus ( ...@@ -748,7 +757,7 @@ VAStatus vaQuerySurfaceStatus (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQuerySurfaceStatus); TRACE(vaQuerySurfaceStatus);
return ctx->vtable.vaQuerySurfaceStatus( ctx, context, render_target, status ); return ctx->vtable.vaQuerySurfaceStatus( ctx, context, render_target, status );
...@@ -772,7 +781,7 @@ VAStatus vaPutSurface ( ...@@ -772,7 +781,7 @@ VAStatus vaPutSurface (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaPutSurface); TRACE(vaPutSurface);
return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch, return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
...@@ -786,7 +795,10 @@ int vaMaxNumImageFormats ( ...@@ -786,7 +795,10 @@ int vaMaxNumImageFormats (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_image_formats; return ctx->max_image_formats;
} }
...@@ -798,7 +810,7 @@ VAStatus vaQueryImageFormats ( ...@@ -798,7 +810,7 @@ VAStatus vaQueryImageFormats (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQueryImageFormats); TRACE(vaQueryImageFormats);
return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats); return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
...@@ -821,7 +833,7 @@ VAStatus vaCreateImage ( ...@@ -821,7 +833,7 @@ VAStatus vaCreateImage (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateImage); TRACE(vaCreateImage);
return ctx->vtable.vaCreateImage ( ctx, format, width, height, image); return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
...@@ -836,7 +848,7 @@ VAStatus vaDestroyImage ( ...@@ -836,7 +848,7 @@ VAStatus vaDestroyImage (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroyImage); TRACE(vaDestroyImage);
return ctx->vtable.vaDestroyImage ( ctx, image); return ctx->vtable.vaDestroyImage ( ctx, image);
...@@ -857,7 +869,7 @@ VAStatus vaGetImage ( ...@@ -857,7 +869,7 @@ VAStatus vaGetImage (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaGetImage); TRACE(vaGetImage);
return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image); return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
...@@ -880,7 +892,7 @@ VAStatus vaPutImage ( ...@@ -880,7 +892,7 @@ VAStatus vaPutImage (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaPutImage); TRACE(vaPutImage);
return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y ); return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
...@@ -892,7 +904,10 @@ int vaMaxNumSubpictureFormats ( ...@@ -892,7 +904,10 @@ int vaMaxNumSubpictureFormats (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_subpic_formats; return ctx->max_subpic_formats;
} }
...@@ -912,7 +927,7 @@ VAStatus vaQuerySubpictureFormats ( ...@@ -912,7 +927,7 @@ VAStatus vaQuerySubpictureFormats (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQuerySubpictureFormats); TRACE(vaQuerySubpictureFormats);
return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats); return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
...@@ -928,7 +943,7 @@ VAStatus vaCreateSubpicture ( ...@@ -928,7 +943,7 @@ VAStatus vaCreateSubpicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaCreateSubpicture); TRACE(vaCreateSubpicture);
return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture ); return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
...@@ -943,7 +958,7 @@ VAStatus vaDestroySubpicture ( ...@@ -943,7 +958,7 @@ VAStatus vaDestroySubpicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDestroySubpicture); TRACE(vaDestroySubpicture);
return ctx->vtable.vaDestroySubpicture ( ctx, subpicture); return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
...@@ -956,7 +971,7 @@ VAStatus vaSetSubpictureImage ( ...@@ -956,7 +971,7 @@ VAStatus vaSetSubpictureImage (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureImage); TRACE(vaSetSubpictureImage);
return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image); return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
...@@ -975,7 +990,7 @@ VAStatus vaSetSubpicturePalette ( ...@@ -975,7 +990,7 @@ VAStatus vaSetSubpicturePalette (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSetSubpicturePalette); TRACE(vaSetSubpicturePalette);
return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette); return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
...@@ -993,7 +1008,7 @@ VAStatus vaSetSubpictureChromakey ( ...@@ -993,7 +1008,7 @@ VAStatus vaSetSubpictureChromakey (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_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 );
...@@ -1012,7 +1027,7 @@ VAStatus vaSetSubpictureGlobalAlpha ( ...@@ -1012,7 +1027,7 @@ VAStatus vaSetSubpictureGlobalAlpha (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSetSubpictureGlobalAlpha); TRACE(vaSetSubpictureGlobalAlpha);
return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha ); return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
...@@ -1043,7 +1058,7 @@ VAStatus vaAssociateSubpicture ( ...@@ -1043,7 +1058,7 @@ VAStatus vaAssociateSubpicture (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_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, target_surface, subpicture, src_x, src_y, dest_x, dest_y, width, height, flags );
...@@ -1055,7 +1070,10 @@ int vaMaxNumDisplayAttributes ( ...@@ -1055,7 +1070,10 @@ int vaMaxNumDisplayAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); if( !vaContextIsValid(ctx) )
{
return 0;
}
return ctx->max_display_attributes; return ctx->max_display_attributes;
} }
...@@ -1073,7 +1091,7 @@ VAStatus vaQueryDisplayAttributes ( ...@@ -1073,7 +1091,7 @@ VAStatus vaQueryDisplayAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaQueryDisplayAttributes); TRACE(vaQueryDisplayAttributes);
return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes ); return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
...@@ -1092,7 +1110,7 @@ VAStatus vaGetDisplayAttributes ( ...@@ -1092,7 +1110,7 @@ VAStatus vaGetDisplayAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaGetDisplayAttributes); TRACE(vaGetDisplayAttributes);
return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes ); return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
...@@ -1111,7 +1129,7 @@ VAStatus vaSetDisplayAttributes ( ...@@ -1111,7 +1129,7 @@ VAStatus vaSetDisplayAttributes (
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaSetDisplayAttributes); TRACE(vaSetDisplayAttributes);
return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes ); return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
...@@ -1126,7 +1144,7 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, ...@@ -1126,7 +1144,7 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
) )
{ {
VADriverContextP ctx = CTX(dpy); VADriverContextP ctx = CTX(dpy);
ASSERT_CONTEXT(ctx); CHECK_CONTEXT(ctx);
TRACE(vaDbgCopySurfaceToBuffer); TRACE(vaDbgCopySurfaceToBuffer);
return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride ); return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );
......
...@@ -86,17 +86,19 @@ typedef void* VADisplay; /* window system dependent */ ...@@ -86,17 +86,19 @@ typedef void* VADisplay; /* window system dependent */
typedef int VAStatus; /* Return status type from functions */ typedef int VAStatus; /* Return status type from functions */
/* Values for the return status */ /* Values for the return status */
#define VA_STATUS_SUCCESS 0x00000000 #define VA_STATUS_SUCCESS 0x00000000
#define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000001 #define VA_STATUS_ERROR_OPERATION_FAILED 0x00000001
#define VA_STATUS_ERROR_INVALID_CONFIG 0x00000002 #define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000002
#define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000003 #define VA_STATUS_ERROR_INVALID_DISPLAY 0x00000003
#define VA_STATUS_ERROR_INVALID_SURFACE 0x00000004 #define VA_STATUS_ERROR_INVALID_CONFIG 0x00000004
#define VA_STATUS_ERROR_INVALID_BUFFER 0x00000005 #define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005
#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x00000006 #define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006
#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x00000007 #define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007
#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x00000008 #define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x00000008
#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x00000009 #define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x00000009
#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000a #define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000a
#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000b #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_UNKNOWN 0xFFFFFFFF #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
/* /*
......
...@@ -51,7 +51,7 @@ struct VADriverContext ...@@ -51,7 +51,7 @@ struct VADriverContext
int max_display_attributes; int max_display_attributes;
void *handle; /* dlopen handle */ void *handle; /* dlopen handle */
void *pDriverData; void *pDriverData;
struct struct VADriverVTable
{ {
VAStatus (*vaTerminate) ( VADriverContextP ctx ); VAStatus (*vaTerminate) ( VADriverContextP ctx );
...@@ -139,15 +139,15 @@ struct VADriverContext ...@@ -139,15 +139,15 @@ struct VADriverContext
VAStatus (*vaBufferData) ( VAStatus (*vaBufferData) (
VADriverContextP ctx, VADriverContextP ctx,
VABufferID buf_id, /* in */ VABufferID buf_id, /* in */
unsigned int size, /* in */ unsigned int size, /* in */
unsigned int num_elements, /* in */ unsigned int num_elements, /* in */
void *data /* in */ void *data /* in */
); );
VAStatus (*vaBufferSetNumElements) ( VAStatus (*vaBufferSetNumElements) (
VADriverContextP ctx, VADriverContextP ctx,
VABufferID buf_id, /* in */ VABufferID buf_id, /* in */
unsigned int num_elements /* in */ unsigned int num_elements /* in */
); );
VAStatus (*vaMapBuffer) ( VAStatus (*vaMapBuffer) (
......
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