Merge "Add CSV per-frame stats to vpxdec."

This commit is contained in:
Peter Boström
2017-01-18 16:32:34 +00:00
committed by Gerrit Code Review

View File

@@ -94,16 +94,21 @@ static const arg_def_t outbitdeptharg =
#endif #endif
static const arg_def_t svcdecodingarg = ARG_DEF( static const arg_def_t svcdecodingarg = ARG_DEF(
NULL, "svc-decode-layer", 1, "Decode SVC stream up to given spatial layer"); NULL, "svc-decode-layer", 1, "Decode SVC stream up to given spatial layer");
static const arg_def_t framestatsarg =
ARG_DEF(NULL, "framestats", 1, "Output per-frame stats (.csv format)");
static const arg_def_t *all_args[] = { static const arg_def_t *all_args[] = {
&codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &codecarg, &use_yv12, &use_i420,
&noblitarg, &progressarg, &limitarg, &skiparg, &postprocarg, &flipuvarg, &rawvideo, &noblitarg,
&summaryarg, &outputfile, &threadsarg, &frameparallelarg, &verbosearg, &progressarg, &limitarg, &skiparg,
&scalearg, &fb_arg, &md5arg, &error_concealment, &continuearg, &postprocarg, &summaryarg, &outputfile,
&threadsarg, &frameparallelarg, &verbosearg,
&scalearg, &fb_arg, &md5arg,
&error_concealment, &continuearg,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
&outbitdeptharg, &outbitdeptharg,
#endif #endif
&svcdecodingarg, NULL &svcdecodingarg, &framestatsarg, NULL
}; };
#if CONFIG_VP8_DECODER #if CONFIG_VP8_DECODER
@@ -527,6 +532,8 @@ static int main_loop(int argc, const char **argv_) {
char outfile_name[PATH_MAX] = { 0 }; char outfile_name[PATH_MAX] = { 0 };
FILE *outfile = NULL; FILE *outfile = NULL;
FILE *framestats_file = NULL;
MD5Context md5_ctx; MD5Context md5_ctx;
unsigned char md5_digest[16]; unsigned char md5_digest[16];
@@ -603,6 +610,12 @@ static int main_loop(int argc, const char **argv_) {
else if (arg_match(&arg, &svcdecodingarg, argi)) { else if (arg_match(&arg, &svcdecodingarg, argi)) {
svc_decoding = 1; svc_decoding = 1;
svc_spatial_layer = arg_parse_uint(&arg); svc_spatial_layer = arg_parse_uint(&arg);
} else if (arg_match(&arg, &framestatsarg, argi)) {
framestats_file = fopen(arg.val, "w");
if (!framestats_file) {
die("Error: Could not open --framestats file (%s) for writing.\n",
arg.val);
}
} }
#if CONFIG_VP8_DECODER #if CONFIG_VP8_DECODER
else if (arg_match(&arg, &addnoise_level, argi)) { else if (arg_match(&arg, &addnoise_level, argi)) {
@@ -761,6 +774,8 @@ static int main_loop(int argc, const char **argv_) {
frame_avail = 1; frame_avail = 1;
got_data = 0; got_data = 0;
if (framestats_file) fprintf(framestats_file, "bytes,qp\n");
/* Decode file */ /* Decode file */
while (frame_avail || got_data) { while (frame_avail || got_data) {
vpx_codec_iter_t iter = NULL; vpx_codec_iter_t iter = NULL;
@@ -786,6 +801,16 @@ static int main_loop(int argc, const char **argv_) {
if (!keep_going) goto fail; if (!keep_going) goto fail;
} }
if (framestats_file) {
int qp;
if (vpx_codec_control(&decoder, VPXD_GET_LAST_QUANTIZER, &qp)) {
warn("Failed VPXD_GET_LAST_QUANTIZER: %s",
vpx_codec_error(&decoder));
if (!keep_going) goto fail;
}
fprintf(framestats_file, "%d,%d\n", (int)bytes_in_buffer, qp);
}
vpx_usec_timer_mark(&timer); vpx_usec_timer_mark(&timer);
dx_time += vpx_usec_timer_elapsed(&timer); dx_time += vpx_usec_timer_elapsed(&timer);
} else { } else {
@@ -1018,6 +1043,8 @@ fail2:
free(ext_fb_list.ext_fb); free(ext_fb_list.ext_fb);
fclose(infile); fclose(infile);
if (framestats_file) fclose(framestats_file);
free(argv); free(argv);
return ret; return ret;