[Libva] [PATCH 1/3] HEVC: Fix the Wrong slice type usage

Qu, Pengfei pengfei.qu at intel.com
Thu May 28 19:09:34 PDT 2015


See comments inline.

-----Original Message-----
From: Libva [mailto:libva-bounces at lists.freedesktop.org] On Behalf Of sreerenj.balachandran at intel.com
Sent: Friday, May 22, 2015 9:46 AM
To: libva at lists.freedesktop.org
Subject: [Libva] [PATCH 1/3] HEVC: Fix the Wrong slice type usage

From: Sreerenj Balachandran <sreerenj.balachandran at intel.com>

Don't mix the slice_type values of h264 and h265.

The SLICE_TYPE values of H264 and HEVC are different.
H264: Bslice_type = 1, Pslice_type = 0
HEVC: Bslice_type = 0, Pslice_type = 1
---
 src/gen6_mfc_common.c    |  4 ++--
 src/gen9_vme.c           | 12 ++++++------
 src/i965_encoder_utils.c | 16 ++++++++--------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c index 6ae29f3..2babb99 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -1811,7 +1811,7 @@ void intel_vme_hevc_update_mbmv_cost(VADriverContextP ctx,
 
     assert(qp <= QP_MAX);
     lambda = intel_lambda_qp(qp);
-    if (slice_type == SLICE_TYPE_I) {
+    if (slice_type == HEVC_SLICE_I) {
         vme_state_message[MODE_INTRA_16X16] = 0;
         m_cost = lambda * 4;
         vme_state_message[MODE_INTRA_8X8] = intel_format_lutvalue(m_cost, 0x8f); @@ -1857,7 +1857,7 @@ void intel_vme_hevc_update_mbmv_cost(VADriverContextP ctx,
         m_costf = lambda * 3.5;
         m_cost = m_costf;
         vme_state_message[MODE_INTRA_NONPRED] = intel_format_lutvalue(m_cost, 0x6f);
-        if (slice_type == SLICE_TYPE_P) {
+        if (slice_type == HEVC_SLICE_P) {
             m_costf = lambda * 2.5;
             m_cost = m_costf;
             vme_state_message[MODE_INTER_16X16] = intel_format_lutvalue(m_cost, 0x8f); diff --git a/src/gen9_vme.c b/src/gen9_vme.c index 39ac180..b28470b 100644


[Pengfei] here we should still use SLICE_TYPE_I /SLICE_TYPE_P. As we use the AVC VME HW. Also this maybe the reason you see B size bigger than P.



--- a/src/gen9_vme.c
+++ b/src/gen9_vme.c
@@ -1334,7 +1334,7 @@ gen9_vme_hevc_output_buffer_setup(VADriverContextP ctx,
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
     VAEncSequenceParameterBufferHEVC *pSequenceParameter = (VAEncSequenceParameterBufferHEVC *)encode_state->seq_param_ext->buffer;
     VAEncSliceParameterBufferHEVC *pSliceParameter = (VAEncSliceParameterBufferHEVC *)encode_state->slice_params_ext[0]->buffer;
-    int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I;
+    int is_intra = pSliceParameter->slice_type == HEVC_SLICE_I;
     int width_in_mbs = (pSequenceParameter->pic_width_in_luma_samples + 15)/16;
     int height_in_mbs = (pSequenceParameter->pic_height_in_luma_samples + 15)/16;
 
@@ -1405,12 +1405,12 @@ gen9_vme_hevc_surface_setup(VADriverContextP ctx,
         int slice_type;
 
         slice_type = slice_param->slice_type;
-        assert(slice_type != SLICE_TYPE_I && slice_type != SLICE_TYPE_SI);
+        assert(slice_type != HEVC_SLICE_I);
 
         /* to do HEVC */
         intel_hevc_vme_reference_state(ctx, encode_state, encoder_context, 0, 1, gen9_vme_source_surface_state);
 
-        if (slice_type == SLICE_TYPE_B)
+        if (slice_type == HEVC_SLICE_B)
             intel_hevc_vme_reference_state(ctx, encode_state, encoder_context, 1, 2, gen9_vme_source_surface_state);
     }
 
@@ -1669,9 +1669,9 @@ static void gen9_vme_hevc_pipeline_programing(VADriverContextP ctx,
         }
     }
 
-    if (pSliceParameter->slice_type == SLICE_TYPE_I) {
+    if (pSliceParameter->slice_type == HEVC_SLICE_I) {
         kernel_shader = VME_INTRA_SHADER;
-    } else if (pSliceParameter->slice_type == SLICE_TYPE_P) {
+    } else if (pSliceParameter->slice_type == HEVC_SLICE_P) {
         kernel_shader = VME_INTER_SHADER;
     } else {
         kernel_shader = VME_BINTER_SHADER; @@ -1715,7 +1715,7 @@ static VAStatus gen9_vme_hevc_prepare(VADriverContextP ctx,  {
     VAStatus vaStatus = VA_STATUS_SUCCESS;
     VAEncSliceParameterBufferHEVC *pSliceParameter = (VAEncSliceParameterBufferHEVC *)encode_state->slice_params_ext[0]->buffer;
-    int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I;
+    int is_intra = pSliceParameter->slice_type == HEVC_SLICE_I;
     VAEncSequenceParameterBufferHEVC *pSequenceParameter = (VAEncSequenceParameterBufferHEVC *)encode_state->seq_param_ext->buffer;
     struct gen6_vme_context *vme_context = encoder_context->vme_context;
 
diff --git a/src/i965_encoder_utils.c b/src/i965_encoder_utils.c index 6638491..9c9619c 100644
--- a/src/i965_encoder_utils.c
+++ b/src/i965_encoder_utils.c
@@ -902,20 +902,20 @@ void hevc_short_term_ref_pic_set(avc_bitstream *bs,VAEncSliceParameterBufferHEVC
 
     hevc_rps.inter_ref_pic_set_prediction_flag = 0;
     /* s0: between I and P/B; s1 : between P and B */
-    hevc_rps.num_negative_pics               = (slice_param->slice_type!=SLICE_TYPE_I) ? 1 : 0;
-    hevc_rps.num_positive_pics               = (slice_param->slice_type==SLICE_TYPE_B) ? 1 : 0;
+    hevc_rps.num_negative_pics               = (slice_param->slice_type!=HEVC_SLICE_I) ? 1 : 0;
+    hevc_rps.num_positive_pics               = (slice_param->slice_type==HEVC_SLICE_B) ? 1 : 0;
     hevc_rps.delta_poc_s0_minus1[0]          = 0;
     hevc_rps.used_by_curr_pic_s0_flag[0]     = 0;
     hevc_rps.delta_poc_s1_minus1[0]          = 0;
     hevc_rps.used_by_curr_pic_s1_flag[0]     = 0;
     if(slice_param->num_ref_idx_l0_active_minus1==0 )
     {
-        hevc_rps.delta_poc_s0_minus1[0]          = (slice_param->slice_type==SLICE_TYPE_I) ? 0 : ( curPicOrderCnt - slice_param->ref_pic_list0[0].pic_order_cnt-1); //0;
+        hevc_rps.delta_poc_s0_minus1[0]          = (slice_param->slice_type==HEVC_SLICE_I) ? 0 : ( curPicOrderCnt - slice_param->ref_pic_list0[0].pic_order_cnt-1); //0;
         hevc_rps.used_by_curr_pic_s0_flag[0]     = 1;
     }
     if(slice_param->num_ref_idx_l1_active_minus1==0 )
     {
-        hevc_rps.delta_poc_s1_minus1[0]          = (slice_param->slice_type==SLICE_TYPE_I) ? 0 : ( slice_param->ref_pic_list1[0].pic_order_cnt -curPicOrderCnt -1);
+        hevc_rps.delta_poc_s1_minus1[0]          = (slice_param->slice_type==HEVC_SLICE_I) ? 0 : ( slice_param->ref_pic_list1[0].pic_order_cnt -curPicOrderCnt -1);
         hevc_rps.used_by_curr_pic_s1_flag[0]     = 1;
     }
 
@@ -1045,7 +1045,7 @@ static void slice_rbsp(avc_bitstream *bs,
             avc_bitstream_put_ui(bs, slice_param->slice_fields.bits.slice_sao_chroma_flag, 1);
         }
 
-        if (slice_param->slice_type != SLICE_TYPE_I)
+        if (slice_param->slice_type != HEVC_SLICE_I)
         {
             /* num_ref_idx_active_override_flag. 0 */
             avc_bitstream_put_ui(bs, 0, 1); @@ -1054,7 +1054,7 @@ static void slice_rbsp(avc_bitstream *bs,
             /* No reference picture set modification */
 
             /* MVD_l1_zero_flag */
-            if (slice_param->slice_type == SLICE_TYPE_B)
+            if (slice_param->slice_type == HEVC_SLICE_B)
                 avc_bitstream_put_ui(bs, slice_param->slice_fields.bits.mvd_l1_zero_flag, 1);
 
             /* cabac_init_present_flag. 0 */ @@ -1068,9 +1068,9 @@ static void slice_rbsp(avc_bitstream *bs,
                 */
             }
             if (((pic_param->pic_fields.bits.weighted_pred_flag) &&
-                (slice_param->slice_type == SLICE_TYPE_P)) ||
+                (slice_param->slice_type == HEVC_SLICE_P)) ||
                 ((pic_param->pic_fields.bits.weighted_bipred_flag) &&
-                (slice_param->slice_type == SLICE_TYPE_B)))
+                (slice_param->slice_type == HEVC_SLICE_B)))
             {
                 /* TBD:
                 * add the weighted table
--
2.1.4

_______________________________________________
Libva mailing list
Libva at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libva


More information about the Libva mailing list