aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Mohan <ram.mohan@ittiam.com>2020-09-18 02:54:10 +0530
committerWonsik Kim <wonsik@google.com>2020-10-30 21:58:54 +0000
commitf5ec0d4287f61b578a700ff70beb3700b96ab827 (patch)
treed2fd547c7a591033008356cce687d9dca643cfaa
parent3cacdbc078fc3269f2273a45220f3d127e0d87e9 (diff)
downloadlibhevc-f5ec0d4287f61b578a700ff70beb3700b96ab827.tar.gz
libhevcenc: fix bitrate overshoot when lookahead is disabled
When rc lookahead is disabled, next frame encode context becomes NULL. This context is used to signal end of gop. As this is NULL rc does not know the end of gop causing over consumption of bits. Rely on intraframe interval to resolve this. Also, as there is no scene change detection, default all pics to single scene. Bug: 140313463 Bug: 168628473 Bug: 166085628 Test: atest android.media.cts.VideoCodecTest Merged-In: I6dcf9fb52d3aa18935e0b8d9ec9c193b15d30668 Change-Id: I6dcf9fb52d3aa18935e0b8d9ec9c193b15d30668
-rw-r--r--encoder/ihevce_lap_interface.c2
-rw-r--r--encoder/ihevce_rc_interface.c23
2 files changed, 15 insertions, 10 deletions
diff --git a/encoder/ihevce_lap_interface.c b/encoder/ihevce_lap_interface.c
index 4ace17a..9112e1d 100644
--- a/encoder/ihevce_lap_interface.c
+++ b/encoder/ihevce_lap_interface.c
@@ -1710,7 +1710,7 @@ void ihevce_pre_rel_lapout_update(lap_struct_t *ps_lap_struct, ihevce_lap_enc_bu
}
ps_lap_struct->pv_prev_inp_buf = (void *)ps_lap_out_buf;
- ps_lap_out_buf->s_lap_out.i4_is_prev_pic_in_Tid0_same_scene = 0;
+ ps_lap_out_buf->s_lap_out.i4_is_prev_pic_in_Tid0_same_scene = 1;
/*with force idr below check is not valid*/
#if(!FORCE_IDR_TEST)
diff --git a/encoder/ihevce_rc_interface.c b/encoder/ihevce_rc_interface.c
index 17ffa78..b0cee1b 100644
--- a/encoder/ihevce_rc_interface.c
+++ b/encoder/ihevce_rc_interface.c
@@ -4929,13 +4929,11 @@ void ihevce_rc_store_retrive_update_info(
&ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc],
ps_rc_lap_out,
sizeof(rc_lap_out_params_t));
- //BUG_FIX related to the releasing of the next lap out buffers and retrieving of the data for the delayed update.
{
- rc_lap_out_params_t *ps_rc_lap_out_next_encode;
- ps_rc_lap_out_next_encode =
- (rc_lap_out_params_t *)((rc_lap_out_params_t *)ps_rc_lap_out)
- ->ps_rc_lap_out_next_encode;
+ rc_lap_out_params_t *ps_rc_lap_out_curr = (rc_lap_out_params_t *)ps_rc_lap_out;
+ rc_lap_out_params_t *ps_rc_lap_out_next_encode =
+ (rc_lap_out_params_t *)ps_rc_lap_out_curr->ps_rc_lap_out_next_encode;
if(NULL != ps_rc_lap_out_next_encode)
{
@@ -4946,12 +4944,19 @@ void ihevce_rc_store_retrive_update_info(
}
else
{
- ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].i4_next_pic_type = -1;
+ if(ps_rc_lap_out_curr->i4_rc_display_num &&
+ (ps_rc_lap_out_curr->i4_rc_display_num %
+ (ps_rc_ctxt->u4_intra_frame_interval - 1)) == 0)
+ {
+ ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].i4_next_pic_type = IV_I_FRAME;
+ }
+ else
+ {
+ ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].i4_next_pic_type = -1;
+ }
ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].i4_next_scene_type = -1;
}
-
- ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].ps_rc_lap_out_next_encode =
- NULL; //RC_BUG_FIX
+ ps_rc_ctxt->as_rc_lap_out[i4_enc_frm_id_rc].ps_rc_lap_out_next_encode = NULL;
}
}
else if(2 == i4_store_retrive)