summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/i965_drv_video.c34
-rw-r--r--src/i965_drv_video.h2
-rw-r--r--src/i965_output_dri.c9
-rw-r--r--src/i965_render.c38
4 files changed, 54 insertions, 29 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index f4caaec..e7633e5 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -702,6 +702,7 @@ i965_CreateSurfaces2(
obj_surface->subpic_render_idx = 0;
for(j = 0; j < I965_MAX_SUBPIC_SUM; j++){
obj_surface->subpic[j] = VA_INVALID_ID;
+ obj_surface->obj_subpic[j] = NULL;
}
obj_surface->width = ALIGN(width, 16);
@@ -915,6 +916,7 @@ i965_CreateSubpicture(VADriverContextP ctx,
*subpicture = subpicID;
obj_subpic->image = image;
+ obj_subpic->obj_image = obj_image;
obj_subpic->format = m->format;
obj_subpic->width = obj_image->image.width;
obj_subpic->height = obj_image->image.height;
@@ -931,6 +933,11 @@ i965_DestroySubpicture(VADriverContextP ctx,
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_subpic *obj_subpic = SUBPIC(subpicture);
+
+ if (!obj_subpic)
+ return VA_STATUS_ERROR_INVALID_SUBPICTURE;
+
+ assert(obj_subpic->obj_image);
i965_destroy_subpic(&i965->subpic_heap, (struct object_base *)obj_subpic);
return VA_STATUS_SUCCESS;
}
@@ -966,6 +973,10 @@ i965_SetSubpictureGlobalAlpha(VADriverContextP ctx,
if(global_alpha > 1.0 || global_alpha < 0.0){
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
+
+ if (!obj_subpic)
+ return VA_STATUS_ERROR_INVALID_SUBPICTURE;
+
obj_subpic->global_alpha = global_alpha;
return VA_STATUS_SUCCESS;
@@ -994,6 +1005,11 @@ i965_AssociateSubpicture(VADriverContextP ctx,
struct object_subpic *obj_subpic = SUBPIC(subpicture);
int i, j;
+ if (!obj_subpic)
+ return VA_STATUS_ERROR_INVALID_SUBPICTURE;
+
+ assert(obj_subpic->obj_image);
+
obj_subpic->src_rect.x = src_x;
obj_subpic->src_rect.y = src_y;
obj_subpic->src_rect.width = src_width;
@@ -1011,8 +1027,10 @@ i965_AssociateSubpicture(VADriverContextP ctx,
for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
if(obj_surface->subpic[j] == VA_INVALID_ID){
- obj_surface->subpic[j] = subpicture;
- break;
+ assert(obj_surface->obj_subpic[j] == NULL);
+ obj_surface->subpic[j] = subpicture;
+ obj_surface->obj_subpic[j] = obj_subpic;
+ break;
}
}
@@ -1032,17 +1050,23 @@ i965_DeassociateSubpicture(VADriverContextP ctx,
int num_surfaces)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
+ struct object_subpic *obj_subpic = SUBPIC(subpicture);
int i, j;
+ if (!obj_subpic)
+ return VA_STATUS_ERROR_INVALID_SUBPICTURE;
+
for (i = 0; i < num_surfaces; i++) {
struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
if (!obj_surface)
return VA_STATUS_ERROR_INVALID_SURFACE;
for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
- if(obj_surface->subpic[j] == subpicture){
- obj_surface->subpic[j] = VA_INVALID_ID;
- break;
+ if (obj_surface->subpic[j] == subpicture) {
+ assert(obj_surface->obj_subpic[j] == obj_subpic);
+ obj_surface->subpic[j] = VA_INVALID_ID;
+ obj_surface->obj_subpic[j] = NULL;
+ break;
}
}
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 787755c..0943736 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -198,6 +198,7 @@ struct object_surface
struct object_base base;
VASurfaceStatus status;
VASubpictureID subpic[I965_MAX_SUBPIC_SUM];
+ struct object_subpic *obj_subpic[I965_MAX_SUBPIC_SUM];
unsigned int subpic_render_idx;
int width;
@@ -244,6 +245,7 @@ struct object_subpic
{
struct object_base base;
VAImageID image;
+ struct object_image *obj_image;
VARectangle src_rect;
VARectangle dst_rect;
unsigned int format;
diff --git a/src/i965_output_dri.c b/src/i965_output_dri.c
index 34854ac..43e9300 100644
--- a/src/i965_output_dri.c
+++ b/src/i965_output_dri.c
@@ -191,10 +191,11 @@ i965_put_surface_dri(
intel_render_put_surface(ctx, obj_surface, src_rect, dst_rect, pp_flag);
- for(i = 0; i < I965_MAX_SUBPIC_SUM; i++){
- if(obj_surface->subpic[i] != VA_INVALID_ID) {
- obj_surface->subpic_render_idx = i;
- intel_render_put_subpicture(ctx, obj_surface, src_rect, dst_rect);
+ for (i = 0; i < I965_MAX_SUBPIC_SUM; i++) {
+ if (obj_surface->obj_subpic[i] != NULL) {
+ assert(obj_surface->subpic[i] != VA_INVALID_ID);
+ obj_surface->subpic_render_idx = i;
+ intel_render_put_subpicture(ctx, obj_surface, src_rect, dst_rect);
}
}
diff --git a/src/i965_render.c b/src/i965_render.c
index cdbe562..ae913a3 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -884,11 +884,10 @@ static void
i965_subpic_render_src_surfaces_state(VADriverContextP ctx,
struct object_surface *obj_surface)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
dri_bo *subpic_region;
unsigned int index = obj_surface->subpic_render_idx;
- struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
- struct object_image *obj_image = IMAGE(obj_subpic->image);
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
+ struct object_image *obj_image = obj_subpic->obj_image;
assert(obj_surface);
assert(obj_surface->bo);
subpic_region = obj_image->bo;
@@ -991,9 +990,8 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx,
struct object_surface *obj_surface,
const VARectangle *output_rect)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
unsigned int index = obj_surface->subpic_render_idx;
- struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
float tex_coords[4], vid_coords[4];
VARectangle dst_rect;
@@ -1086,13 +1084,11 @@ i965_subpic_render_upload_constants(VADriverContextP ctx,
float *constant_buffer;
float global_alpha = 1.0;
unsigned int index = obj_surface->subpic_render_idx;
-
- if(obj_surface->subpic[index] != VA_INVALID_ID){
- struct object_subpic *obj_subpic= SUBPIC(obj_surface->subpic[index]);
- if(obj_subpic->flags & VA_SUBPICTURE_GLOBAL_ALPHA){
- global_alpha = obj_subpic->global_alpha;
- }
- }
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
+
+ if (obj_subpic->flags & VA_SUBPICTURE_GLOBAL_ALPHA) {
+ global_alpha = obj_subpic->global_alpha;
+ }
dri_bo_map(render_state->curbe.bo, 1);
@@ -1391,7 +1387,7 @@ i965_render_vertex_elements(VADriverContextP ctx)
static void
i965_render_upload_image_palette(
VADriverContextP ctx,
- VAImageID image_id,
+ struct object_image *obj_image,
unsigned int alpha
)
{
@@ -1399,9 +1395,11 @@ i965_render_upload_image_palette(
struct intel_batchbuffer *batch = i965->batch;
unsigned int i;
- struct object_image *obj_image = IMAGE(image_id);
assert(obj_image);
+ if (!obj_image)
+ return;
+
if (obj_image->image.num_palette_entries == 0)
return;
@@ -1657,14 +1655,14 @@ i965_render_put_subpicture(
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = i965->batch;
unsigned int index = obj_surface->subpic_render_idx;
- struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
assert(obj_subpic);
i965_render_initialize(ctx);
i965_subpic_render_state_setup(ctx, obj_surface, src_rect, dst_rect);
i965_subpic_render_pipeline_setup(ctx);
- i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
+ i965_render_upload_image_palette(ctx, obj_subpic->obj_image, 0xff);
intel_batchbuffer_flush(batch);
}
@@ -2224,13 +2222,13 @@ gen6_render_put_subpicture(
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = i965->batch;
unsigned int index = obj_surface->subpic_render_idx;
- struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
assert(obj_subpic);
gen6_render_initialize(ctx);
gen6_subpicture_render_setup_states(ctx, obj_surface, src_rect, dst_rect);
gen6_render_emit_states(ctx, PS_SUBPIC_KERNEL);
- i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
+ i965_render_upload_image_palette(ctx, obj_subpic->obj_image, 0xff);
intel_batchbuffer_flush(batch);
}
@@ -3002,13 +3000,13 @@ gen7_render_put_subpicture(
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = i965->batch;
unsigned int index = obj_surface->subpic_render_idx;
- struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
+ struct object_subpic *obj_subpic = obj_surface->obj_subpic[index];
assert(obj_subpic);
gen7_render_initialize(ctx);
gen7_subpicture_render_setup_states(ctx, obj_surface, src_rect, dst_rect);
gen7_render_emit_states(ctx, PS_SUBPIC_KERNEL);
- i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
+ i965_render_upload_image_palette(ctx, obj_subpic->obj_image, 0xff);
intel_batchbuffer_flush(batch);
}