OSDN Git Service

Render: Add four subpicture support
authorLi,Xiaowei <xiaowei.a.li@intel.com>
Tue, 27 Nov 2012 01:08:29 +0000 (09:08 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 14 Dec 2012 03:01:17 +0000 (11:01 +0800)
Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
(cherry picked from commit a7c42530c312bdb1c53cce49b6a86f47de2ccb65)

Conflicts:

src/i965_drv_video.c

src/i965_drv_video.c
src/i965_drv_video.h
src/i965_output_dri.c
src/i965_render.c

index 4433775..c0b4fe6 100644 (file)
@@ -530,7 +530,7 @@ i965_CreateSurfaces(VADriverContextP ctx,
                     VASurfaceID *surfaces)      /* out */
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
-    int i;
+    int i,j;
     VAStatus vaStatus = VA_STATUS_SUCCESS;
 
     /* We only support one format */
@@ -549,7 +549,6 @@ i965_CreateSurfaces(VADriverContextP ctx,
 
         surfaces[i] = surfaceID;
         obj_surface->status = VASurfaceReady;
-        obj_surface->subpic = VA_INVALID_ID;
         obj_surface->orig_width = width;
         obj_surface->orig_height = height;
 
@@ -561,6 +560,11 @@ i965_CreateSurfaces(VADriverContextP ctx,
                obj_surface->height = ALIGN(height, 32);
        }
 
+        obj_surface->subpic_render_idx = 0;
+        for(j = 0; j < I965_MAX_SUBPIC_SUM; j++){
+           obj_surface->subpic[j] = VA_INVALID_ID;
+        }
+
         obj_surface->flags = SURFACE_REFERENCED;
         obj_surface->fourcc = 0;
         obj_surface->bo = NULL;
@@ -767,7 +771,7 @@ i965_AssociateSubpicture(VADriverContextP ctx,
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct object_subpic *obj_subpic = SUBPIC(subpicture);
-    int i;
+    int i, j;
 
     obj_subpic->src_rect.x      = src_x;
     obj_subpic->src_rect.y      = src_y;
@@ -783,7 +787,18 @@ i965_AssociateSubpicture(VADriverContextP ctx,
         struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
         if (!obj_surface)
             return VA_STATUS_ERROR_INVALID_SURFACE;
-        obj_surface->subpic = subpicture;
+
+        for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
+            if(obj_surface->subpic[j] == VA_INVALID_ID){
+               obj_surface->subpic[j] = subpicture;
+               break;
+            }
+        }
+        
+        if(j == I965_MAX_SUBPIC_SUM){
+            return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
+        }
+
     }
     return VA_STATUS_SUCCESS;
 }
@@ -796,14 +811,23 @@ i965_DeassociateSubpicture(VADriverContextP ctx,
                            int num_surfaces)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
-    int i;
+    int i, j;
 
     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;
-        if (obj_surface->subpic == subpicture)
-            obj_surface->subpic = VA_INVALID_ID;
+
+        for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
+            if(obj_surface->subpic[j] == subpicture){
+               obj_surface->subpic[j] = VA_INVALID_ID;
+               break;
+            }
+        }
+        
+        if(j == I965_MAX_SUBPIC_SUM){
+            return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
+        }
     }
     return VA_STATUS_SUCCESS;
 }
index 15eb189..f03b6cb 100644 (file)
@@ -42,6 +42,7 @@
 #define I965_MAX_CONFIG_ATTRIBUTES              10
 #define I965_MAX_IMAGE_FORMATS                  3
 #define I965_MAX_SUBPIC_FORMATS                 6
+#define I965_MAX_SUBPIC_SUM                     4
 
 #define INTEL_STR_DRIVER_VENDOR                 "Intel"
 #define INTEL_STR_DRIVER_NAME                   "i965"
@@ -163,7 +164,9 @@ struct object_surface
 {
     struct object_base base;
     VASurfaceStatus status;
-    VASubpictureID subpic;
+    VASubpictureID subpic[I965_MAX_SUBPIC_SUM];
+    unsigned int subpic_render_idx;
+
     int width;
     int height;
     int size;
index 5757ce8..c58e8cc 100644 (file)
@@ -124,7 +124,7 @@ i965_put_surface_dri(
     unsigned int pp_flag = 0;
     bool new_region = false;
     uint32_t name;
-    int ret;
+    int i, ret;
 
     /* Currently don't support DRI1 */
     if (!VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2))
@@ -187,8 +187,11 @@ i965_put_surface_dri(
 
     intel_render_put_surface(ctx, surface, src_rect, dst_rect, pp_flag);
 
-    if(obj_surface->subpic != VA_INVALID_ID) {
-        intel_render_put_subpicture(ctx, surface, src_rect, dst_rect);
+    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, surface, src_rect, dst_rect);
+        }
     }
 
     dri_vtable->swap_buffer(ctx, dri_drawable);
index 92f5188..de93164 100644 (file)
@@ -892,7 +892,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx,
     struct i965_driver_data *i965 = i965_driver_data(ctx);  
     struct object_surface *obj_surface = SURFACE(surface);
     dri_bo *subpic_region;
-    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
+    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);
     assert(obj_surface);
     assert(obj_surface->bo);
@@ -998,7 +999,8 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx,
 {    
     struct i965_driver_data  *i965         = i965_driver_data(ctx);
     struct object_surface    *obj_surface  = SURFACE(surface);
-    struct object_subpic     *obj_subpic   = SUBPIC(obj_surface->subpic);
+    unsigned int index = obj_surface->subpic_render_idx;
+    struct object_subpic     *obj_subpic   = SUBPIC(obj_surface->subpic[index]);
     float tex_coords[4], vid_coords[4];
     VARectangle dst_rect;
 
@@ -1096,9 +1098,10 @@ i965_subpic_render_upload_constants(VADriverContextP ctx,
     float *constant_buffer;
     float global_alpha = 1.0;
     struct object_surface *obj_surface = SURFACE(surface);
+    unsigned int index = obj_surface->subpic_render_idx;
 
-    if(obj_surface->subpic != VA_INVALID_ID){
-        struct object_subpic *obj_subpic= SUBPIC(obj_surface->subpic);
+    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;
         }
@@ -1667,7 +1670,8 @@ i965_render_put_subpicture(
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
     struct object_surface *obj_surface = SURFACE(surface);
-    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
+    unsigned int index = obj_surface->subpic_render_idx;
+    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
 
     assert(obj_subpic);
 
@@ -2234,7 +2238,8 @@ gen6_render_put_subpicture(
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
     struct object_surface *obj_surface = SURFACE(surface);
-    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
+    unsigned int index = obj_surface->subpic_render_idx;
+    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
 
     assert(obj_subpic);
     gen6_render_initialize(ctx);
@@ -3012,7 +3017,8 @@ gen7_render_put_subpicture(
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct intel_batchbuffer *batch = i965->batch;
     struct object_surface *obj_surface = SURFACE(surface);
-    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
+    unsigned int index = obj_surface->subpic_render_idx;
+    struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic[index]);
 
     assert(obj_subpic);
     gen7_render_initialize(ctx);