[FFmpeg-cvslog] avfilter: Add new format for PSNR stats log

Lucas Cooper git at videolan.org
Sat Jul 30 01:29:05 EEST 2016


ffmpeg | branch: master | Lucas Cooper <bobobo-at-google.com at ffmpeg.org> | Mon Jul 25 11:54:37 2016 -0700| [bc9ce5f6bec01cea4c291e5a339d3c08d89700f0] | committer: Michael Niedermayer

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 at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc9ce5f6bec01cea4c291e5a339d3c08d89700f0
---

 libavfilter/vf_psnr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 0c8d0f1..3bec747 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;



More information about the ffmpeg-cvslog mailing list