mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Some updates done to get right bitrate and avg QP
This commit is contained in:
parent
252bab8820
commit
80575c59bf
11
src/cli.c
11
src/cli.c
|
@ -31,6 +31,7 @@
|
|||
#include <getopt.h>
|
||||
#include <ctype.h>
|
||||
unsigned int sum_of_qps = 0;
|
||||
unsigned int frames_done = 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' },
|
||||
|
@ -255,7 +256,6 @@ cmdline_opts_t* cmdline_opts_parse(const kvz_api *const api, int argc, char *arg
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for extra arguments.
|
||||
if (argc - optind > 0) {
|
||||
fprintf(stderr, "Input error: Extra argument found: \"%s\"\n", argv[optind]);
|
||||
|
@ -282,7 +282,6 @@ cmdline_opts_t* cmdline_opts_parse(const kvz_api *const api, int argc, char *arg
|
|||
ok = select_input_res_auto(opts->input, &opts->config->width, &opts->config->height);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if (!ok) {
|
||||
cmdline_opts_free(api, opts);
|
||||
|
@ -566,12 +565,16 @@ void print_frame_info(const kvz_frame_info *const info,
|
|||
const uint32_t bytes,
|
||||
const bool print_psnr)
|
||||
{
|
||||
fprintf(stderr, "POC %4d QP %2d (%c-frame) %10d bits",
|
||||
sum_of_qps += info->qp;
|
||||
frames_done += 1;
|
||||
double avg_qp = sum_of_qps / frames_done;
|
||||
fprintf(stderr, "POC %4d QP %2d AVG QP %.1f (%c-frame) %10d bits",
|
||||
info->poc,
|
||||
info->qp,
|
||||
avg_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]);
|
||||
|
|
|
@ -636,21 +636,19 @@ int main(int argc, char *argv[])
|
|||
double wall_time = KVZ_CLOCK_T_AS_DOUBLE(encoding_end_real_time) - KVZ_CLOCK_T_AS_DOUBLE(encoding_start_real_time);
|
||||
fprintf(stderr, " Encoding time: %.3f s.\n", encoding_time);
|
||||
fprintf(stderr, " Encoding wall time: %.3f s.\n", wall_time);
|
||||
fprintf(stderr, " Encoding CPU usage: %.2f%%\n", encoding_time/wall_time*100.f);
|
||||
|
||||
double encoding_cpu = encoding_time / wall_time * 100.f;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (encoding_cpu > 100) encoding_cpu = 100;
|
||||
#endif
|
||||
|
||||
|
||||
fprintf(stderr, " Encoding CPU usage: %.2f%%\n", encoding_cpu);
|
||||
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);
|
||||
}
|
||||
double bitrate = (bitstream_length * 8 * (double)(encoder->cfg.framerate_num / encoder->cfg.framerate_denom) / 1024 / frames_done / 1024);
|
||||
fprintf(stderr, " Bitrate: %.3f mbps\n", bitrate);
|
||||
fprintf(stderr, " AVG QP: %.1f\n", (double)(return_sum_of_qps() /frames_done));
|
||||
|
||||
;
|
||||
}
|
||||
pthread_join(input_thread, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue