[Libva] [PATCH 2/3] Convert encoding misc param type to index

Zhong Li zhong.li at intel.com
Tue May 13 02:20:07 PDT 2014


Add function va_enc_misc_param_type_to_idx(),
it is helpful to reduce misc_param of encode_state buffer size.

Signed-off-by: Zhong Li <zhong.li at intel.com>
---
 src/gen6_mfc_common.c |    3 ++-
 src/i965_drv_video.c  |   45 ++++++++++++++++++++++++++++++++++++++++++---
 src/i965_drv_video.h  |    3 +++
 3 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 33b9d55..faad699 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -134,7 +134,8 @@ static void intel_mfc_brc_init(struct encode_state *encode_state,
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
     VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer;
-    VAEncMiscParameterBuffer* pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer;
+    int idx = va_enc_misc_param_type_to_idx(VAEncMiscParameterTypeHRD);
+    VAEncMiscParameterBuffer* pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[idx]->buffer;
     VAEncMiscParameterHRD* pParameterHRD = (VAEncMiscParameterHRD*)pMiscParamHRD->data;
     double bitrate = pSequenceParameter->bits_per_second;
     double framerate = (double)pSequenceParameter->time_scale /(2 * (double)pSequenceParameter->num_units_in_tick);
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index e505e4a..808c0d5 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -261,6 +261,43 @@ va_enc_packed_type_to_idx(int packed_type)
     return idx;
 }
 
+#define I965_ENC_MISC_PARAM_TYPE_FEI_FRAME_CONTROL_INDEX 14
+
+int
+va_enc_misc_param_type_to_idx(int misc_param_type)
+{
+    int idx = 0;
+
+    switch (misc_param_type) {
+    case VAEncMiscParameterTypeFrameRate:
+    case VAEncMiscParameterTypeRateControl:
+    case VAEncMiscParameterTypeMaxSliceSize:
+    case VAEncMiscParameterTypeAIR:
+    case VAEncMiscParameterTypeMaxFrameSize:
+    case VAEncMiscParameterTypeHRD:
+    case VAEncMiscParameterTypeQualityLevel:
+    case VAEncMiscParameterTypeRIR:
+    case VAEncMiscParameterTypeQuantization:
+    case VAEncMiscParameterTypeSkipFrame:
+    case VAEncMiscParameterTypeROI:
+    case VAEncMiscParameterTypeCIR:
+	 idx = misc_param_type;
+	 break;
+
+    case VAEncMiscParameterTypeFEIFrameControlIntel:
+	 idx = I965_ENC_MISC_PARAM_TYPE_FEI_FRAME_CONTROL_INDEX;
+	 break;
+
+    default:
+	 /* Should not get here */
+	 ASSERT_RET(0, 0);
+	 break;
+    }
+
+    ASSERT_RET(idx < 16, 0);
+    return idx;
+}
+
 VAStatus 
 i965_QueryConfigProfiles(VADriverContextP ctx,
                          VAProfile *profile_list,       /* out */
@@ -2171,17 +2208,19 @@ i965_encoder_render_misc_parameter_buffer(VADriverContextP ctx,
 {
     struct encode_state *encode = &obj_context->codec_state.encode;
     VAEncMiscParameterBuffer *param = NULL;
+    int type_index;
 
     ASSERT_RET(obj_buffer->buffer_store->bo == NULL, VA_STATUS_ERROR_INVALID_BUFFER);
     ASSERT_RET(obj_buffer->buffer_store->buffer, VA_STATUS_ERROR_INVALID_BUFFER);
 
     param = (VAEncMiscParameterBuffer *)obj_buffer->buffer_store->buffer;
+    type_index = va_enc_misc_param_type_to_idx(param->type);
 
-    if (param->type >= ARRAY_ELEMS(encode->misc_param))
+    if (type_index >= ARRAY_ELEMS(encode->misc_param))
         return VA_STATUS_ERROR_INVALID_PARAMETER;
 
-    i965_release_buffer_store(&encode->misc_param[param->type]);
-    i965_reference_buffer_store(&encode->misc_param[param->type], obj_buffer->buffer_store);
+    i965_release_buffer_store(&encode->misc_param[type_index]);
+    i965_reference_buffer_store(&encode->misc_param[type_index], obj_buffer->buffer_store);
 
     return VA_STATUS_SUCCESS;
 }
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 7c2306c..d7e8eb2 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -391,6 +391,9 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
 int
 va_enc_packed_type_to_idx(int packed_type);
 
+int
+va_enc_misc_param_type_to_idx(int misc_param_type);
+
 /* reserve 2 byte for internal using */
 #define CODEC_H264      0
 #define CODEC_MPEG2     1
-- 
1.7.9.5



More information about the Libva mailing list