mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 18:34:06 +00:00
Merge branch 'stats_and_framecount_fixes' of https://github.com/lfasnacht/kvazaar
This commit is contained in:
commit
86fa7312c9
|
@ -355,6 +355,13 @@ int main(int argc, char *argv[])
|
||||||
//Clear encoder
|
//Clear encoder
|
||||||
encoder_next_frame(&encoder_states[current_encoder_state]);
|
encoder_next_frame(&encoder_states[current_encoder_state]);
|
||||||
|
|
||||||
|
//Abort if enough frames
|
||||||
|
if (cfg->frames && encoder_states[current_encoder_state].global->frame >= cfg->frames) {
|
||||||
|
//Ignore this frame, which is not valid...
|
||||||
|
encoder_states[current_encoder_state].stats_done = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
CHECKPOINT_MARK("read source frame: %d", encoder_states[current_encoder_state].global->frame + cfg->seek);
|
CHECKPOINT_MARK("read source frame: %d", encoder_states[current_encoder_state].global->frame + cfg->seek);
|
||||||
|
|
||||||
// Read one frame from the input
|
// Read one frame from the input
|
||||||
|
|
|
@ -675,9 +675,19 @@ static void add_checksum(encoder_state * const encoder_state)
|
||||||
static void encoder_state_write_bitstream_main(encoder_state * const main_state) {
|
static void encoder_state_write_bitstream_main(encoder_state * const main_state) {
|
||||||
const encoder_control * const encoder = main_state->encoder_control;
|
const encoder_control * const encoder = main_state->encoder_control;
|
||||||
bitstream * const stream = &main_state->stream;
|
bitstream * const stream = &main_state->stream;
|
||||||
|
uint64_t curpos;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (main_state->stream.base.type == BITSTREAM_TYPE_FILE) {
|
||||||
|
fgetpos(main_state->stream.file.output,(fpos_t*)&curpos);
|
||||||
|
} else if (main_state->stream.base.type == BITSTREAM_TYPE_MEMORY) {
|
||||||
|
curpos = stream->mem.output_length;
|
||||||
|
} else {
|
||||||
|
//Should not happen
|
||||||
|
assert(0);
|
||||||
|
curpos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (main_state->global->is_radl_frame) {
|
if (main_state->global->is_radl_frame) {
|
||||||
// Access Unit Delimiter (AUD)
|
// Access Unit Delimiter (AUD)
|
||||||
if (encoder->aud_enable)
|
if (encoder->aud_enable)
|
||||||
|
@ -737,6 +747,19 @@ static void encoder_state_write_bitstream_main(encoder_state * const main_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(main_state->tile->frame->poc == main_state->global->poc);
|
assert(main_state->tile->frame->poc == main_state->global->poc);
|
||||||
|
|
||||||
|
//Get bitstream length for stats
|
||||||
|
if (main_state->stream.base.type == BITSTREAM_TYPE_FILE) {
|
||||||
|
uint64_t newpos;
|
||||||
|
fgetpos(main_state->stream.file.output,(fpos_t*)&newpos);
|
||||||
|
main_state->stats_bitstream_length = newpos - curpos;
|
||||||
|
} else if (main_state->stream.base.type == BITSTREAM_TYPE_MEMORY) {
|
||||||
|
main_state->stats_bitstream_length = stream->mem.output_length - curpos;
|
||||||
|
} else {
|
||||||
|
//Should not happen
|
||||||
|
assert(0);
|
||||||
|
main_state->stats_bitstream_length = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void encoder_state_write_bitstream_leaf(encoder_state * const encoder_state) {
|
void encoder_state_write_bitstream_leaf(encoder_state * const encoder_state) {
|
||||||
|
|
|
@ -830,13 +830,12 @@ void encoder_compute_stats(encoder_state *encoder_state, FILE * const recout, ui
|
||||||
|
|
||||||
// PSNR calculations
|
// PSNR calculations
|
||||||
{
|
{
|
||||||
int32_t diff=0; //FIXME: get the correct length of bitstream
|
|
||||||
double temp_psnr[3];
|
double temp_psnr[3];
|
||||||
|
|
||||||
videoframe_compute_psnr(encoder_state->tile->frame, temp_psnr);
|
videoframe_compute_psnr(encoder_state->tile->frame, temp_psnr);
|
||||||
|
|
||||||
fprintf(stderr, "POC %4d (%c-frame) %10d bits PSNR: %2.4f %2.4f %2.4f\n", encoder_state->global->frame,
|
fprintf(stderr, "POC %4d (%c-frame) %10d bits PSNR: %2.4f %2.4f %2.4f\n", encoder_state->global->frame,
|
||||||
"BPI"[encoder_state->global->slicetype%3], diff<<3,
|
"BPI"[encoder_state->global->slicetype%3], encoder_state->stats_bitstream_length<<3,
|
||||||
temp_psnr[0], temp_psnr[1], temp_psnr[2]);
|
temp_psnr[0], temp_psnr[1], temp_psnr[2]);
|
||||||
|
|
||||||
// Increment total PSNR
|
// Increment total PSNR
|
||||||
|
|
|
@ -163,6 +163,7 @@ typedef struct encoder_state {
|
||||||
cabac_data cabac;
|
cabac_data cabac;
|
||||||
|
|
||||||
int stats_done;
|
int stats_done;
|
||||||
|
uint32_t stats_bitstream_length; //Bitstream length written in bytes
|
||||||
|
|
||||||
//Jobs to wait for
|
//Jobs to wait for
|
||||||
threadqueue_job * tqj_recon_done; //Reconstruction is done
|
threadqueue_job * tqj_recon_done; //Reconstruction is done
|
||||||
|
|
Loading…
Reference in a new issue