[Libva] [Libva-intel-driver][PATCH v3 09/18] Use a 2-dimensional array to store misc parameters

Xiang, Haihao haihao.xiang at intel.com
Tue Sep 13 08:02:38 UTC 2016


This patch allows multiple misc parameter buffers for the same type
within the same Begin/Render/End sequence in the future. Currently
only the first element for each misc type is used, so it doesn't
change any functionality yet.

v2: rebased

Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
Tested-by: Luo, Focus <focus.luo at intel.com>
---
 src/gen6_mfc_common.c  |  4 ++--
 src/gen8_mfc.c         |  6 +++---
 src/gen9_mfc_hevc.c    |  4 ++--
 src/gen9_vdenc.c       |  4 ++--
 src/gen9_vp9_encoder.c | 26 +++++++++++++-------------
 src/i965_drv_video.c   | 16 +++++++++-------
 src/i965_drv_video.h   |  2 +-
 src/i965_encoder.c     | 10 +++++-----
 8 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 67a84ea..8677ecb 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -1884,8 +1884,8 @@ intel_h264_enc_roi_config(VADriverContextP ctx,
     if (!encoder_context->context_roi || (encode_state->num_slice_params_ext > 1))
         return;
 
-    if (encode_state->misc_param[VAEncMiscParameterTypeROI] != NULL) {
-        pMiscParamROI = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeROI]->buffer;
+    if (encode_state->misc_param[VAEncMiscParameterTypeROI][0] != NULL) {
+        pMiscParamROI = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeROI][0]->buffer;
         pParamROI = (VAEncMiscParameterBufferROI *)pMiscParamROI->data;
 
         /* check whether number of ROI is correct */
diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
index f880333..daef41c 100644
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -3324,9 +3324,9 @@ static void gen8_mfc_vp8_brc_init(struct encode_state *encode_state,
 {
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
     VAEncSequenceParameterBufferVP8 *seq_param = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer;
-    VAEncMiscParameterBuffer* misc_param_hrd = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer;
+    VAEncMiscParameterBuffer* misc_param_hrd = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD][0]->buffer;
     VAEncMiscParameterHRD* param_hrd = (VAEncMiscParameterHRD*)misc_param_hrd->data;
-    VAEncMiscParameterBuffer* misc_param_frame_rate_buffer = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
+    VAEncMiscParameterBuffer* misc_param_frame_rate_buffer = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer;
     VAEncMiscParameterFrameRate* param_frame_rate = (VAEncMiscParameterFrameRate*)misc_param_frame_rate_buffer->data;
     double bitrate = seq_param->bits_per_second;
     unsigned int frame_rate = param_frame_rate->framerate;
@@ -3523,7 +3523,7 @@ static bool gen8_mfc_vp8_brc_updated_check(struct encode_state *encode_state,
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
     double cur_fps, cur_bitrate;
     VAEncSequenceParameterBufferVP8 *seq_param = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer;
-    VAEncMiscParameterBuffer *misc_param_frame_rate_buf = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
+    VAEncMiscParameterBuffer *misc_param_frame_rate_buf = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer;
     VAEncMiscParameterFrameRate *param_frame_rate = (VAEncMiscParameterFrameRate*)misc_param_frame_rate_buf->data;
     unsigned int frame_rate = param_frame_rate->framerate;
 
diff --git a/src/gen9_mfc_hevc.c b/src/gen9_mfc_hevc.c
index 9aaf4e9..be5666c 100644
--- a/src/gen9_mfc_hevc.c
+++ b/src/gen9_mfc_hevc.c
@@ -2238,10 +2238,10 @@ static void intel_hcpe_brc_init(struct encode_state *encode_state,
     qp1_size = qp1_size * bpp;
     qp51_size = qp51_size * bpp;
 
-    if (!encode_state->misc_param[VAEncMiscParameterTypeHRD] || !encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer)
+    if (!encode_state->misc_param[VAEncMiscParameterTypeHRD][0] || !encode_state->misc_param[VAEncMiscParameterTypeHRD][0]->buffer)
         return;
 
-    pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer;
+    pMiscParamHRD = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeHRD][0]->buffer;
     pParameterHRD = (VAEncMiscParameterHRD*)pMiscParamHRD->data;
 
     if (pSequenceParameter->ip_period) {
diff --git a/src/gen9_vdenc.c b/src/gen9_vdenc.c
index e19def1..46da334 100644
--- a/src/gen9_vdenc.c
+++ b/src/gen9_vdenc.c
@@ -931,10 +931,10 @@ gen9_vdenc_update_misc_parameters(VADriverContextP ctx,
     VAEncMiscParameterBuffer *misc_param;
 
     for (i = 0; i < ARRAY_ELEMS(encode_state->misc_param); i++) {
-        if (!encode_state->misc_param[i] || !encode_state->misc_param[i]->buffer)
+        if (!encode_state->misc_param[i][0] || !encode_state->misc_param[i][0]->buffer)
             continue;
 
-        misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i]->buffer;
+        misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i][0]->buffer;
 
         switch (misc_param->type) {
         case VAEncMiscParameterTypeFrameRate:
diff --git a/src/gen9_vp9_encoder.c b/src/gen9_vp9_encoder.c
index 34952c9..f39d6d0 100644
--- a/src/gen9_vp9_encoder.c
+++ b/src/gen9_vp9_encoder.c
@@ -3944,7 +3944,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                     VAEncMiscParameterHRD *misc_param_hrd;
 
                     misc_param = (VAEncMiscParameterBuffer *)
-                        encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer;
+                        encode_state->misc_param[VAEncMiscParameterTypeHRD][0]->buffer;
                     misc_param_hrd = (VAEncMiscParameterHRD *)misc_param->data;
 
                     vp9_state->init_vbv_buffer_fullness_in_bit = misc_param_hrd->initial_buffer_fullness;
@@ -3955,7 +3955,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                     VAEncMiscParameterFrameRate *misc_param_fr;
 
                     misc_param = (VAEncMiscParameterBuffer *)
-                        encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
+                        encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer;
                     misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data;
 
                     vp9_state->frame_rate = misc_param_fr->framerate;
@@ -3969,7 +3969,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                     VAEncMiscParameterRateControl *misc_param_rc;
 
                     misc_param = (VAEncMiscParameterBuffer *)
-                        encode_state->misc_param[VAEncMiscParameterTypeRateControl]->buffer;
+                        encode_state->misc_param[VAEncMiscParameterTypeRateControl][0]->buffer;
                     misc_param_rc = (VAEncMiscParameterRateControl *)misc_param->data;
 
                     vp9_state->target_bit_rate = misc_param_rc->bits_per_second;
@@ -3990,7 +3990,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                     VAEncMiscParameterFrameRate *misc_param_fr;
 
                     misc_param = (VAEncMiscParameterBuffer *)
-                        encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
+                        encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer;
                     misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data;
 
                     vp9_state->frame_rate = misc_param_fr->framerate;
@@ -4003,7 +4003,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                     VAEncMiscParameterRateControl *misc_param_rc;
 
                     misc_param = (VAEncMiscParameterBuffer *)
-                        encode_state->misc_param[VAEncMiscParameterTypeRateControl]->buffer;
+                        encode_state->misc_param[VAEncMiscParameterTypeRateControl][0]->buffer;
                     misc_param_rc = (VAEncMiscParameterRateControl *)misc_param->data;
 
                     vp9_state->max_bit_rate = misc_param_rc->bits_per_second;
@@ -4027,7 +4027,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                VAEncMiscParameterFrameRate *misc_param_fr;
 
                misc_param = (VAEncMiscParameterBuffer *)
-                   encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
+                   encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer;
                misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data;
 
                if (vp9_state->frame_rate != misc_param_fr->framerate) {
@@ -4049,7 +4049,7 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
                 VAEncMiscParameterRateControl *misc_param_rc;
 
                 misc_param = (VAEncMiscParameterBuffer *)
-                    encode_state->misc_param[VAEncMiscParameterTypeRateControl]->buffer;
+                    encode_state->misc_param[VAEncMiscParameterTypeRateControl][0]->buffer;
                 misc_param_rc = (VAEncMiscParameterRateControl *)misc_param->data;
 
                 if (encoder_context->rate_control_mode == VA_RC_CBR) {
@@ -5815,19 +5815,19 @@ gen9_vp9_pak_brc_prepare(struct encode_state *encode_state,
         }
 
         /* Frame_rate */
-        if (encode_state->misc_param[VAEncMiscParameterTypeFrameRate] &&
-            encode_state->misc_param[VAEncMiscParameterTypeFrameRate]->buffer) {
+        if (encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0] &&
+            encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer) {
             vp9_state->brc_flag_check |= VP9_BRC_FR;
         }
 
         /* HRD */
-        if (encode_state->misc_param[VAEncMiscParameterTypeRateControl] &&
-            encode_state->misc_param[VAEncMiscParameterTypeRateControl]->buffer) {
+        if (encode_state->misc_param[VAEncMiscParameterTypeRateControl][0] &&
+            encode_state->misc_param[VAEncMiscParameterTypeRateControl][0]->buffer) {
             vp9_state->brc_flag_check |= VP9_BRC_RC;
         }
 
-        if (encode_state->misc_param[VAEncMiscParameterTypeHRD] &&
-            encode_state->misc_param[VAEncMiscParameterTypeHRD]->buffer) {
+        if (encode_state->misc_param[VAEncMiscParameterTypeHRD][0] &&
+            encode_state->misc_param[VAEncMiscParameterTypeHRD][0]->buffer) {
             vp9_state->brc_flag_check |= VP9_BRC_HRD;
         }
 
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 2ca84c0..a8ecb24 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1992,7 +1992,7 @@ static void
 i965_destroy_context(struct object_heap *heap, struct object_base *obj)
 {
     struct object_context *obj_context = (struct object_context *)obj;
-    int i;
+    int i, j;
 
     if (obj_context->hw_context) {
         obj_context->hw_context->destroy(obj_context->hw_context);
@@ -2017,7 +2017,8 @@ i965_destroy_context(struct object_heap *heap, struct object_base *obj)
             i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_data[i]);
 
         for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.misc_param); i++)
-            i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[i]);
+            for (j = 0; j < ARRAY_ELEMS(obj_context->codec_state.encode.misc_param[0]); j++)
+                i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[i][j]);
 
         for (i = 0; i < obj_context->codec_state.encode.num_slice_params_ext; i++)
             i965_release_buffer_store(&obj_context->codec_state.encode.slice_params_ext[i]);
@@ -2728,7 +2729,7 @@ i965_BeginPicture(VADriverContextP ctx,
     struct object_surface *obj_surface = SURFACE(render_target);
     struct object_config *obj_config;
     VAStatus vaStatus = VA_STATUS_SUCCESS;
-    int i;
+    int i, j;
 
     ASSERT_RET(obj_context, VA_STATUS_ERROR_INVALID_CONTEXT);
     ASSERT_RET(obj_surface, VA_STATUS_ERROR_INVALID_SURFACE);
@@ -2779,13 +2780,14 @@ i965_BeginPicture(VADriverContextP ctx,
         * It is uncertain whether the other misc buffer should be released.
         * So only release the previous ROI buffer.
         */
-        i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[VAEncMiscParameterTypeROI]);
+        i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[VAEncMiscParameterTypeROI][0]);
 
         i965_release_buffer_store(&obj_context->codec_state.encode.encmb_map);
 
         if (obj_config->profile == VAProfileVP9Profile0) {
             for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.misc_param); i++)
-                i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[i]);
+                for (j = 0; j < ARRAY_ELEMS(obj_context->codec_state.encode.misc_param[0]); j++)
+                    i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[i][j]);
 
             i965_release_buffer_store(&obj_context->codec_state.encode.seq_param_ext);
         }
@@ -3111,8 +3113,8 @@ i965_encoder_render_misc_parameter_buffer(VADriverContextP ctx,
     if (param->type >= 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[param->type][0]);
+    i965_reference_buffer_store(&encode->misc_param[param->type][0], obj_buffer->buffer_store);
 
     return VA_STATUS_SUCCESS;
 }
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 9b9bfac..7bef613 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -266,7 +266,7 @@ struct encode_state
 
     int last_packed_header_type;
 
-    struct buffer_store *misc_param[16];
+    struct buffer_store *misc_param[16][8];
 
     VASurfaceID current_render_target;
     struct object_surface *input_yuv_object;
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index ec5dd2f..0620c40 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -434,10 +434,10 @@ intel_encoder_check_brc_parameter(VADriverContextP ctx,
         return ret;
 
     for (i = 0; i < ARRAY_ELEMS(encode_state->misc_param); i++) {
-        if (!encode_state->misc_param[i] || !encode_state->misc_param[i]->buffer)
+        if (!encode_state->misc_param[i][0] || !encode_state->misc_param[i][0]->buffer)
             continue;
 
-        misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i]->buffer;
+        misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i][0]->buffer;
 
         switch (misc_param->type) {
         case VAEncMiscParameterTypeFrameRate:
@@ -473,9 +473,9 @@ intel_encoder_check_misc_parameter(VADriverContextP ctx,
 {
     VAStatus ret = VA_STATUS_SUCCESS;
 
-    if (encode_state->misc_param[VAEncMiscParameterTypeQualityLevel] &&
-        encode_state->misc_param[VAEncMiscParameterTypeQualityLevel]->buffer) {
-        VAEncMiscParameterBuffer* pMiscParam = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeQualityLevel]->buffer;
+    if (encode_state->misc_param[VAEncMiscParameterTypeQualityLevel][0] &&
+        encode_state->misc_param[VAEncMiscParameterTypeQualityLevel][0]->buffer) {
+        VAEncMiscParameterBuffer* pMiscParam = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeQualityLevel][0]->buffer;
         VAEncMiscParameterBufferQualityLevel* param_quality_level = (VAEncMiscParameterBufferQualityLevel*)pMiscParam->data;
         encoder_context->quality_level = param_quality_level->quality_level;
 
-- 
1.9.1



More information about the Libva mailing list