diff --git a/encoder/ih264e_cabac_encode.c b/encoder/ih264e_cabac_encode.c index e49ab58c..d17e5fb5 100644 --- a/encoder/ih264e_cabac_encode.c +++ b/encoder/ih264e_cabac_encode.c @@ -598,8 +598,8 @@ static void ih264e_cabac_enc_mb_qp_delta(WORD8 i1_mb_qp_delta, u4_bins = 0; i1_bins_len = 1; /* calculate ctxtInc, depending on neighbour availability */ - u1_ctxt_inc = (!(!(ps_cabac_ctxt->i1_prevps_mb_qp_delta_ctxt))); - ps_cabac_ctxt->i1_prevps_mb_qp_delta_ctxt = i1_mb_qp_delta; + u1_ctxt_inc = (!(!(ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt))); + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = i1_mb_qp_delta; if (u1_code_num == 0) { @@ -1721,6 +1721,7 @@ IH264E_ERROR_T ih264e_write_islice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt) *(ps_cabac_ctxt->pu1_left_uv_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_y_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_yuv_dc_csbp) = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; /* Ending bitstream offset for header in bits */ bitstream_end_offset = GET_NUM_BITS(ps_bitstream); ps_ent_ctxt->u4_header_bits[0] += bitstream_end_offset @@ -1887,6 +1888,7 @@ IH264E_ERROR_T ih264e_write_pslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt) *(ps_cabac_ctxt->pu1_left_uv_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_y_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_yuv_dc_csbp) = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; /* Ending bitstream offset for header in bits */ bitstream_end_offset = GET_NUM_BITS(ps_bitstream); ps_ent_ctxt->u4_header_bits[0] += bitstream_end_offset @@ -2002,6 +2004,7 @@ IH264E_ERROR_T ih264e_write_pslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt) *(ps_cabac_ctxt->pu1_left_uv_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_y_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_yuv_dc_csbp) = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; } ps_curr_ctxt->u1_intrapred_chroma_mode = 0; ps_curr_ctxt->u1_cbp = cbp; @@ -2195,6 +2198,7 @@ IH264E_ERROR_T ih264e_write_bslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt) *(ps_cabac_ctxt->pu1_left_uv_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_y_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_yuv_dc_csbp) = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; /* Ending bitstream offset for header in bits */ bitstream_end_offset = GET_NUM_BITS(ps_bitstream); ps_ent_ctxt->u4_header_bits[0] += bitstream_end_offset @@ -2390,6 +2394,7 @@ IH264E_ERROR_T ih264e_write_bslice_mb_cabac(entropy_ctxt_t *ps_ent_ctxt) *(ps_cabac_ctxt->pu1_left_uv_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_y_ac_csbp) = 0; *(ps_cabac_ctxt->pu1_left_yuv_dc_csbp) = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; } ps_curr_ctxt->u1_intrapred_chroma_mode = 0; ps_curr_ctxt->u1_cbp = cbp; diff --git a/encoder/ih264e_cabac_init.c b/encoder/ih264e_cabac_init.c index 7407dccc..77c768db 100644 --- a/encoder/ih264e_cabac_init.c +++ b/encoder/ih264e_cabac_init.c @@ -203,7 +203,7 @@ void ih264e_init_cabac_ctxt(entropy_ctxt_t *ps_ent_ctxt) ih264e_init_cabac_enc_envirnoment(&ps_cabac_ctxt->s_cab_enc_env); - ps_cabac_ctxt->i1_prevps_mb_qp_delta_ctxt = 0; + ps_cabac_ctxt->i1_prev_mb_qp_delta_ctxt = 0; if (ISLICE != u1_slice_type) { diff --git a/encoder/ih264e_cabac_structs.h b/encoder/ih264e_cabac_structs.h index 82938ca8..382500cb 100644 --- a/encoder/ih264e_cabac_structs.h +++ b/encoder/ih264e_cabac_structs.h @@ -179,8 +179,8 @@ typedef struct /* These things need to be updated at each MbLevel */ - /* Prev ps_mb_qp_delta_ctxt */ - WORD8 i1_prevps_mb_qp_delta_ctxt; + /* prev mb qp delta ctxt */ + WORD8 i1_prev_mb_qp_delta_ctxt; /* Pointer to mb_info_ctxt_t map */ mb_info_ctxt_t *ps_mb_map_ctxt_inc; diff --git a/encoder/irc_rate_control_api.c b/encoder/irc_rate_control_api.c index 4a646451..b641aa14 100644 --- a/encoder/irc_rate_control_api.c +++ b/encoder/irc_rate_control_api.c @@ -163,7 +163,9 @@ void irc_initialise_rate_control(rate_control_api_t *ps_rate_control_api, UWORD32 u4_tgt_ticks) { WORD32 i; - UWORD32 u4_frms_in_delay_prd = (u4_frame_rate * u4_max_delay) / 1000000; + UWORD32 u4_frms_in_delay_prd; + + X_PROD_Y_DIV_Z(u4_frame_rate, u4_max_delay, 1000000, u4_frms_in_delay_prd); ps_rate_control_api->e_rc_type = e_rate_control_type; ps_rate_control_api->u1_is_mb_level_rc_on = u1_is_mb_level_rc_on; @@ -307,8 +309,8 @@ void irc_initialise_rate_control(rate_control_api_t *ps_rate_control_api, /* Initialize the mb level rate control module */ irc_init_mb_level_rc(ps_rate_control_api->ps_mb_rate_control); - ps_rate_control_api->i4_prev_frm_est_bits = u4_avg_bit_rate * 1000 - / u4_frame_rate; + X_PROD_Y_DIV_Z(u4_avg_bit_rate, 1000, u4_frame_rate, + ps_rate_control_api->i4_prev_frm_est_bits); ps_rate_control_api->prev_ref_pic_type = I_PIC; }