Commit 06553a76 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne Committed by Xiang, Haihao

implement vaSetImagePalette

parent c4848526
...@@ -437,27 +437,6 @@ i965_SetSubpictureImage(VADriverContextP ctx, ...@@ -437,27 +437,6 @@ i965_SetSubpictureImage(VADriverContextP ctx,
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
/*
* 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
*/
VAStatus
i965_SetSubpicturePalette(VADriverContextP ctx,
VASubpictureID subpicture,
unsigned char *palette)
{
/*set palette in shader,so the following code is unused*/
struct i965_driver_data *i965 = i965_driver_data(ctx);
VAStatus vaStatus = VA_STATUS_SUCCESS;
struct object_subpic *obj_subpic = SUBPIC(subpicture);
if (NULL == obj_subpic) {
vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
}
memcpy(obj_subpic->palette, palette, 3*16);
return VA_STATUS_SUCCESS;
}
VAStatus VAStatus
i965_SetSubpictureChromakey(VADriverContextP ctx, i965_SetSubpictureChromakey(VADriverContextP ctx,
VASubpictureID subpicture, VASubpictureID subpicture,
...@@ -1157,6 +1136,8 @@ i965_CreateImage(VADriverContextP ctx, ...@@ -1157,6 +1136,8 @@ i965_CreateImage(VADriverContextP ctx,
obj_image = IMAGE(image_id); obj_image = IMAGE(image_id);
if (!obj_image) if (!obj_image)
return VA_STATUS_ERROR_ALLOCATION_FAILED; return VA_STATUS_ERROR_ALLOCATION_FAILED;
obj_image->bo = NULL;
obj_image->palette = NULL;
VAImage * const image = &obj_image->image; VAImage * const image = &obj_image->image;
image->image_id = image_id; image->image_id = image_id;
...@@ -1195,6 +1176,12 @@ i965_CreateImage(VADriverContextP ctx, ...@@ -1195,6 +1176,12 @@ i965_CreateImage(VADriverContextP ctx,
obj_image->bo = BUFFER(image->buf)->buffer_store->bo; obj_image->bo = BUFFER(image->buf)->buffer_store->bo;
if (image->num_palette_entries > 0 && image->entry_bytes > 0) {
obj_image->palette = malloc(image->num_palette_entries * sizeof(obj_image->palette));
if (!obj_image->palette)
goto error;
}
image->image_id = image_id; image->image_id = image_id;
image->format = *format; image->format = *format;
image->width = width; image->width = width;
...@@ -1228,21 +1215,48 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) ...@@ -1228,21 +1215,48 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image)
struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_image *obj_image = IMAGE(image); struct object_image *obj_image = IMAGE(image);
if (obj_image && obj_image->image.buf != VA_INVALID_ID) { if (!obj_image)
return VA_STATUS_SUCCESS;
if (obj_image->image.buf != VA_INVALID_ID) {
i965_DestroyBuffer(ctx, obj_image->image.buf); i965_DestroyBuffer(ctx, obj_image->image.buf);
obj_image->image.buf = VA_INVALID_ID; obj_image->image.buf = VA_INVALID_ID;
} }
if (obj_image->palette) {
free(obj_image->palette);
obj_image->palette = NULL;
}
i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image);
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
/*
* 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
*/
VAStatus VAStatus
i965_SetImagePalette(VADriverContextP ctx, i965_SetImagePalette(VADriverContextP ctx,
VAImageID image, VAImageID image,
unsigned char *palette) unsigned char *palette)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx);
unsigned int i;
struct object_image *obj_image = IMAGE(image);
if (!obj_image)
return VA_STATUS_ERROR_INVALID_IMAGE;
if (!obj_image->palette)
return VA_STATUS_ERROR_ALLOCATION_FAILED; /* XXX: unpaletted/error */
for (i = 0; i < obj_image->image.num_palette_entries; i++)
obj_image->palette[i] = (((unsigned int)palette[3*i + 0] << 16) |
((unsigned int)palette[3*i + 1] << 8) |
(unsigned int)palette[3*i + 2]);
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
...@@ -1417,7 +1431,6 @@ __vaDriverInit_0_31( VADriverContextP ctx ) ...@@ -1417,7 +1431,6 @@ __vaDriverInit_0_31( VADriverContextP ctx )
ctx->vtable.vaCreateSubpicture = i965_CreateSubpicture; ctx->vtable.vaCreateSubpicture = i965_CreateSubpicture;
ctx->vtable.vaDestroySubpicture = i965_DestroySubpicture; ctx->vtable.vaDestroySubpicture = i965_DestroySubpicture;
ctx->vtable.vaSetSubpictureImage = i965_SetSubpictureImage; ctx->vtable.vaSetSubpictureImage = i965_SetSubpictureImage;
//ctx->vtable.vaSetSubpicturePalette = i965_SetSubpicturePalette;
ctx->vtable.vaSetSubpictureChromakey = i965_SetSubpictureChromakey; ctx->vtable.vaSetSubpictureChromakey = i965_SetSubpictureChromakey;
ctx->vtable.vaSetSubpictureGlobalAlpha = i965_SetSubpictureGlobalAlpha; ctx->vtable.vaSetSubpictureGlobalAlpha = i965_SetSubpictureGlobalAlpha;
ctx->vtable.vaAssociateSubpicture = i965_AssociateSubpicture; ctx->vtable.vaAssociateSubpicture = i965_AssociateSubpicture;
......
...@@ -112,6 +112,7 @@ struct object_image ...@@ -112,6 +112,7 @@ struct object_image
struct object_base base; struct object_base base;
VAImage image; VAImage image;
dri_bo *bo; dri_bo *bo;
unsigned int *palette;
}; };
struct object_subpic struct object_subpic
...@@ -122,7 +123,6 @@ struct object_subpic ...@@ -122,7 +123,6 @@ struct object_subpic
VARectangle dst_rect; VARectangle dst_rect;
int width; int width;
int height; int height;
unsigned char palette[3][16];
dri_bo *bo; dri_bo *bo;
}; };
......
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