Merge branch 'stats_and_framecount_fixes' of https://github.com/lfasnacht/kvazaar

This commit is contained in:
Marko Viitanen 2014-06-19 14:54:38 +03:00
commit 86fa7312c9
4 changed files with 33 additions and 3 deletions

View file

@ -355,6 +355,13 @@ int main(int argc, char *argv[])
//Clear encoder
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);
// Read one frame from the input

View file

@ -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) {
const encoder_control * const encoder = main_state->encoder_control;
bitstream * const stream = &main_state->stream;
uint64_t curpos;
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) {
// Access Unit Delimiter (AUD)
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);
//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) {

View file

@ -830,13 +830,12 @@ void encoder_compute_stats(encoder_state *encoder_state, FILE * const recout, ui
// PSNR calculations
{
int32_t diff=0; //FIXME: get the correct length of bitstream
double temp_psnr[3];
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,
"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]);
// Increment total PSNR

View file

@ -163,6 +163,7 @@ typedef struct encoder_state {
cabac_data cabac;
int stats_done;
uint32_t stats_bitstream_length; //Bitstream length written in bytes
//Jobs to wait for
threadqueue_job * tqj_recon_done; //Reconstruction is done