aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_psnr.c
diff options
context:
space:
mode:
authorLucas Cooper <bobobo-at-google.com@ffmpeg.org>2016-07-25 11:54:37 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2016-07-29 20:49:53 +0200
commitbc9ce5f6bec01cea4c291e5a339d3c08d89700f0 (patch)
treefec5a01ffcb4410dee9d367e8c4c8b2d4f28cd96 /libavfilter/vf_psnr.c
parent0219dc6c072586a14c641d108ef3e7da70fecae7 (diff)
downloadffmpeg-bc9ce5f6bec01cea4c291e5a339d3c08d89700f0.tar.gz
avfilter: Add new format for PSNR stats log
Add an AVOption stats_version with a new header for V2 stats, which specifies the stats log version and lists the fields that will be present in the log (to ease parsing). The primary motivation is to facilitate the addition of optional fields to the log without breaking backwards compatibility, while making the logs easier to parse. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavfilter/vf_psnr.c')
-rw-r--r--libavfilter/vf_psnr.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 0c8d0f1a31..3bec747573 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -43,6 +43,8 @@ typedef struct PSNRContext {
uint64_t nb_frames;
FILE *stats_file;
char *stats_file_str;
+ int stats_version;
+ int stats_header_written;
int max[4], average_max;
int is_rgb;
uint8_t rgba_map[4];
@@ -60,6 +62,7 @@ typedef struct PSNRContext {
static const AVOption psnr_options[] = {
{"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
+ {"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS },
{ NULL }
};
@@ -169,6 +172,19 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main,
set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max));
if (s->stats_file) {
+ if (s->stats_version == 2 && !s->stats_header_written) {
+ fprintf(s->stats_file, "psnr_log_version:2 fields:n");
+ fprintf(s->stats_file, ",mse_avg");
+ for (j = 0; j < s->nb_components; j++) {
+ fprintf(s->stats_file, ",mse_%c", s->comps[j]);
+ }
+ fprintf(s->stats_file, ",psnr_avg");
+ for (j = 0; j < s->nb_components; j++) {
+ fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
+ }
+ fprintf(s->stats_file, "\n");
+ s->stats_header_written = 1;
+ }
fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse);
for (j = 0; j < s->nb_components; j++) {
c = s->is_rgb ? s->rgba_map[j] : j;