diff --git a/encoder/ih264e_globals.c b/encoder/ih264e_globals.c index 2639273d..fdc6837c 100644 --- a/encoder/ih264e_globals.c +++ b/encoder/ih264e_globals.c @@ -62,7 +62,7 @@ * (from rate distortion optimization for video compression by sullivan). ****************************************************************************** */ -const UWORD16 gu2_qp_lambda[52]= +const UWORD8 gu1_qp_lambdaIP[52]= { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -73,6 +73,26 @@ const UWORD16 gu2_qp_lambda[52]= 59, 66, 74, 83, }; +/** +****************************************************************************** +* @brief lambda for varying quantizer scales that would be used to +* compute the RD cost while deciding on the MB modes. +* input : qp +* output : lambda +* @remarks lambda = max(2, min(4, pow(2, (qp - 12)/6))) * gu1_qp_lambdaIP[] +****************************************************************************** +*/ +const UWORD8 gu1_qp_lambdaB[52]= +{ + 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 3, 3, 3, 4, 4, 5, + 5, 6, 7, 8, 10, 11, 13, 15, + 17, 20, 22, 26, 30, 33, 37, 42, + 47, 53, 59, 66, 74, 83, 94, 105, + 118, 132, 149, 167, +}; + /** ****************************************************************************** * @brief Lamda for varying quantizer scales that would be used to diff --git a/encoder/ih264e_globals.h b/encoder/ih264e_globals.h index 5ce1dc88..3c9ea1f7 100644 --- a/encoder/ih264e_globals.h +++ b/encoder/ih264e_globals.h @@ -43,7 +43,8 @@ /* Global Declarations */ /*****************************************************************************/ -extern const UWORD16 gu2_qp_lambda[52]; +extern const UWORD8 gu1_qp_lambdaIP[52]; +extern const UWORD8 gu1_qp_lambdaB[52]; extern const UWORD8 gu1_qp0[52]; extern const UWORD8 u1_uev_codelength[32]; extern const UWORD8 gu1_coeff_cost[6]; diff --git a/encoder/ih264e_me.c b/encoder/ih264e_me.c index f4822191..7b1d5f3e 100644 --- a/encoder/ih264e_me.c +++ b/encoder/ih264e_me.c @@ -825,9 +825,14 @@ void ih264e_init_me(process_ctxt_t *ps_proc) ps_me_ctxt->apu1_ref_buf_luma[0] = ps_proc->apu1_ref_buf_luma[0]; ps_me_ctxt->apu1_ref_buf_luma[1] = ps_proc->apu1_ref_buf_luma[1]; - ps_me_ctxt->u4_lambda_motion = gu1_qp0[ps_me_ctxt->u1_mb_qp]; - - + if (ps_codec->pic_type == PIC_B) + { + ps_me_ctxt->u4_lambda_motion = gu1_qp_lambdaB[ps_me_ctxt->u1_mb_qp]; + } + else + { + ps_me_ctxt->u4_lambda_motion = gu1_qp_lambdaIP[ps_me_ctxt->u1_mb_qp]; + } } diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c index d3212c06..5e55a143 100644 --- a/encoder/ih264e_process.c +++ b/encoder/ih264e_process.c @@ -1458,7 +1458,14 @@ IH264E_ERROR_T ih264e_init_proc_ctxt(process_ctxt_t *ps_proc) ps_proc->u4_mb_type = I16x16; /* lambda */ - ps_proc->u4_lambda = gu1_qp0[ps_qp_params->u1_mb_qp]; + if (ps_codec->pic_type == PIC_B) + { + ps_proc->u4_lambda = gu1_qp_lambdaB[ps_qp_params->u1_mb_qp]; + } + else + { + ps_proc->u4_lambda = gu1_qp_lambdaIP[ps_qp_params->u1_mb_qp]; + } /* mb distortion */ ps_proc->i4_mb_distortion = SHRT_MAX;