diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c index c4c6050f..ab7f8c3f 100644 --- a/encoder/ih264e_api.c +++ b/encoder/ih264e_api.c @@ -1613,6 +1613,16 @@ static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, return IV_FAIL; } + if((ps_ip->s_ive_ip.u4_idr_frm_interval > ps_ip->s_ive_ip.u4_i_frm_interval) && + (ps_ip->s_ive_ip.u4_idr_frm_interval % ps_ip->s_ive_ip.u4_i_frm_interval != 0)) + { + ps_op->s_ive_op.u4_error_code |= 1 + << IVE_UNSUPPORTEDPARAM; + ps_op->s_ive_op.u4_error_code |= + IH264E_INVALID_INTRA_FRAME_INTERVAL; + return IV_FAIL; + } + break; } @@ -2301,7 +2311,8 @@ static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, return IV_FAIL; } - if (ps_ip->s_ive_ip.u4_air_refresh_period == 0) + if (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_NONE && + ps_ip->s_ive_ip.u4_air_refresh_period == 0) { ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; @@ -3328,7 +3339,7 @@ static WORD32 ih264e_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op) max_mb_cnt = max_mb_rows * max_mb_cols; /* profile / level info */ - level = ih264e_get_min_level(max_ht_luma, max_wd_luma); + level = ih264e_get_min_level(max_wd_luma, max_ht_luma); /* validate params */ if ((level < MIN_LEVEL) || (level > MAX_LEVEL)) @@ -5756,6 +5767,9 @@ static IV_STATUS_T ih264_set_gop_params(void *pv_api_ip, ps_cfg->u4_i_frm_interval = ps_ip->s_ive_ip.u4_i_frm_interval; ps_cfg->u4_idr_frm_interval = ps_ip->s_ive_ip.u4_idr_frm_interval; + if(ps_cfg->u4_idr_frm_interval < ps_cfg->u4_i_frm_interval) + ps_cfg->u4_i_frm_interval = ps_cfg->u4_idr_frm_interval; + ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c index 769e124d..8f4fdb02 100644 --- a/encoder/ih264e_process.c +++ b/encoder/ih264e_process.c @@ -2472,6 +2472,12 @@ WORD32 ih264e_update_rc_post_enc(codec_t *ps_codec, WORD32 ctxt_sel, WORD32 i4_i if (ps_codec->s_rate_control.post_encode_skip[ctxt_sel]) { ps_entropy->ps_bitstrm->u4_strm_buf_offset = 0; + // If an IDR frame was skipped, restore frame num and IDR pic id + if (ps_codec->u4_is_idr == 1) + { + ps_codec->i4_frame_num = ps_codec->i4_restore_frame_num; + ps_codec->i4_idr_pic_id--; + } } else if (i4_stuffing_byte) { diff --git a/encoder/ih264e_rate_control.c b/encoder/ih264e_rate_control.c index f7c2edaa..4e7b4e92 100644 --- a/encoder/ih264e_rate_control.c +++ b/encoder/ih264e_rate_control.c @@ -596,8 +596,7 @@ WORD32 ih264e_rc_post_enc(void * ps_rate_control_api, pi4_is_post_encode_skip[0]= 0; /* For NLDRC, get the buffer status for stuffing or skipping */ - /* Default NLDRC to CBR with no frame drops. */ - /* FIX ME: In frame drop mode, the bitstream generated is non-compliant */ + /* Default NLDRC to CBR with no frame drops so the '0 &&'. */ if (0 && irc_get_rc_type(ps_rate_control_api) == CBR_NLDRC) { WORD32 i4_get_num_bit_to_prevent_vbv_overflow; diff --git a/encoder/ih264e_structs.h b/encoder/ih264e_structs.h index 4c3f63f9..898387d4 100644 --- a/encoder/ih264e_structs.h +++ b/encoder/ih264e_structs.h @@ -2253,6 +2253,11 @@ struct _codec_t */ WORD32 i4_frame_num; + /** + * frame num backup (used in post enc skip case) + */ + WORD32 i4_restore_frame_num; + /** * slice_type */ diff --git a/encoder/ih264e_utils.c b/encoder/ih264e_utils.c index cb5eb25c..5c9dc33e 100644 --- a/encoder/ih264e_utils.c +++ b/encoder/ih264e_utils.c @@ -1489,6 +1489,8 @@ IH264E_ERROR_T ih264e_pic_init(codec_t *ps_codec, inp_buf_t *ps_inp_buf) /* set idr flag */ ps_codec->u4_is_idr = 1; + ps_codec->i4_restore_frame_num = ps_codec->i4_frame_num; + /* reset frame num */ ps_codec->i4_frame_num = 0; diff --git a/examples/avcenc/input.c b/examples/avcenc/input.c index 77b10902..bf92d567 100644 --- a/examples/avcenc/input.c +++ b/examples/avcenc/input.c @@ -245,7 +245,7 @@ void allocate_input(app_ctxt_t *ps_app_ctxt) /* Size of buffer */ luma_size = ps_app_ctxt->u4_wd * ps_app_ctxt->u4_ht; chroma_size = luma_size >> 1; - pic_size = luma_size + chroma_size; + pic_size = luma_size + chroma_size * 2; num_mbs = ALIGN16(ps_app_ctxt->u4_max_wd) * ALIGN16(ps_app_ctxt->u4_max_ht); num_mbs /= 256;