[x265] [PATCH] csv: dump input sequence and preset info in csv

mahesh at multicorewareinc.com mahesh at multicorewareinc.com
Fri Sep 11 15:07:28 CEST 2015


# HG changeset patch
# User Mahesh Pittala <mahesh at multicorewareinc.com>
# Date 1441976825 -19800
#      Fri Sep 11 18:37:05 2015 +0530
# Node ID ee6208293726f96786389b342bc810557763bd26
# Parent  365f7ed4d89628d49cd6af8d81d4edc01f73ffad
csv: dump input sequence and preset info in csv

diff -r 365f7ed4d896 -r ee6208293726 source/x265-extras.cpp
--- a/source/x265-extras.cpp	Tue Sep 08 16:38:01 2015 +0530
+++ b/source/x265-extras.cpp	Fri Sep 11 18:37:05 2015 +0530
@@ -31,7 +31,7 @@
 using namespace X265_NS;
 
 static const char* summaryCSVHeader =
-    "Command, Date/Time, Elapsed Time, FPS, Bitrate, "
+    "Input Sequence, Preset, Command, Date/Time, Elapsed Time, FPS, Bitrate, "
     "Y PSNR, U PSNR, V PSNR, Global PSNR, SSIM, SSIM (dB), "
     "I count, I ave-QP, I kbps, I-PSNR Y, I-PSNR U, I-PSNR V, I-SSIM (dB), "
     "P count, P ave-QP, P kbps, P-PSNR Y, P-PSNR U, P-PSNR V, P-SSIM (dB), "
@@ -185,7 +185,7 @@
     fflush(stderr);
 }
 
-void x265_csvlog_encode(FILE* csvfp, const x265_api& api, const x265_param& param, const x265_stats& stats, int level, int argc, char** argv)
+void x265_csvlog_encode(FILE* csvfp, const x265_api& api, const x265_param& param, const x265_stats& stats, int level, int argc, char** argv, char *prst, const char *inputseq)
 {
     if (!csvfp)
         return;
@@ -197,11 +197,31 @@
         fputs(summaryCSVHeader, csvfp);
     }
 
+    // strip input sequence path
+    char *tok;
+    char *prevtok = NULL;
+    char temp[256];
+    strcpy(temp,inputseq);
+    tok = strtok(temp,"\\://");
+    while(tok != NULL)
+    {
+        prevtok = tok;
+        tok = strtok(NULL,"//:\\");
+    }
+
+    fputs(prevtok, csvfp);
+    fputc(',', csvfp);
+    if (prst == NULL)
+        fputs("medium", csvfp);
+    else
+        fputs(prst, csvfp);
+    fputc(',', csvfp);
+
     // CLI arguments or other
-    for (int i = 1; i < argc; i++)
-    {
-        if (i) fputc(' ', csvfp);
-        fputs(argv[i], csvfp);
+    for (int i = 1; i < argc; i++)
+    {
+        if (i) fputc(' ', csvfp);
+        fputs(argv[i], csvfp);
     }
 
     // current date and time
diff -r 365f7ed4d896 -r ee6208293726 source/x265-extras.h
--- a/source/x265-extras.h	Tue Sep 08 16:38:01 2015 +0530
+++ b/source/x265-extras.h	Fri Sep 11 18:37:05 2015 +0530
@@ -53,7 +53,7 @@
 /* Log final encode statistics to the CSV file handle. 'argc' and 'argv' are
  * intended to be command line arguments passed to the encoder. Encode
  * statistics should be queried from the encoder just prior to closing it. */
-LIBAPI void x265_csvlog_encode(FILE* csvfp, const x265_api& api, const x265_param& param, const x265_stats& stats, int level, int argc, char** argv);
+LIBAPI void x265_csvlog_encode(FILE* csvfp, const x265_api& api, const x265_param& param, const x265_stats& stats, int level, int argc, char** argv, char * prst, const char *inputseq);
 
 /* In-place downshift from a bit-depth greater than 8 to a bit-depth of 8, using
  * the residual bits to dither each row. */
diff -r 365f7ed4d896 -r ee6208293726 source/x265.cpp
--- a/source/x265.cpp	Tue Sep 08 16:38:01 2015 +0530
+++ b/source/x265.cpp	Fri Sep 11 18:37:05 2015 +0530
@@ -90,6 +90,8 @@
     uint64_t totalbytes;
     int64_t startTime;
     int64_t prevUpdateTime;
+    char *prst;
+    const char *inputseq;
 
     /* in microseconds */
     static const int UPDATE_INTERVAL = 250000;
@@ -113,6 +115,8 @@
         prevUpdateTime = 0;
         bDither = false;
         csvLogLevel = 0;
+        prst = NULL;
+        inputseq = NULL;
     }
 
     void destroy();
@@ -194,7 +198,10 @@
         if (c == -1)
             break;
         else if (c == 'p')
+        {
             preset = optarg;
+            prst = optarg;
+        }
         else if (c == 't')
             tune = optarg;
         else if (c == 'D')
@@ -204,7 +211,6 @@
         else if (c == '?')
             bShowHelp = true;
     }
-
     if (!outputBitDepth && profile)
     {
         /* try to derive the output bit depth from the requested profile */
@@ -373,6 +379,7 @@
     info.sarHeight = param->vui.sarHeight;
     info.skipFrames = seek;
     info.frameCount = 0;
+    inputseq = info.filename;
     getParamAspectRatio(param, info.sarWidth, info.sarHeight);
 
     this->input = InputFile::open(info, this->bForceY4m);
@@ -715,7 +722,7 @@
 
     api->encoder_get_stats(encoder, &stats, sizeof(stats));
     if (cliopt.csvfpt && !b_ctrl_c)
-        x265_csvlog_encode(cliopt.csvfpt, *api, *param, stats, cliopt.csvLogLevel, argc, argv);
+        x265_csvlog_encode(cliopt.csvfpt, *api, *param, stats, cliopt.csvLogLevel, argc, argv, cliopt.prst, cliopt.inputseq);
     api->encoder_close(encoder);
 
     int64_t second_largest_pts = 0;


More information about the x265-devel mailing list