OSDN Git Service

Encode/VP9: turn gen9_vp9_get_coded_status() into a local function
authorXiang, Haihao <haihao.xiang@intel.com>
Mon, 15 Aug 2016 02:46:10 +0000 (10:46 +0800)
committerSean V Kelley <seanvk@posteo.de>
Fri, 19 Aug 2016 22:17:59 +0000 (15:17 -0700)
Set encoder_context->get_status to this local function when initializing,
so that we can fetch VP9 encoding status from the underlying context.

This patch changes the input parameters and removes redundant assigns

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
src/gen9_vp9_encapi.h
src/gen9_vp9_encoder.c
src/i965_drv_video.c

index 0100a06..99963fc 100644 (file)
@@ -40,13 +40,4 @@ gen9_vp9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *en
 extern Bool
 gen9_vp9_pak_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
 
-/* buffer points to the start address of coded_buffer. It is also
- * interpreted as i965_coded_buffer_segment.
- */
-extern VAStatus
-gen9_vp9_get_coded_status(VADriverContextP ctx,
-                          char *buffer,
-                          struct hw_context *hw_context);
-
-
 #endif  // _INTE_VP9_ENC_API_H_
index 0980a77..6b9f13f 100644 (file)
@@ -5789,6 +5789,7 @@ gen9_vp9_pak_pipeline_prepare(VADriverContextP ctx,
     coded_buffer_segment = (struct i965_coded_buffer_segment *)bo->virtual;
     coded_buffer_segment->mapped = 0;
     coded_buffer_segment->codec = encoder_context->codec;
+    coded_buffer_segment->status_support = 1;
     dri_bo_unmap(bo);
 
     return VA_STATUS_SUCCESS;
@@ -6007,58 +6008,50 @@ gen9_vp9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *en
     return true;
 }
 
-Bool
-gen9_vp9_pak_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
-{
-    /* VME & PAK share the same context */
-    struct gen9_encoder_context_vp9 *pak_context = encoder_context->vme_context;
-
-    if (!pak_context)
-        return false;
-
-    encoder_context->mfc_context = pak_context;
-    encoder_context->mfc_context_destroy = gen9_vp9_pak_context_destroy;
-    encoder_context->mfc_pipeline = gen9_vp9_pak_pipeline;
-    encoder_context->mfc_brc_prepare = gen9_vp9_pak_brc_prepare;
-
-    return true;
-}
-
-VAStatus
+static VAStatus
 gen9_vp9_get_coded_status(VADriverContextP ctx,
-                          char *buffer,
-                          struct hw_context *hw_context)
+                          struct intel_encoder_context *encoder_context,
+                          struct i965_coded_buffer_segment *coded_buf_seg)
 {
-    struct intel_encoder_context *encoder_context =
-                      (struct intel_encoder_context *)hw_context;
     struct gen9_vp9_state *vp9_state = NULL;
     struct vp9_encode_status_buffer_internal *status_buffer;
-    struct i965_coded_buffer_segment *coded_buf_seg;
     unsigned int *buf_ptr;
 
-    if (!encoder_context || !buffer)
+    if (!encoder_context || !coded_buf_seg)
         return VA_STATUS_ERROR_INVALID_BUFFER;
 
     vp9_state = (struct gen9_vp9_state *)(encoder_context->enc_priv_state);
-    coded_buf_seg = (struct i965_coded_buffer_segment *) buffer;
 
     if (!vp9_state)
         return VA_STATUS_ERROR_INVALID_BUFFER;
 
     status_buffer = &vp9_state->status_buffer;
 
-    buf_ptr = (unsigned int *)(buffer + status_buffer->bs_byte_count_offset);
-    coded_buf_seg->base.buf = buffer + I965_CODEDBUFFER_HEADER_SIZE;
-    coded_buf_seg->base.next = NULL;
+    buf_ptr = (unsigned int *)((char *)coded_buf_seg + status_buffer->bs_byte_count_offset);
 
     /* the stream size is writen into the bs_byte_count_offset address of buffer */
     coded_buf_seg->base.size = *buf_ptr;
 
-    coded_buf_seg->mapped = 1;
-
     /* One VACodedBufferSegment for VP9 will be added later.
      * It will be linked to the next element of coded_buf_seg->base.next
      */
 
     return VA_STATUS_SUCCESS;
 }
+
+Bool
+gen9_vp9_pak_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
+{
+    /* VME & PAK share the same context */
+    struct gen9_encoder_context_vp9 *pak_context = encoder_context->vme_context;
+
+    if (!pak_context)
+        return false;
+
+    encoder_context->mfc_context = pak_context;
+    encoder_context->mfc_context_destroy = gen9_vp9_pak_context_destroy;
+    encoder_context->mfc_pipeline = gen9_vp9_pak_pipeline;
+    encoder_context->mfc_brc_prepare = gen9_vp9_pak_brc_prepare;
+    encoder_context->get_status = gen9_vp9_get_coded_status;
+    return true;
+}
index 1c24d00..912896d 100644 (file)
@@ -2654,16 +2654,7 @@ i965_MapBuffer(VADriverContextP ctx,
                     coded_buffer_segment->status_support) {
                     vaStatus = obj_context->hw_context->get_status(ctx, obj_context->hw_context, coded_buffer_segment);
                 } else {
-
-                    if (coded_buffer_segment->codec == CODEC_VP9) {
-
-                        if (obj_context == NULL)
-                            return VA_STATUS_ERROR_ENCODING_ERROR;
-
-                        gen9_vp9_get_coded_status(ctx, (char *)coded_buffer_segment,
-                                                  obj_context->hw_context);
-                    }
-                    else if (coded_buffer_segment->codec == CODEC_H264 ||
+                    if (coded_buffer_segment->codec == CODEC_H264 ||
                         coded_buffer_segment->codec == CODEC_H264_MVC) {
                         delimiter0 = H264_DELIMITER0;
                         delimiter1 = H264_DELIMITER1;
@@ -2690,9 +2681,6 @@ i965_MapBuffer(VADriverContextP ctx,
                         ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
                     }
 
-                    if(coded_buffer_segment->codec == CODEC_VP9) {
-                        /* it is already handled */
-                    } else
                     if(coded_buffer_segment->codec == CODEC_JPEG) {
                         for(i = 0; i <  obj_buffer->size_element - header_offset - 1 - 0x1000; i++) {
                             if( (buffer[i] == 0xFF) && (buffer[i + 1] == 0xD9)) {