ref: e758f9d45704ea0247c1b654f8602c967fa44199
parent: 70c9b3c6686660e45c617468e4f6ea103a10c7cb
parent: a981cb2809e14cde251e212d388148bcdc89a79b
author: Peter Boström <[email protected]>
date: Wed Jan 18 11:32:34 EST 2017
Merge "Add CSV per-frame stats to vpxdec."
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -94,16 +94,21 @@
#endif
static const arg_def_t svcdecodingarg = ARG_DEF(
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[] = {
- &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo,
- &noblitarg, &progressarg, &limitarg, &skiparg, &postprocarg,
- &summaryarg, &outputfile, &threadsarg, &frameparallelarg, &verbosearg,
- &scalearg, &fb_arg, &md5arg, &error_concealment, &continuearg,
+ &codecarg, &use_yv12, &use_i420,
+ &flipuvarg, &rawvideo, &noblitarg,
+ &progressarg, &limitarg, &skiparg,
+ &postprocarg, &summaryarg, &outputfile,
+ &threadsarg, &frameparallelarg, &verbosearg,
+ &scalearg, &fb_arg, &md5arg,
+ &error_concealment, &continuearg,
#if CONFIG_VP9_HIGHBITDEPTH
&outbitdeptharg,
#endif
- &svcdecodingarg, NULL
+ &svcdecodingarg, &framestatsarg, NULL
};
#if CONFIG_VP8_DECODER
@@ -527,6 +532,8 @@
char outfile_name[PATH_MAX] = { 0 };
FILE *outfile = NULL;
+ FILE *framestats_file = NULL;
+
MD5Context md5_ctx;
unsigned char md5_digest[16];
@@ -603,6 +610,12 @@
else if (arg_match(&arg, &svcdecodingarg, argi)) {
svc_decoding = 1;
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
else if (arg_match(&arg, &addnoise_level, argi)) {
@@ -761,6 +774,8 @@
frame_avail = 1;
got_data = 0;
+ if (framestats_file) fprintf(framestats_file, "bytes,qp\n");
+
/* Decode file */
while (frame_avail || got_data) {
vpx_codec_iter_t iter = NULL;
@@ -786,6 +801,16 @@
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);
dx_time += vpx_usec_timer_elapsed(&timer);
} else {
@@ -1018,6 +1043,8 @@
free(ext_fb_list.ext_fb);
fclose(infile);
+ if (framestats_file) fclose(framestats_file);
+
free(argv);
return ret;