diff options
author | Hamsalekha S <hamsalekha.s@ittiam.com> | 2023-09-28 17:56:00 +0530 |
---|---|---|
committer | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2023-09-28 07:24:09 -0700 |
commit | a24d3cf61f26d7c2f0a6e41830a463a2d781de1a (patch) | |
tree | 1364cb662e0a103df143d3bb73315ef20348f9b7 | |
parent | 4ea89ecf7bfc4f058cbba91733948f6a3573ba3e (diff) | |
download | libavc-a24d3cf61f26d7c2f0a6e41830a463a2d781de1a.tar.gz |
libavcenc: Fixed bug in the case of IDR frame being skipped.
When IDR frame is skipped due to VBV constraints, the frame
number should not be reset. Since it was reset earlier, it
was leading to bistream being not decodable in such a case.
Restore frame_num during idr skip.
-rw-r--r-- | encoder/ih264e_process.c | 6 | ||||
-rw-r--r-- | encoder/ih264e_rate_control.c | 3 | ||||
-rw-r--r-- | encoder/ih264e_structs.h | 5 | ||||
-rw-r--r-- | encoder/ih264e_utils.c | 2 |
4 files changed, 14 insertions, 2 deletions
diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c index 769e124..8f4fdb0 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 f7c2eda..4e7b4e9 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 4c3f63f..898387d 100644 --- a/encoder/ih264e_structs.h +++ b/encoder/ih264e_structs.h @@ -2254,6 +2254,11 @@ struct _codec_t WORD32 i4_frame_num; /** + * frame num backup (used in post enc skip case) + */ + WORD32 i4_restore_frame_num; + + /** * slice_type */ WORD32 i4_slice_type; diff --git a/encoder/ih264e_utils.c b/encoder/ih264e_utils.c index cb5eb25..5c9dc33 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; |