Skip to content

Commit

Permalink
libavcenc: relocate the update post enc routines
Browse files Browse the repository at this point in the history
During bitstream overflow errors, it is possible that update post
enc gets skipped as last row might never have to be entropy coded
as we have already consumed the buffer. This can be fatal for
encoding further frames. Move this update to a location where it
is guaranteed to be updated
  • Loading branch information
ram-mohan committed Sep 27, 2023
1 parent ff394df commit c95744a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 6 additions & 0 deletions encoder/ih264e_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op)

ih264_list_reset(ps_codec->pv_entropy_jobq);

error_status = ih264e_update_rc_post_enc(ps_codec, ctxt_sel, (ps_codec->i4_poc == 0));
SET_ERROR_ON_RETURN(error_status,
((error_status == IH264E_BITSTREAM_BUFFER_OVERFLOW) ?
IVE_UNSUPPORTEDPARAM : IVE_FATALERROR),
ps_video_encode_op->s_ive_op.u4_error_code, IV_FAIL);

if (ps_codec->s_cfg.u4_enable_quality_metrics & QUALITY_MASK_PSNR)
{
ih264e_compute_quality_stats(ps_proc);
Expand Down
6 changes: 0 additions & 6 deletions encoder/ih264e_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -2621,12 +2621,6 @@ WORD32 ih264e_process_thread(void *pv_proc)
/* entropy code all mbs enlisted under the current job */
error_status = ih264e_entropy(ps_proc);

if (s_job.i2_mb_y == ps_proc->i4_ht_mbs - 1)
{
error_status |= ih264e_update_rc_post_enc(ps_codec, ctxt_sel,
(ps_codec->i4_poc == 0));
}

/* Dont execute any further instructions until store synchronization took place */
DATA_SYNC();

Expand Down

0 comments on commit c95744a

Please sign in to comment.