Keep track of total number of bits coded.

Adds total_bits_coded into encoder_state_config_global_t. The count is
updated whenever a frame is written.
This commit is contained in:
Arttu Ylä-Outinen 2015-04-17 17:31:22 +03:00
parent 815a2bea55
commit 5b8cd76f01
3 changed files with 11 additions and 3 deletions

View file

@ -738,7 +738,7 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state) {
uint64_t newpos;
int i;
curpos = bitstream_tell(stream) >> 3;
curpos = bitstream_tell(stream);
// The first NAL unit of the access unit must use a long start code.
bool first_nal_in_au = true;
@ -803,8 +803,12 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state) {
assert(state->tile->frame->poc == state->global->poc);
//Get bitstream length for stats
newpos = bitstream_tell(stream) >> 3;
state->stats_bitstream_length = newpos - curpos;
newpos = bitstream_tell(stream);
state->stats_bitstream_length = (newpos >> 3) - (curpos >> 3);
if (state->global->frame > 0) {
state->global->total_bits_coded = state->previous_encoder_state->global->total_bits_coded;
}
state->global->total_bits_coded += newpos - curpos;
// Flush the output in case someone is reading the file on the other end.
fflush(state->stream.file.output);

View file

@ -34,6 +34,7 @@ static int encoder_state_config_global_init(encoder_state_t * const state) {
state->global->ref_list = REF_PIC_LIST_0;
state->global->frame = 0;
state->global->poc = 0;
state->global->total_bits_coded = 0;
return 1;
}

View file

@ -82,6 +82,9 @@ typedef struct {
bool is_idr_frame;
uint8_t pictype;
uint8_t slicetype;
//! Total number of bits written.
uint64_t total_bits_coded;
} encoder_state_config_global_t;