Added prints to bitrate and AVG QP

This commit is contained in:
Reima Hyvönen 2019-05-03 18:40:31 +03:00 committed by Pauli Oikkonen
parent 6d7a4f555c
commit 252bab8820
3 changed files with 21 additions and 1 deletions

View file

@ -30,7 +30,7 @@
#include <string.h>
#include <getopt.h>
#include <ctype.h>
unsigned int sum_of_qps = 0;
static const char short_options[] = "i:o:d:w:h:n:q:p:r:";
static const struct option long_options[] = {
{ "input", required_argument, NULL, 'i' },
@ -571,6 +571,7 @@ void print_frame_info(const kvz_frame_info *const info,
info->qp,
"BPI"[info->slice_type % 3],
bytes << 3);
sum_of_qps += info->qp;
if (print_psnr) {
fprintf(stderr, " PSNR Y %2.4f U %2.4f V %2.4f",
frame_psnr[0], frame_psnr[1], frame_psnr[2]);
@ -591,3 +592,8 @@ void print_frame_info(const kvz_frame_info *const info,
fprintf(stderr, "\n");
}
unsigned int return_sum_of_qps()
{
return sum_of_qps;
}

View file

@ -59,5 +59,6 @@ void print_frame_info(const kvz_frame_info *const info,
const double frame_psnr[3],
const uint32_t bytes,
const bool print_psnr);
unsigned int return_sum_of_qps();
#endif

View file

@ -638,6 +638,19 @@ int main(int argc, char *argv[])
fprintf(stderr, " Encoding wall time: %.3f s.\n", wall_time);
fprintf(stderr, " Encoding CPU usage: %.2f%%\n", encoding_time/wall_time*100.f);
fprintf(stderr, " FPS: %.2f\n", ((double)frames_done)/wall_time);
double bitrate = (long long unsigned int)bitstream_length * 8 / 1024 / ((double)frames_done) * frames_done / wall_time;
if (bitrate > 1024) {
bitrate = bitrate / 1024;
fprintf(stderr, " Bitrate: %.1f mbps\n", bitrate);
}
else {
fprintf(stderr, " Bitrate: %.1f kbps\n", bitrate);
}
fprintf(stderr, " AVG QP: %.1f\n", (double)(return_sum_of_qps() /frames_done));
;
}
pthread_join(input_thread, NULL);
}