diff options
author | Gwenole Beauchesne <gbeauchesne@splitted-desktop.com> | 2009-11-18 10:06:25 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2009-11-18 11:51:11 +0800 |
commit | 5f4d73d1656f5d38b8ece20bb65055d0cf74f401 (patch) | |
tree | 894dd63ddea027e95e1c45d96c62a59db7080a72 | |
parent | 88df301b97c64bd487787e0f15df6e4e91b33376 (diff) |
cleanup vaCreateImage, make it possible to add formats later
-rw-r--r-- | i965_drv_video/i965_drv_video.c | 106 | ||||
-rw-r--r-- | i965_drv_video/i965_drv_video.h | 6 | ||||
-rw-r--r-- | i965_drv_video/i965_render.c | 4 |
3 files changed, 75 insertions, 41 deletions
diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c index 79faf2e..13bb5f8 100644 --- a/i965_drv_video/i965_drv_video.c +++ b/i965_drv_video/i965_drv_video.c @@ -410,11 +410,10 @@ i965_CreateSubpicture(VADriverContextP ctx, vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; } *subpicture = subpicID; - obj_subpic->image = image; - obj_subpic->width = obj_image->width; - obj_subpic->height = obj_image->height; - obj_subpic->bo = obj_image->bo; - + obj_subpic->image = image; + obj_subpic->width = obj_image->image.width; + obj_subpic->height = obj_image->image.height; + obj_subpic->bo = obj_image->bo; return vaStatus; } @@ -1119,44 +1118,81 @@ i965_destroy_heap(struct object_heap *heap, } +VAStatus +i965_DestroyImage(VADriverContextP ctx, VAImageID image); VAStatus i965_CreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, - VAImage *image) /* out */ + VAImage *out_image) /* out */ { struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus va_status; - /*we will receive the actual subpicture size from the player,now we assume it is 720*32*/ - char subpic_buf[width*height]; - int subpic_size = 720*32; - unsigned int img_buf_id; + struct object_image *obj_image; + VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED; + VAImageID image_id; + unsigned int width2, height2, size2, size; - image->image_id = NEW_IMAGE_ID(); - struct object_image *obj_image = IMAGE(image->image_id); + out_image->image_id = VA_INVALID_ID; + out_image->buf = VA_INVALID_ID; - /*assume we got IA44 in format[0]*/ - image->format = *format; - - /*create empty buffer*/ - va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, - subpic_size, 1, subpic_buf, &img_buf_id); - assert( VA_STATUS_SUCCESS == va_status ); - struct object_buffer *obj_buf = BUFFER(img_buf_id); - - image->buf = img_buf_id; - image->width = width; - image->height = height; - - obj_image->buf = img_buf_id; - obj_image->width = width; - obj_image->height = height; - obj_image->size = subpic_size; - obj_image->bo = obj_buf->buffer_store->bo; - + image_id = NEW_IMAGE_ID(); + if (image_id == VA_INVALID_ID) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + obj_image = IMAGE(image_id); + if (!obj_image) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + VAImage * const image = &obj_image->image; + image->image_id = image_id; + image->buf = VA_INVALID_ID; + + size = width * height; + width2 = (width + 1) / 2; + height2 = (height + 1) / 2; + size2 = width2 * height2; + + image->num_palette_entries = 0; + image->entry_bytes = 0; + memset(image->component_order, 0, sizeof(image->component_order)); + + switch (format->fourcc) { + case VA_FOURCC('I','A','4','4'): + case VA_FOURCC('A','I','4','4'): + image->num_planes = 1; + image->pitches[0] = width; + image->offsets[0] = 0; + image->data_size = image->offsets[0] + image->pitches[0] * height; + image->num_palette_entries = 16; + image->entry_bytes = 3; + image->component_order[0] = 'R'; + image->component_order[1] = 'G'; + image->component_order[2] = 'B'; + break; + default: + goto error; + } + + va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, + image->data_size, 1, NULL, &image->buf); + if (va_status != VA_STATUS_SUCCESS) + goto error; + + obj_image->bo = BUFFER(image->buf)->buffer_store->bo; + + image->image_id = image_id; + image->format = *format; + image->width = width; + image->height = height; + + *out_image = *image; return VA_STATUS_SUCCESS; + + error: + i965_DestroyImage(ctx, image_id); + return va_status; } VAStatus i965_DeriveImage(VADriverContextP ctx, @@ -1179,9 +1215,9 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_image *obj_image = IMAGE(image); - if (obj_image && obj_image->buf != VA_INVALID_ID) { - i965_DestroyBuffer(ctx, obj_image->buf); - obj_image->buf = VA_INVALID_ID; + if (obj_image && obj_image->image.buf != VA_INVALID_ID) { + i965_DestroyBuffer(ctx, obj_image->image.buf); + obj_image->image.buf = VA_INVALID_ID; } i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h index 0b7ee33..855e6b9 100644 --- a/i965_drv_video/i965_drv_video.h +++ b/i965_drv_video/i965_drv_video.h @@ -106,13 +106,11 @@ struct object_buffer int size_element; VABufferType type; }; + struct object_image { struct object_base base; - VABufferID buf; - int width; - int height; - int size; + VAImage image; dri_bo *bo; }; diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c index e897dcd..1e1b1dd 100644 --- a/i965_drv_video/i965_render.c +++ b/i965_drv_video/i965_render.c @@ -677,8 +677,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx, region = obj_surface->bo; subpic_region = obj_image->bo; /*subpicture surface*/ - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_image->width, obj_image->height); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->width, obj_image->height); + i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_image->image.width, obj_image->image.height); + i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->image.width, obj_image->image.height); } static void |