[x265] [PATCH] stats: add frame level csv printing

Divya Manivannan divya at multicorewareinc.com
Wed Jun 10 15:32:57 CEST 2015


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1433943002 -19800
#      Wed Jun 10 19:00:02 2015 +0530
# Node ID 09bc0967dfa84b6630e400229969d500b5aef624
# Parent  35d767d2ac378854794ff36b82a121a2833454f7
stats: add frame level csv printing

diff -r 35d767d2ac37 -r 09bc0967dfa8 source/x265.cpp
--- a/source/x265.cpp	Wed Jun 10 18:55:08 2015 +0530
+++ b/source/x265.cpp	Wed Jun 10 19:00:02 2015 +0530
@@ -124,6 +124,7 @@
     void destroy();
     bool parseCSVFile();
     void printLog(int argc, char **argv, x265_stats stats);
+    void printFrameLog(x265_frame_stats frameStats);
     void printStatus(uint32_t frameNum);
     bool parse(int argc, char **argv);
     bool parseQPFile(x265_picture &pic_org);
@@ -162,7 +163,19 @@
         /* new CSV file, write header */
         csvfpt = fopen(csvfn, "wb");
         if (csvfpt)
-            fputs(summaryCSVHeader, csvfpt);
+        {
+            if (csvData > 0)
+            {
+                fprintf(csvfpt, "Encode Order, Type, POC, QP, Bits, ");
+                if (param->rc.rateControlMode == X265_RC_CRF)
+                    fprintf(csvfpt, "RateFactor, ");
+                fprintf(csvfpt, "Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB),  List 0, List 1");
+                /* detailed performance statistics */
+                fprintf(csvfpt, ", DecideWait (ms), Row0Wait (ms), Wall time (ms), Ref Wait Wall (ms), Total CTU time (ms), Stall Time (ms), Avg WPP, Row Blocks\n");
+            }
+            else
+                fputs(summaryCSVHeader, csvfpt);
+        }
     }
 
     if (!csvfpt)
@@ -177,6 +190,12 @@
 {
     if (csvfpt)
     {
+        if (csvData > 0)
+        {
+            // adding summary to a per-frame csv log file needs a summary header
+            fprintf(csvfpt, "\nSummary\n");
+            fputs(summaryCSVHeader, csvfpt);
+        }
         // CLI arguments or other
         for (int i = 1; i < argc; i++)
         {
@@ -215,6 +234,39 @@
     }
 }
 
+void CLIOptions::printFrameLog(x265_frame_stats frameStats)
+{
+    if (csvfpt)
+    {
+        // per frame CSV logging if the file handle is valid
+        fprintf(csvfpt, "%d, %c-SLICE, %4d, %2.2lf, %10d,", frameStats.encoderOrder, frameStats.sliceType, frameStats.poc, frameStats.qp, (int)frameStats.bits);
+        if (param->rc.rateControlMode == X265_RC_CRF)
+            fprintf(csvfpt, "%.3lf,", frameStats.rateFactor);
+        if (param->bEnablePsnr)
+            fprintf(csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", frameStats.psnrY, frameStats.psnrU, frameStats.psnrV, frameStats.psnr);
+        else
+            fputs(" -, -, -, -,", csvfpt);
+        if (param->bEnableSsim)
+            fprintf(csvfpt, " %.6f, %6.3f,", frameStats.ssim, x265_ssim2dB(frameStats.ssim));
+        else
+            fputs(" -, -,", csvfpt);
+        if (frameStats.sliceType == 'I')
+            fputs(" -, -,", csvfpt);
+        else
+        {
+            fprintf(csvfpt, " %s,", frameStats.list1Buf);
+            if (frameStats.sliceType != 'P')
+                fprintf(csvfpt, " %s,", frameStats.list2Buf);
+            else
+                fputs(" -,", csvfpt);
+        }
+        fprintf(csvfpt, " %.1lf, %.1lf, %.1lf, %.1lf, %.1lf, %.1lf,", frameStats.decideWaitTime, frameStats.row0WaitTime, frameStats.wallTime, frameStats.refWaitWallTime, frameStats.totalCTUTime, frameStats.stallTime);
+        fprintf(csvfpt, " %.3lf, %d", frameStats.avgWPP, frameStats.countRowBlocks);
+        fprintf(csvfpt, "\n");
+        fflush(stderr);
+    }
+}
+
 void CLIOptions::printStatus(uint32_t frameNum)
 {
     char buf[200];
@@ -725,6 +777,8 @@
         }
 
         cliopt.printStatus(outFrameCount);
+        if (numEncoded && cliopt.csvData > 0)
+            cliopt.printFrameLog(pic_recon->frameData);
     }
 
     /* Flush the encoder */
@@ -755,6 +809,8 @@
         }
 
         cliopt.printStatus(outFrameCount);
+        if (numEncoded && cliopt.csvData > 0)
+            cliopt.printFrameLog(pic_recon->frameData);
 
         if (!numEncoded)
             break;


More information about the x265-devel mailing list