[Libva] [Libva-intel-driver][PATCH 15/18] Use arrays to store BRC related parameters per temporal layer

Zhao Yakui yakui.zhao at intel.com
Wed Sep 7 05:36:54 UTC 2016


On 09/06/2016 11:46 PM, Xiang, Haihao wrote:
> Currently only the first element is used

This looks good to me.

Thanks
    Yakui
>
> Signed-off-by: Xiang, Haihao<haihao.xiang at intel.com>
> ---
>   src/gen6_mfc.c        |  8 +++----
>   src/gen6_mfc.h        |  6 ++---
>   src/gen6_mfc_common.c | 66 +++++++++++++++++++++++++--------------------------
>   src/gen6_vme.c        |  2 +-
>   src/gen75_mfc.c       |  4 ++--
>   src/gen75_vme.c       |  4 ++--
>   src/gen7_vme.c        |  2 +-
>   src/gen8_mfc.c        | 46 +++++++++++++++++------------------
>   src/gen8_vme.c        |  2 +-
>   src/gen9_vme.c        |  2 +-
>   10 files changed, 71 insertions(+), 71 deletions(-)
>
> diff --git a/src/gen6_mfc.c b/src/gen6_mfc.c
> index cf20e3b..969c726 100644
> --- a/src/gen6_mfc.c
> +++ b/src/gen6_mfc.c
> @@ -401,9 +401,9 @@ gen6_mfc_avc_slice_state(VADriverContextP ctx,
>       for (i = 0; i<  6; i++)
>           correct[i] = mfc_context->bit_rate_control_context[slice_type].Correct[i];
>
> -    grow = mfc_context->bit_rate_control_context[slice_type].GrowInit +
> +    grow = mfc_context->bit_rate_control_context[slice_type].GrowInit +
>           (mfc_context->bit_rate_control_context[slice_type].GrowResistance<<  4);
> -    shrink = mfc_context->bit_rate_control_context[slice_type].ShrinkInit +
> +    shrink = mfc_context->bit_rate_control_context[slice_type].ShrinkInit +
>           (mfc_context->bit_rate_control_context[slice_type].ShrinkResistance<<  4);
>
>       BEGIN_BCS_BATCH(batch, 11);;
> @@ -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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 a130c83..02591a3 100644
> --- a/src/gen6_mfc.h
> +++ b/src/gen6_mfc.h
> @@ -229,9 +229,9 @@ struct gen6_mfc_context
>       struct {
>           int mode;
>           int gop_nums[3];
> -        int target_frame_size[3]; // I,P,B
> -        int qp_prime_y[3];
> -        double bits_per_frame;
> +        int target_frame_size[MAX_TEMPORAL_LAYERS][3]; // I,P,B
> +        int qp_prime_y[MAX_TEMPORAL_LAYERS][3];
> +        double bits_per_frame[MAX_TEMPORAL_LAYERS];
>           double qpf_rounding_accumulator;
>
>           double saved_bps;
> diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
> index d388d44..5c10147 100644
> --- a/src/gen6_mfc_common.c
> +++ b/src/gen6_mfc_common.c
> @@ -108,19 +108,19 @@ static void intel_mfc_brc_init(struct encode_state *encode_state,
>       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.qp_prime_y[0][i] = 26;
>       }
>
> -    mfc_context->brc.target_frame_size[SLICE_TYPE_I] = (int)((double)((bitrate * intra_period)/framerate) /
> +    mfc_context->brc.target_frame_size[0][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];
> -    mfc_context->brc.target_frame_size[SLICE_TYPE_B] = BRC_BWEIGHT * mfc_context->brc.target_frame_size[SLICE_TYPE_I];
> +    mfc_context->brc.target_frame_size[0][SLICE_TYPE_P] = BRC_PWEIGHT * mfc_context->brc.target_frame_size[0][SLICE_TYPE_I];
> +    mfc_context->brc.target_frame_size[0][SLICE_TYPE_B] = BRC_BWEIGHT * mfc_context->brc.target_frame_size[0][SLICE_TYPE_I];
>
>       mfc_context->brc.gop_nums[SLICE_TYPE_I] = inum;
>       mfc_context->brc.gop_nums[SLICE_TYPE_P] = pnum;
>       mfc_context->brc.gop_nums[SLICE_TYPE_B] = bnum;
>
> -    bpf = mfc_context->brc.bits_per_frame = bitrate/framerate;
> +    bpf = mfc_context->brc.bits_per_frame[0] = bitrate/framerate;
>
>       mfc_context->hrd.buffer_size = encoder_context->brc.hrd_buffer_size;
>       mfc_context->hrd.current_buffer_fullness =
> @@ -131,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->brc.qp_prime_y[SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
> +        mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size);
>       }
>       else if (bpf>= qp1_size)
> -        mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 1;
> +        mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] = 1;
>       else if (bpf<= qp51_size)
> -        mfc_context->brc.qp_prime_y[SLICE_TYPE_P] = 51;
> +        mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] = 51;
>
> -    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];
> +    mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I] = mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P];
> +    mfc_context->brc.qp_prime_y[0][SLICE_TYPE_B] = mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I];
>
> -    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);
> +    BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I], 1, 51);
> +    BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P], 1, 51);
> +    BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_B], 1, 51);
>   }
>
>   int intel_mfc_update_hrd(struct encode_state *encode_state,
> @@ -160,7 +160,7 @@ int intel_mfc_update_hrd(struct encode_state *encode_state,
>           return BRC_UNDERFLOW;
>       }
>
> -    mfc_context->hrd.current_buffer_fullness += mfc_context->brc.bits_per_frame;
> +    mfc_context->hrd.current_buffer_fullness += mfc_context->brc.bits_per_frame[0];
>       if (mfc_context->hrd.buffer_size>  0&&  mfc_context->hrd.current_buffer_fullness>  mfc_context->hrd.buffer_size) {
>           if (mfc_context->brc.mode == VA_RC_VBR)
>               mfc_context->hrd.current_buffer_fullness = mfc_context->hrd.buffer_size;
> @@ -180,9 +180,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->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 qpi = mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I];
> +    int qpp = mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P];
> +    int qpb = mfc_context->brc.qp_prime_y[0][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
> @@ -195,9 +195,9 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
>       double x, y;
>       double frame_size_alpha;
>
> -    qp = mfc_context->brc.qp_prime_y[slicetype];
> +    qp = mfc_context->brc.qp_prime_y[0][slicetype];
>
> -    target_frame_size = mfc_context->brc.target_frame_size[slicetype];
> +    target_frame_size = mfc_context->brc.target_frame_size[0][slicetype];
>       if (mfc_context->hrd.buffer_capacity<  5)
>           frame_size_alpha = 0;
>       else
> @@ -257,23 +257,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->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_P_B_QP_DIFF - qpb)>>  1;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_B] += (qpn + BRC_P_B_QP_DIFF - qpb)>>  1;
>               if (abs(qpn - BRC_I_P_QP_DIFF - qpi)>  2)
> -                mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi)>>  1;
> +                mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[SLICE_TYPE_B] += (qpn + BRC_I_B_QP_DIFF - qpb)>>  2;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_B] += (qpn + BRC_I_B_QP_DIFF - qpb)>>  2;
>               if (abs(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;
> +                mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[SLICE_TYPE_P] += (qpn - BRC_P_B_QP_DIFF - qpp)>>  1;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] += (qpn - BRC_P_B_QP_DIFF - qpp)>>  1;
>               if (abs(qpn - BRC_I_B_QP_DIFF - qpi)>  4)
> -                mfc_context->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_B_QP_DIFF - qpi)>>  2;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I] += (qpn - BRC_I_B_QP_DIFF - qpi)>>  2;
>           }
> -        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);
> +        BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I], 1, 51);
> +        BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P], 1, 51);
> +        BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_B], 1, 51);
>       } else if (sts == BRC_UNDERFLOW) { // underflow
>           if (qpn<= qp) qpn = qp + 1;
>           if (qpn>  51) {
> @@ -288,7 +288,7 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
>           }
>       }
>
> -    mfc_context->brc.qp_prime_y[slicetype] = qpn;
> +    mfc_context->brc.qp_prime_y[0][slicetype] = qpn;
>
>       return sts;
>   }
> @@ -807,7 +807,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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][slice_type];
>
>       if (vme_state_message == NULL)
>           return;
> @@ -836,7 +836,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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][slice_type];
>
>       lambda = intel_lambda_qp(qp * QP_MAX / VP8_QP_MAX);
>
> @@ -965,7 +965,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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][slice_type];
>
>   #define		USE_SCOREBOARD		(1<<  21)
>
> @@ -1918,7 +1918,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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 183f087..fb04749 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->brc.qp_prime_y[SLICE_TYPE_I]];
> +        vme_state_message[16] = intra_mb_mode_cost_table[mfc_context->brc.qp_prime_y[0][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 c42de38..2d6baa6 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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 fd6363d..9223f68 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->brc.qp_prime_y[SLICE_TYPE_I]];
> +        vme_state_message[0] = intra_mb_mode_cost_table[mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 3073cd4..7530d19 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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 9da0730..ef553fb 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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][slice_type];
>           if (encode_state->slice_header_index[slice_index] == 0) {
>               pSliceParameter->slice_qp_delta = qp - pPicParameter->pic_init_qp;
>               qp_slice = qp;
> @@ -3340,23 +3340,23 @@ static void gen8_mfc_vp8_brc_init(struct encode_state *encode_state,
>
>       mfc_context->brc.mode = encoder_context->rate_control_mode;
>
> -    mfc_context->brc.target_frame_size[SLICE_TYPE_I] = (int)((double)((bitrate * intra_period)/frame_rate) /
> +    mfc_context->brc.target_frame_size[0][SLICE_TYPE_I] = (int)((double)((bitrate * intra_period)/frame_rate) /
>                                                                (double)(inum + BRC_PWEIGHT * pnum ));
> -    mfc_context->brc.target_frame_size[SLICE_TYPE_P] = BRC_PWEIGHT * mfc_context->brc.target_frame_size[SLICE_TYPE_I];
> +    mfc_context->brc.target_frame_size[0][SLICE_TYPE_P] = BRC_PWEIGHT * mfc_context->brc.target_frame_size[0][SLICE_TYPE_I];
>
>       mfc_context->brc.gop_nums[SLICE_TYPE_I] = inum;
>       mfc_context->brc.gop_nums[SLICE_TYPE_P] = pnum;
>
> -    mfc_context->brc.bits_per_frame = bitrate/frame_rate;
> +    mfc_context->brc.bits_per_frame[0] = bitrate/frame_rate;
>
> -    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->brc.qp_prime_y[0][SLICE_TYPE_I] = gen8_mfc_vp8_qindex_estimate(encode_state,
> +                                                                                mfc_context,
> +                                                                                mfc_context->brc.target_frame_size[0][SLICE_TYPE_I],
> +                                                                                1);
> +    mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] = gen8_mfc_vp8_qindex_estimate(encode_state,
> +                                                                                mfc_context,
> +                                                                                mfc_context->brc.target_frame_size[0][SLICE_TYPE_P],
> +                                                                                0);
>
>       mfc_context->hrd.buffer_size = (double)param_hrd->buffer_size;
>       mfc_context->hrd.current_buffer_fullness =
> @@ -3376,8 +3376,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->brc.qp_prime_y[SLICE_TYPE_I];
> -    int qpp = mfc_context->brc.qp_prime_y[SLICE_TYPE_P];
> +    int qpi = mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I];
> +    int qpp = mfc_context->brc.qp_prime_y[0][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
> @@ -3392,9 +3392,9 @@ 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->brc.qp_prime_y[slicetype];
> +    qp = mfc_context->brc.qp_prime_y[0][slicetype];
>
> -    target_frame_size = mfc_context->brc.target_frame_size[slicetype];
> +    target_frame_size = mfc_context->brc.target_frame_size[0][slicetype];
>       if (mfc_context->hrd.buffer_capacity<  5)
>           frame_size_alpha = 0;
>       else
> @@ -3455,13 +3455,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->brc.qp_prime_y[SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi)>>  2;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I] += (qpn - BRC_I_P_QP_DIFF - qpi)>>  2;
>           } else {
>               if (abs(qpn + BRC_I_P_QP_DIFF - qpp)>  4)
> -                mfc_context->brc.qp_prime_y[SLICE_TYPE_P] += (qpn + BRC_I_P_QP_DIFF - qpp)>>  2;
> +                mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P] += (qpn + BRC_I_P_QP_DIFF - qpp)>>  2;
>           }
> -        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);
> +        BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_I], min_qindex, max_qindex);
> +        BRC_CLIP(mfc_context->brc.qp_prime_y[0][SLICE_TYPE_P], min_qindex, max_qindex);
>       } else if (sts == BRC_UNDERFLOW) { // underflow
>           if (qpn<= qp) qpn = qp + 2;
>           if (qpn>  max_qindex) {
> @@ -3476,7 +3476,7 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
>           }
>       }
>
> -    mfc_context->brc.qp_prime_y[slicetype] = qpn;
> +    mfc_context->brc.qp_prime_y[0][slicetype] = qpn;
>
>       return sts;
>   }
> @@ -3672,7 +3672,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->brc.qp_prime_y[slice_type];
> +        q_matrix->quantization_index[0] = mfc_context->brc.qp_prime_y[0][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 8c717b2..5ad0243 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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][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 fa59a52..e80467d 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->brc.qp_prime_y[slice_type];
> +        qp = mfc_context->brc.qp_prime_y[0][slice_type];
>
>       dri_bo_map(vme_context->vme_batchbuffer.bo, 1);
>       command_ptr = vme_context->vme_batchbuffer.bo->virtual;



More information about the Libva mailing list