fix for VAEncCodedBufferType 39/739/1
authorXiang, Haihao <haihao.xiang@intel.com>
Sat, 2 Apr 2011 08:16:04 +0000 (16:16 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 7 Apr 2011 06:45:14 +0000 (14:45 +0800)
It matches VA spec.

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
i965_drv_video/gen6_mfc.c
i965_drv_video/i965_drv_video.c

index 52b8bc3..f883b9f 100644 (file)
@@ -294,7 +294,7 @@ static void gen6_mfc_avc_slice_state(VADriverContextP ctx)
        
     OUT_BCS_RELOC(ctx, bcs_state->mfc_indirect_pak_bse_object.bo,
                   I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION,
-                  0);
+                  ALIGN(sizeof(VACodedBufferSegment), 64));
 
     OUT_BCS_BATCH(ctx, 0);
     OUT_BCS_BATCH(ctx, 0);
index fe06097..766d513 100644 (file)
@@ -922,6 +922,10 @@ i965_create_buffer_internal(VADriverContextP ctx,
         return VA_STATUS_ERROR_ALLOCATION_FAILED;
     }
 
+    if (type == VAEncCodedBufferType) {
+        size += ALIGN(sizeof(VACodedBufferSegment), 64);
+    }
+
     obj_buffer->max_num_elements = num_elements;
     obj_buffer->num_elements = num_elements;
     obj_buffer->size_element = size;
@@ -943,8 +947,20 @@ i965_create_buffer_internal(VADriverContextP ctx,
                                         size * num_elements, 64);
         assert(buffer_store->bo);
 
-        if (data)
+        if (type == VAEncCodedBufferType) {
+            VACodedBufferSegment *coded_buffer_segment;
+            dri_bo_map(buffer_store->bo, 1);
+            coded_buffer_segment = (VACodedBufferSegment *)buffer_store->bo->virtual;
+            coded_buffer_segment->size = size - ALIGN(sizeof(VACodedBufferSegment), 64);
+            coded_buffer_segment->bit_offset = 0;
+            coded_buffer_segment->status = 0;
+            coded_buffer_segment->buf = NULL;
+            coded_buffer_segment->next = NULL;
+            dri_bo_unmap(buffer_store->bo);
+        } else if (data) {
             dri_bo_subdata(buffer_store->bo, 0, size * num_elements, data);
+        }
+
     } else {
         buffer_store->buffer = malloc(size * num_elements);
         assert(buffer_store->buffer);
@@ -1023,6 +1039,12 @@ i965_MapBuffer(VADriverContextP ctx,
 
         assert(obj_buffer->buffer_store->bo->virtual);
         *pbuf = obj_buffer->buffer_store->bo->virtual;
+
+        if (obj_buffer->type == VAEncCodedBufferType) {
+            VACodedBufferSegment *coded_buffer_segment = (VACodedBufferSegment *)(obj_buffer->buffer_store->bo->virtual);
+            coded_buffer_segment->buf = (unsigned char *)(obj_buffer->buffer_store->bo->virtual) + ALIGN(sizeof(VACodedBufferSegment), 64);
+        }
+
         vaStatus = VA_STATUS_SUCCESS;
     } else if (NULL != obj_buffer->buffer_store->buffer) {
         *pbuf = obj_buffer->buffer_store->buffer;