[x265] [PATCH] log: statistics for max depth analysis

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Dec 11 07:00:25 CET 2013


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1386740625 -19800
#      Wed Dec 11 11:13:45 2013 +0530
# Node ID 503d382aa8c4bede5ab61f6543e5d617672155f4
# Parent  3bf6be9d766b83ff253b504dbe1cf395bdffbac4
log: statistics for max depth analysis

diff -r 3bf6be9d766b -r 503d382aa8c4 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Tue Dec 10 11:05:28 2013 -0600
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Wed Dec 11 11:13:45 2013 +0530
@@ -598,9 +598,16 @@
 
         // Early CU determination
         if (outBestCU->isSkipped(0))
+        {
             bSubBranch = false;
+            m_log->cntAnalysisDepth[depth]++;
+        }
         else
+        {
             bSubBranch = true;
+            if (depth == g_maxCUDepth - 1)
+                m_log->cntAnalysisDepth[depth]++;
+        }
     }
     else if (!(bSliceEnd && bInsidePicture))
     {
@@ -948,9 +955,16 @@
 
         // Early CU determination
         if (outBestCU->isSkipped(0))
+        {
             bSubBranch = false;
+            m_log->cntAnalysisDepth[depth]++;
+        }
         else
+        {
             bSubBranch = true;
+            if (depth == g_maxCUDepth - 1)
+                m_log->cntAnalysisDepth[depth]++;
+        }
     }
     else if (!(bSliceEnd && bInsidePicture))
     {
diff -r 3bf6be9d766b -r 503d382aa8c4 source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Tue Dec 10 11:05:28 2013 -0600
+++ b/source/Lib/TLibEncoder/TEncCu.h	Wed Dec 11 11:13:45 2013 +0530
@@ -66,6 +66,7 @@
     uint64_t cntSkipCu[4];
     uint64_t cntTotalCu[4];
     uint64_t totalCu;
+    uint64_t cntAnalysisDepth[4];
 
     StatisticLog()
     {
diff -r 3bf6be9d766b -r 503d382aa8c4 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Tue Dec 10 11:05:28 2013 -0600
+++ b/source/encoder/compress.cpp	Wed Dec 11 11:13:45 2013 +0530
@@ -598,9 +598,16 @@
             }
             /* Disable recursive analysis for whole CUs temporarily */
             if ((outBestCU != 0) && (outBestCU->isSkipped(0)))
+            {
                 bSubBranch = false;
+                m_log->cntAnalysisDepth[depth]++;
+            }
             else
+            {
                 bSubBranch = true;
+                if (depth == g_maxCUDepth - 1)
+                    m_log->cntAnalysisDepth[depth]++;
+            }
 
             m_entropyCoder->resetBits();
             m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
@@ -675,6 +682,7 @@
 
                 /* Copy Yuv data to picture Yuv */
                 xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(), outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpely);
+                m_log->cntAnalysisDepth[depth]++;
                 return;
             }
         }
diff -r 3bf6be9d766b -r 503d382aa8c4 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Tue Dec 10 11:05:28 2013 -0600
+++ b/source/encoder/encoder.cpp	Wed Dec 11 11:13:45 2013 +0530
@@ -384,6 +384,8 @@
 
 void Encoder::printSummary()
 {
+    uint64_t cntAnalysisDepth[3][4];
+    char sliceTypeChar[] = "BPI";
     for (int sliceType = 2; sliceType >= 0; sliceType--)
     {
         if (sliceType == P_SLICE && !m_analyzeP.m_numPics)
@@ -392,6 +394,7 @@
             continue;
 
         StatisticLog finalLog;
+        uint64_t totalAnalysedCu = 0;
         for (int depth = 0; depth < (int)g_maxCUDepth; depth++)
         {
             for (int j = 0; j < param.frameNumThreads; j++)
@@ -401,6 +404,7 @@
                     StatisticLog& enclog = m_frameEncoder[j].m_rows[row].m_cuCoder.m_sliceTypeLog[sliceType];
                     if (depth == 0)
                         finalLog.totalCu += enclog.totalCu;
+                    finalLog.cntAnalysisDepth[depth] += enclog.cntAnalysisDepth[depth];
                     finalLog.cntIntra[depth] += enclog.cntIntra[depth];
                     for (int m = 0; m < INTER_MODES; m++)
                     {
@@ -420,6 +424,7 @@
                     }
                 }
             }
+            totalAnalysedCu += finalLog.cntAnalysisDepth[depth];
 
             uint64_t cntInter, cntSkipCu, cntIntra = 0, cntIntraNxN = 0, encCu = 0;
             uint64_t cuInterDistribution[INTER_MODES], cuIntraDistribution[INTRA_MODES];
@@ -524,8 +529,29 @@
                 }
             }
             if (stats[0])
-                x265_log(&param, X265_LOG_INFO, "%c%-2d: %s\n", sliceType == P_SLICE ? 'P' : sliceType == B_SLICE ? 'B' : 'I', cuSize, stats);
+                x265_log(&param, X265_LOG_INFO, "%c%-2d: %s\n", sliceTypeChar[sliceType], cuSize, stats);
         }
+        for (int depth = 0; depth < (int)g_maxCUDepth; depth++)
+        {
+            if (totalAnalysedCu == 0)
+                cntAnalysisDepth[sliceType][depth] = 0;
+            else
+                cntAnalysisDepth[sliceType][depth] = (finalLog.cntAnalysisDepth[depth] * 100) / totalAnalysedCu;
+        }
+    }
+    for (int slice = 2; slice >= 0; slice--)
+    {
+        if (slice == P_SLICE && !m_analyzeP.m_numPics)
+            continue;
+        if (slice == B_SLICE && !m_analyzeB.m_numPics)
+            continue;
+        char stats[50];
+        int len = 0;
+        for (int i = 0; i < (int)g_maxCUDepth; i++)
+        {
+            len += sprintf(stats + len, LL"%%  ", cntAnalysisDepth[slice][i]);
+        }
+        x265_log(&param, X265_LOG_INFO, "analysis depth %c%d..8:  %s\n", sliceTypeChar[slice], g_maxCUWidth, stats);
     }
 
     if (param.logLevel >= X265_LOG_INFO)


More information about the x265-devel mailing list