[Libva] [PATCH] VP8 HWEnc: Fix CBR qp setting for vme cost

Zhao, Yakui yakui.zhao at intel.com
Thu May 21 23:10:58 PDT 2015


On Fri, 2015-05-22 at 00:06 -0600, Zhong Li wrote:
> 1. The q_index range of vp8 is different from h264, it's need to be
> mapped to avc qp range.
> 2. For CBR case, qp should be set to CBR calculated value.
> 
> Signed-off-by: Zhong Li <zhong.li at intel.com>

Good catch. This looks good to me.

Thanks.
    Yakui
> ---
>  src/gen6_mfc_common.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
> index 9c1d294..275fa13 100644
> --- a/src/gen6_mfc_common.c
> +++ b/src/gen6_mfc_common.c
> @@ -793,6 +793,7 @@ int intel_format_lutvalue(int value, int max)
>  
> 
>  #define		QP_MAX			52
> +#define		VP8_QP_MAX	        128
>  
> 
>  static float intel_lambda_qp(int qp)
> @@ -932,11 +933,17 @@ void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx,
>      float   lambda, m_costf;
>  
>      int is_key_frame = !pic_param->pic_flags.bits.frame_type;
> +    int slice_type = (is_key_frame ? SLICE_TYPE_I : SLICE_TYPE_P);
>    
>      if (vme_state_message == NULL)
>  	return;
>   
> -    lambda = intel_lambda_qp(q_matrix->quantization_index[0] >> 1);
> +    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;
> +
> +    lambda = intel_lambda_qp(qp * QP_MAX / VP8_QP_MAX);
>      if (is_key_frame) {
>  	vme_state_message[MODE_INTRA_16X16] = 0;
>  	m_cost = lambda * 16; 
> @@ -957,7 +964,7 @@ void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx,
>              mv_count++;
>  	}
>  
> -	if (q_matrix->quantization_index[0] < 32 ) {
> +	if (qp < 32 ) {
>              vme_state_message[MODE_INTRA_16X16] = 0x4a;
>              vme_state_message[MODE_INTRA_4X4] = 0x4a;
>              vme_state_message[MODE_INTRA_NONPRED] = 0x4a;




More information about the Libva mailing list