Skip to content

Commit

Permalink
libavcenc: increment picture count only on valid inputs
Browse files Browse the repository at this point in the history
If the encoder receives inputs that are empty or frames
that have to be skipped due to frame rate pull down,
do not increment picture count.

Bug: oss-fuzz-62827
Test: ./avc-enc-fuzzer
  • Loading branch information
ram-mohan authored and harishdm committed Oct 3, 2023
1 parent 56a598c commit e4574d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion encoder/ih264e_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op)
}

/* curr pic cnt */
ps_codec->i4_pic_cnt += 1;
ps_codec->i4_pic_cnt += 1;

i4_rc_pre_enc_skip = 0;
i4_rc_pre_enc_skip = ih264e_input_queue_update(
Expand Down
5 changes: 3 additions & 2 deletions encoder/ih264e_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ WORD32 ih264e_input_queue_update(codec_t *ps_codec,
{
ps_enc_buff->s_raw_buf.apv_bufs[0] = NULL;
ps_enc_buff->u4_is_last = ps_ive_ip->u4_is_last;
ps_codec->i4_pic_cnt -= 1;
return 0;
}

Expand All @@ -237,6 +238,7 @@ WORD32 ih264e_input_queue_update(codec_t *ps_codec,
if (skip_src)
{
ps_enc_buff->u4_is_last = ps_ive_ip->u4_is_last;
ps_codec->i4_pic_cnt -= 1;
return 1;
}
}
Expand Down Expand Up @@ -297,8 +299,7 @@ WORD32 ih264e_input_queue_update(codec_t *ps_codec,


/* Delay */
if (ps_codec->i4_encode_api_call_cnt
< (WORD32)(ps_codec->s_cfg.u4_num_bframes))
if (ps_codec->i4_pic_cnt < (WORD32)(ps_codec->s_cfg.u4_num_bframes))
{
ps_enc_buff->s_raw_buf.apv_bufs[0] = NULL;
ps_enc_buff->u4_is_last = 0;
Expand Down

0 comments on commit e4574d3

Please sign in to comment.