aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Mohan <ram.mohan@ittiam.com>2023-09-28 18:25:02 +0530
committerram-mohan <ram-mohan@users.noreply.github.com>2023-10-01 01:37:17 +0530
commitc68f552fce1f944c63191ab8202f36ce2e7f19eb (patch)
treeb40efb4c3ad05119c15f340a96bf67f017491a50
parent7429c172946719e61e76785a49849f3cec0bd646 (diff)
downloadlibavc-c68f552fce1f944c63191ab8202f36ce2e7f19eb.tar.gz
libavcenc: signal header bits consumed count accurately to rc
-rw-r--r--encoder/ih264e_process.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c
index 8f4fdb0..406f563 100644
--- a/encoder/ih264e_process.c
+++ b/encoder/ih264e_process.c
@@ -392,6 +392,9 @@ IH264E_ERROR_T ih264e_entropy(process_ctxt_t *ps_proc)
/* populate slice header */
ih264e_populate_slice_header(ps_proc, ps_slice_hdr, ps_pps, ps_sps);
+ /* Starting bitstream offset for header in bits */
+ bitstream_start_offset = GET_NUM_BITS(ps_bitstrm);
+
/* generate sei */
u4_insert_per_idr = (NAL_SLICE_IDR == ps_slice_hdr->i1_nal_unit_type);
@@ -451,6 +454,11 @@ IH264E_ERROR_T ih264e_entropy(process_ctxt_t *ps_proc)
RETURN_ENTROPY_IF_ERROR(ps_codec, ps_entropy, ctxt_sel);
ih264e_init_cabac_ctxt(ps_entropy);
}
+
+ /* Ending bitstream offset for header in bits */
+ bitstream_end_offset = GET_NUM_BITS(ps_bitstrm);
+ ps_entropy->u4_header_bits[i4_slice_type == PSLICE] +=
+ bitstream_end_offset - bitstream_start_offset;
}
/* begin entropy coding for the mb set */
@@ -608,12 +616,17 @@ IH264E_ERROR_T ih264e_entropy(process_ctxt_t *ps_proc)
&& ps_codec->s_cfg.e_slice_mode
!= IVE_SLICE_MODE_BLOCKS)
{
+ bitstream_start_offset = GET_NUM_BITS(ps_bitstrm);
ih264e_cabac_encode_terminate(ps_cabac_ctxt, 0);
+ bitstream_end_offset = GET_NUM_BITS(ps_bitstrm);
+ ps_entropy->u4_header_bits[i4_slice_type == PSLICE] +=
+ bitstream_end_offset - bitstream_start_offset;
}
}
if (ps_entropy->i4_eof)
{
+ bitstream_start_offset = GET_NUM_BITS(ps_bitstrm);
if (CAVLC == ps_entropy->u1_entropy_coding_mode_flag)
{
/* mb skip run */
@@ -635,6 +648,9 @@ IH264E_ERROR_T ih264e_entropy(process_ctxt_t *ps_proc)
{
ih264e_cabac_encode_terminate(ps_cabac_ctxt, 1);
}
+ bitstream_end_offset = GET_NUM_BITS(ps_bitstrm);
+ ps_entropy->u4_header_bits[i4_slice_type == PSLICE] +=
+ bitstream_end_offset - bitstream_start_offset;
DEBUG("entropy status %x", ps_entropy->i4_error_code);
}