From: Gwenole Beauchesne Date: Wed, 18 Nov 2009 02:44:20 +0000 (+0800) Subject: simplify subpicture formats. make sure the returned VAImageFormats are correctly... X-Git-Tag: 1.0_branch~396^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37de6473f15679e6416a8a0bdf111b1b3fe75001;p=profile%2Fivi%2Fvaapi-intel-driver.git simplify subpicture formats. make sure the returned VAImageFormats are correctly filled in --- diff --git a/i965_drv_video.c b/i965_drv_video.c index b6f3733..8f4bfc1 100644 --- a/i965_drv_video.c +++ b/i965_drv_video.c @@ -39,6 +39,7 @@ #include "i965_media.h" #include "i965_drv_video.h" +#include "i965_defines.h" #define CONFIG_ID_OFFSET 0x01000000 #define CONTEXT_ID_OFFSET 0x02000000 @@ -47,6 +48,48 @@ #define IMAGE_ID_OFFSET 0x0a000000 #define SUBPIC_ID_OFFSET 0x10000000 +enum { + I965_SURFACETYPE_RGBA = 1, + I965_SURFACETYPE_YUV, + I965_SURFACETYPE_INDEXED +}; + +/* List of supported subpicture formats */ +typedef struct { + unsigned int type; + unsigned int format; + VAImageFormat va_format; + unsigned int va_flags; +} i965_subpic_format_map_t; + +static const i965_subpic_format_map_t +i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = { + { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_P4A4_UNORM, + { VA_FOURCC('I','A','4','4'), VA_MSB_FIRST, 8, }, + 0 }, + { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A4P4_UNORM, + { VA_FOURCC('A','I','4','4'), VA_MSB_FIRST, 8, }, + 0 }, +}; + +static const i965_subpic_format_map_t * +get_subpic_format(const VAImageFormat *va_format) +{ + unsigned int i; + for (i = 0; i < sizeof(i965_subpic_formats_map)/sizeof(i965_subpic_formats_map[0]); i++) { + const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[i]; + if (m->va_format.fourcc == va_format->fourcc && + (m->type == I965_SURFACETYPE_RGBA ? + (m->va_format.byte_order == va_format->byte_order && + m->va_format.red_mask == va_format->red_mask && + m->va_format.green_mask == va_format->green_mask && + m->va_format.blue_mask == va_format->blue_mask && + m->va_format.alpha_mask == va_format->alpha_mask) : 1)) + return m; + } + return NULL; +} + VAStatus i965_QueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, /* out */ @@ -375,12 +418,19 @@ i965_QuerySubpictureFormats(VADriverContextP ctx, unsigned int *flags, /* out */ unsigned int *num_formats) /* out */ { - /*support 2 subpicture formats*/ - *num_formats = 2; - format_list[0].fourcc=FOURCC_IA44; - format_list[0].byte_order=VA_LSB_FIRST; - format_list[1].fourcc=FOURCC_AI44; - format_list[1].byte_order=VA_LSB_FIRST; + int n; + + for (n = 0; i965_subpic_formats_map[n].va_format.fourcc != 0; n++) { + const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[n]; + if (format_list) + format_list[n] = m->va_format; + if (flags) + flags[n] = m->va_flags; + } + + if (num_formats) + *num_formats = n; + return VA_STATUS_SUCCESS; } @@ -398,24 +448,27 @@ i965_CreateSubpicture(VADriverContextP ctx, VASubpictureID *subpicture) /* out */ { struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus vaStatus = VA_STATUS_SUCCESS; VASubpictureID subpicID = NEW_SUBPIC_ID() struct object_subpic *obj_subpic = SUBPIC(subpicID); + if (!obj_subpic) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + struct object_image *obj_image = IMAGE(image); - - if (NULL == obj_subpic) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - if (NULL == obj_image) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; + + const i965_subpic_format_map_t * const m = get_subpic_format(&obj_image->image.format); + if (!m) + return VA_STATUS_ERROR_UNKNOWN; /* XXX: VA_STATUS_ERROR_UNSUPPORTED_FORMAT? */ + *subpicture = subpicID; obj_subpic->image = image; + obj_subpic->format = m->format; obj_subpic->width = obj_image->image.width; obj_subpic->height = obj_image->image.height; obj_subpic->bo = obj_image->bo; - return vaStatus; + return VA_STATUS_SUCCESS; } VAStatus diff --git a/i965_drv_video.h b/i965_drv_video.h index 6ed8a9b..c95c799 100644 --- a/i965_drv_video.h +++ b/i965_drv_video.h @@ -42,7 +42,7 @@ #define I965_MAX_ENTRYPOINTS 5 #define I965_MAX_CONFIG_ATTRIBUTES 10 #define I965_MAX_IMAGE_FORMATS 10 -#define I965_MAX_SUBPIC_FORMATS 4 +#define I965_MAX_SUBPIC_FORMATS 2 #define I965_MAX_DISPLAY_ATTRIBUTES 4 #define I965_STR_VENDOR "i965 Driver 0.1" @@ -121,6 +121,7 @@ struct object_subpic VAImageID image; VARectangle src_rect; VARectangle dst_rect; + unsigned int format; int width; int height; dri_bo *bo; diff --git a/i965_render.c b/i965_render.c index 1470105..f523c6a 100644 --- a/i965_render.c +++ b/i965_render.c @@ -586,25 +586,12 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, int index, dri_bo *region, unsigned long offset, - int w, int h, int fourcc) + int w, int h, int format) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; struct i965_surface_state *ss; dri_bo *ss_bo; - int surface_format; - - switch (fourcc) { - case VA_FOURCC('I','A','4','4'): - surface_format = I965_SURFACEFORMAT_P4A4_UNORM; - break; - case VA_FOURCC('A','I','4','4'): - surface_format = I965_SURFACEFORMAT_A4P4_UNORM; - break; - default: - assert(0); /* XXX: fix supported subpicture formats */ - break; - } ss_bo = dri_bo_alloc(i965->intel.bufmgr, "surface state", @@ -615,7 +602,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, ss = ss_bo->virtual; memset(ss, 0, sizeof(*ss)); ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = surface_format; + ss->ss0.surface_format = format; ss->ss0.writedisable_alpha = 0; ss->ss0.writedisable_red = 0; ss->ss0.writedisable_green = 0; @@ -691,8 +678,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->image.width, obj_image->image.height, obj_image->image.format.fourcc); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->image.width, obj_image->image.height, obj_image->image.format.fourcc); + i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); + i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); } static void