[Libva] [Libva-intel-driver][PATCH 08/18] move QpPrimeY to another inner structure for H.264/VP8 BRC

Xiang, Haihao haihao.xiang at intel.com
Tue Sep 6 15:41:53 UTC 2016


It doesn't cause functionality change

Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/gen6_mfc.c        |  4 ++--
 src/gen6_mfc.h        |  2 +-
 src/gen6_mfc_common.c | 58 +++++++++++++++++++++++++++------------------------
 src/gen6_vme.c        |  2 +-
 src/gen75_mfc.c       |  4 ++--
 src/gen75_vme.c       |  4 ++--
 src/gen7_vme.c        |  2 +-
 src/gen8_mfc.c        | 38 ++++++++++++++++-----------------
 src/gen8_vme.c        |  2 +-
 src/gen9_vme.c        |  2 +-
 10 files changed, 61 insertions(+), 57 deletions(-)

diff --git a/src/gen6_mfc.c b/src/gen6_mfc.c
index 3c0d4cc..c480430 100644
--- a/src/gen6_mfc.c
+++ b/src/gen6_mfc.c
@@ -799,7 +799,7 @@ gen6_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             qp_slice = qp;
@@ -1189,7 +1189,7 @@ gen6_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             /* Use the adjusted qp when slice_header is generated by driver */
diff --git a/src/gen6_mfc.h b/src/gen6_mfc.h
index 3faaed8..04db6c8 100644
--- a/src/gen6_mfc.h
+++ b/src/gen6_mfc.h
@@ -217,7 +217,6 @@ struct gen6_mfc_context
 
     //Bit rate tracking context
     struct {
-        unsigned int QpPrimeY;
         unsigned int MaxQpNegModifier;
         unsigned int MaxQpPosModifier;
         unsigned char Correct[6];
@@ -231,6 +230,7 @@ struct gen6_mfc_context
         int mode;
         int gop_nums[3];
         int target_frame_size[3]; // I,P,B
+        int qp_prime_y[3];
         double bits_per_frame;
         double qpf_rounding_accumulator;
 
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 1f712e0..4c0d4cc 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -74,7 +74,6 @@ intel_mfc_bit_rate_control_context_init(struct encode_state *encode_state,
     int i;
 
     for(i = 0 ; i < 3; i++) {
-        mfc_context->bit_rate_control_context[i].QpPrimeY = 26;
         mfc_context->bit_rate_control_context[i].MaxQpNegModifier = 6;
         mfc_context->bit_rate_control_context[i].MaxQpPosModifier = 6;
         mfc_context->bit_rate_control_context[i].GrowInit = 6;
@@ -104,9 +103,14 @@ static void intel_mfc_brc_init(struct encode_state *encode_state,
     double qp1_size = 0.1 * 8 * 3 * (encoder_context->frame_width_in_mbs << 4) * (encoder_context->frame_height_in_mbs << 4) / 2;
     double qp51_size = 0.001 * 8 * 3 * (encoder_context->frame_width_in_mbs << 4) * (encoder_context->frame_height_in_mbs << 4)/2;
     double bpf;
+    int i;
 
     mfc_context->brc.mode = encoder_context->rate_control_mode;
 
+    for (i = 0; i < 3; i++) {
+        mfc_context->brc.qp_prime_y[i] = 26;
+    }
+
     mfc_context->brc.target_frame_size[SLICE_TYPE_I] = (int)((double)((bitrate * intra_period)/framerate) /
                                                              (double)(inum + BRC_PWEIGHT * pnum + BRC_BWEIGHT * bnum));
     mfc_context->brc.target_frame_size[SLICE_TYPE_P] = BRC_PWEIGHT * mfc_context->brc.target_frame_size[SLICE_TYPE_I];
@@ -127,19 +131,19 @@ static void intel_mfc_brc_init(struct encode_state *encode_state,
     mfc_context->hrd.violation_noted = 0;
 
     if ((bpf > qp51_size) && (bpf < qp1_size)) {
-        mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
+        mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
     }
     else if (bpf >= qp1_size)
-        mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 1;
+        mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 1;
     else if (bpf <= qp51_size)
-        mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = 51;
+        mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 51;
 
-    mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY = mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY;
-    mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY = mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY;
+    mfc_context->brc.qp_prime_y[SLICE_TYPE_I] = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
+    mfc_context->brc.qp_prime_y[SLICE_TYPE_B] = mfc_context->brc.qp_prime_y[SLICE_TYPE_I];
 
-    BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY, 1, 51);
-    BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY, 1, 51);
-    BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY, 1, 51);
+    BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_I], 1, 51);
+    BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_P], 1, 51);
+    BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_B], 1, 51);
 }
 
 int intel_mfc_update_hrd(struct encode_state *encode_state,
@@ -174,9 +178,9 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
     gen6_brc_status sts = BRC_NO_HRD_VIOLATION;
     VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer; 
     int slicetype = intel_avc_enc_slice_type_fixup(pSliceParameter->slice_type);
-    int qpi = mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY;
-    int qpp = mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY;
-    int qpb = mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY;
+    int qpi = mfc_context->brc.qp_prime_y[SLICE_TYPE_I];
+    int qpp = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
+    int qpb = mfc_context->brc.qp_prime_y[SLICE_TYPE_B];
     int qp; // quantizer of previously encoded slice of current type
     int qpn; // predicted quantizer for next frame of current type in integer format
     double qpf; // predicted quantizer for next frame of current type in float format
@@ -189,7 +193,7 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
     double x, y;
     double frame_size_alpha;
 
-    qp = mfc_context->bit_rate_control_context[slicetype].QpPrimeY;
+    qp = mfc_context->brc.qp_prime_y[slicetype];
 
     target_frame_size = mfc_context->brc.target_frame_size[slicetype];
     if (mfc_context->hrd.buffer_capacity < 5)
@@ -251,23 +255,23 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
         /* correcting QPs of slices of other types */
         if (slicetype == SLICE_TYPE_P) {
             if (abs(qpn + BRC_P_B_QP_DIFF - qpb) > 2)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY += (qpn + BRC_P_B_QP_DIFF - qpb) >> 1;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_P_B_QP_DIFF - qpb) >> 1;
             if (abs(qpn - BRC_I_P_QP_DIFF - qpi) > 2)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY += (qpn - BRC_I_P_QP_DIFF - qpi) >> 1;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi) >> 1;
         } else if (slicetype == SLICE_TYPE_I) {
             if (abs(qpn + BRC_I_B_QP_DIFF - qpb) > 4)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY += (qpn + BRC_I_B_QP_DIFF - qpb) >> 2;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_I_B_QP_DIFF - qpb) >> 2;
             if (abs(qpn + BRC_I_P_QP_DIFF - qpp) > 2)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
         } else { // SLICE_TYPE_B
             if (abs(qpn - BRC_P_B_QP_DIFF - qpp) > 2)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY += (qpn - BRC_P_B_QP_DIFF - qpp) >> 1;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn - BRC_P_B_QP_DIFF - qpp) >> 1;
             if (abs(qpn - BRC_I_B_QP_DIFF - qpi) > 4)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY += (qpn - BRC_I_B_QP_DIFF - qpi) >> 2;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_B_QP_DIFF - qpi) >> 2;
         }
-        BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY, 1, 51);
-        BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY, 1, 51);
-        BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_B].QpPrimeY, 1, 51);
+        BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_I], 1, 51);
+        BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_P], 1, 51);
+        BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_B], 1, 51);
     } else if (sts == BRC_UNDERFLOW) { // underflow
         if (qpn <= qp) qpn = qp + 1;
         if (qpn > 51) {
@@ -282,7 +286,7 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
         }
     }
 
-    mfc_context->bit_rate_control_context[slicetype].QpPrimeY = qpn;
+    mfc_context->brc.qp_prime_y[slicetype] = qpn;
 
     return sts;
 }
@@ -801,7 +805,7 @@ void intel_vme_update_mbmv_cost(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     if (vme_state_message == NULL)
         return;
@@ -830,7 +834,7 @@ void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = q_matrix->quantization_index[0];
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     lambda = intel_lambda_qp(qp * QP_MAX / VP8_QP_MAX);
 
@@ -959,7 +963,7 @@ gen7_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
 #define		USE_SCOREBOARD		(1 << 21)
  
@@ -1912,7 +1916,7 @@ intel_h264_enc_roi_config(VADriverContextP ctx,
         int qp;
         int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type);
 
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         intel_h264_enc_roi_cbr(ctx, qp, pParamROI,encode_state, encoder_context);
 
     } else if (encoder_context->rate_control_mode == VA_RC_CQP){
diff --git a/src/gen6_vme.c b/src/gen6_vme.c
index 45cc30e..183f087 100644
--- a/src/gen6_vme.c
+++ b/src/gen6_vme.c
@@ -369,7 +369,7 @@ static void gen6_vme_state_setup_fixup(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         vme_state_message[16] = intra_mb_mode_cost_table[pic_param->pic_init_qp + slice_param->slice_qp_delta];
     else
-        vme_state_message[16] = intra_mb_mode_cost_table[mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY];
+        vme_state_message[16] = intra_mb_mode_cost_table[mfc_context->brc.qp_prime_y[SLICE_TYPE_I]];
 }
 
 static VAStatus gen6_vme_vme_state_setup(VADriverContextP ctx,
diff --git a/src/gen75_mfc.c b/src/gen75_mfc.c
index 29aeb66..1ea0147 100644
--- a/src/gen75_mfc.c
+++ b/src/gen75_mfc.c
@@ -1175,7 +1175,7 @@ gen75_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             qp_slice = qp;
@@ -1522,7 +1522,7 @@ gen75_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             qp_slice = qp;
diff --git a/src/gen75_vme.c b/src/gen75_vme.c
index 2f9db57..fd6363d 100644
--- a/src/gen75_vme.c
+++ b/src/gen75_vme.c
@@ -441,7 +441,7 @@ static void gen75_vme_state_setup_fixup(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         vme_state_message[0] = intra_mb_mode_cost_table[pic_param->pic_init_qp + slice_param->slice_qp_delta];
     else
-        vme_state_message[0] = intra_mb_mode_cost_table[mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY];
+        vme_state_message[0] = intra_mb_mode_cost_table[mfc_context->brc.qp_prime_y[SLICE_TYPE_I]];
 }
 
 static VAStatus gen75_vme_vme_state_setup(VADriverContextP ctx,
@@ -504,7 +504,7 @@ gen75_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
diff --git a/src/gen7_vme.c b/src/gen7_vme.c
index 897d169..3073cd4 100644
--- a/src/gen7_vme.c
+++ b/src/gen7_vme.c
@@ -560,7 +560,7 @@ gen7_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
index 409259b..f880333 100644
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -1178,7 +1178,7 @@ gen8_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             qp_slice = qp;
@@ -1535,7 +1535,7 @@ gen8_mfc_avc_batchbuffer_slice(VADriverContextP ctx,
 
     qp_slice = qp;
     if (rate_control_mode == VA_RC_CBR) {
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
         if (encode_state->slice_header_index[slice_index] == 0) {
             pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
             qp_slice = qp;
@@ -3349,14 +3349,14 @@ static void gen8_mfc_vp8_brc_init(struct encode_state *encode_state,
 
     mfc_context->brc.bits_per_frame = bitrate/frame_rate;
 
-    mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY = gen8_mfc_vp8_qindex_estimate(encode_state,
-                                                                   mfc_context,
-                                                                   mfc_context->brc.target_frame_size[SLICE_TYPE_I],
-                                                                   1);
-    mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY = gen8_mfc_vp8_qindex_estimate(encode_state,
-                                                                   mfc_context,
-                                                                   mfc_context->brc.target_frame_size[SLICE_TYPE_P],
-                                                                   0);
+    mfc_context->brc.qp_prime_y[SLICE_TYPE_I] = gen8_mfc_vp8_qindex_estimate(encode_state,
+                                                                             mfc_context,
+                                                                             mfc_context->brc.target_frame_size[SLICE_TYPE_I],
+                                                                             1);
+    mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = gen8_mfc_vp8_qindex_estimate(encode_state,
+                                                                             mfc_context,
+                                                                             mfc_context->brc.target_frame_size[SLICE_TYPE_P],
+                                                                             0);
 
     mfc_context->hrd.buffer_size = (double)param_hrd->buffer_size;
     mfc_context->hrd.current_buffer_fullness =
@@ -3375,8 +3375,8 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
     VAEncPictureParameterBufferVP8 *pic_param = (VAEncPictureParameterBufferVP8 *)encode_state->pic_param_ext->buffer;
     int is_key_frame = !pic_param->pic_flags.bits.frame_type;
     int slicetype = (is_key_frame ? SLICE_TYPE_I : SLICE_TYPE_P);
-    int qpi = mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY;
-    int qpp = mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY;
+    int qpi = mfc_context->brc.qp_prime_y[SLICE_TYPE_I];
+    int qpp = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
     int qp; // quantizer of previously encoded slice of current type
     int qpn; // predicted quantizer for next frame of current type in integer format
     double qpf; // predicted quantizer for next frame of current type in float format
@@ -3391,7 +3391,7 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
     unsigned int max_qindex = pic_param->clamp_qindex_high;
     unsigned int min_qindex = pic_param->clamp_qindex_low;
 
-    qp = mfc_context->bit_rate_control_context[slicetype].QpPrimeY;
+    qp = mfc_context->brc.qp_prime_y[slicetype];
 
     target_frame_size = mfc_context->brc.target_frame_size[slicetype];
     if (mfc_context->hrd.buffer_capacity < 5)
@@ -3454,13 +3454,13 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
         /* correcting QPs of slices of other types */
         if (!is_key_frame) {
             if (abs(qpn - BRC_I_P_QP_DIFF - qpi) > 4)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY += (qpn - BRC_I_P_QP_DIFF - qpi) >> 2;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi) >> 2;
         } else {
             if (abs(qpn + BRC_I_P_QP_DIFF - qpp) > 4)
-                mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
+                mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn + BRC_I_P_QP_DIFF - qpp) >> 2;
         }
-        BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_I].QpPrimeY, min_qindex, max_qindex);
-        BRC_CLIP(mfc_context->bit_rate_control_context[SLICE_TYPE_P].QpPrimeY, min_qindex, max_qindex);
+        BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_I], min_qindex, max_qindex);
+        BRC_CLIP(mfc_context->brc.qp_prime_y[SLICE_TYPE_P], min_qindex, max_qindex);
     } else if (sts == BRC_UNDERFLOW) { // underflow
         if (qpn <= qp) qpn = qp + 2;
         if (qpn > max_qindex) {
@@ -3475,7 +3475,7 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
         }
     }
 
-    mfc_context->bit_rate_control_context[slicetype].QpPrimeY = qpn;
+    mfc_context->brc.qp_prime_y[slicetype] = qpn;
 
     return sts;
 }
@@ -3671,7 +3671,7 @@ static void gen8_mfc_vp8_init(VADriverContextP ctx,
     rate_control_mode = encoder_context->rate_control_mode;
 
     if (rate_control_mode == VA_RC_CBR) {
-        q_matrix->quantization_index[0] = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        q_matrix->quantization_index[0] = mfc_context->brc.qp_prime_y[slice_type];
         for (i = 1; i < 4; i++)
             q_matrix->quantization_index[i] = q_matrix->quantization_index[0];
         for (i = 0; i < 5; i++)
diff --git a/src/gen8_vme.c b/src/gen8_vme.c
index 2a93d1e..8c717b2 100644
--- a/src/gen8_vme.c
+++ b/src/gen8_vme.c
@@ -575,7 +575,7 @@ gen8_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
diff --git a/src/gen9_vme.c b/src/gen9_vme.c
index 4f19409..fa59a52 100644
--- a/src/gen9_vme.c
+++ b/src/gen9_vme.c
@@ -620,7 +620,7 @@ gen9_vme_fill_vme_batchbuffer(VADriverContextP ctx,
     if (encoder_context->rate_control_mode == VA_RC_CQP)
         qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
     else
-        qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY;
+        qp = mfc_context->brc.qp_prime_y[slice_type];
 
     dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
     command_ptr = vme_context->vme_batchbuffer.bo->virtual;
-- 
1.9.1



More information about the Libva mailing list