[x265] [PATCH] search: dump best motion statistics for P and B slices into analysisdata file

gopu at multicorewareinc.com gopu at multicorewareinc.com
Tue Oct 14 08:38:06 CEST 2014


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1413268677 -19800
#      Tue Oct 14 12:07:57 2014 +0530
# Node ID ef61b042ab3678c9d27b819efed46f5be8969c32
# Parent  f26e81eb555aa586380b34314c302ea9b148f357
search: dump best motion statistics for P and B slices into analysisdata file

diff -r f26e81eb555a -r ef61b042ab36 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Mon Oct 13 14:36:40 2014 +0530
+++ b/source/Lib/TLibCommon/TComRom.h	Tue Oct 14 12:07:57 2014 +0530
@@ -68,6 +68,8 @@
 
 #define SLFASE_CONSTANT 0x5f4e4a53
 
+#define MAX_RECURSIVE 85 //maximum recursive call for each cu
+
 void initROM();
 void destroyROM();
 
diff -r f26e81eb555a -r ef61b042ab36 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Mon Oct 13 14:36:40 2014 +0530
+++ b/source/encoder/analysis.cpp	Tue Oct 14 12:07:57 2014 +0530
@@ -477,6 +477,9 @@
     }
     else
     {
+        if (m_param->analysisMode)
+            m_interAnalysisData = ctu->m_pic->m_interData + (ctu->m_cuAddr * MAX_RECURSIVE);
+
         if (m_param->rdLevel < 5)
         {
             TComDataCU* outBestCU = NULL;
@@ -712,8 +715,6 @@
         for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++)
         {
             CU *child_cu = pic->getCU(outTempCU->m_cuAddr)->m_cuLocalData + cu->childIdx + partUnitIdx;
-            int qp = outTempCU->getQP(0);
-            subBestPartCU->initSubCU(outTempCU, child_cu, partUnitIdx, nextDepth, qp); // clear sub partition datas or init.
             if (child_cu->flags & CU::PRESENT)
             {
                 subTempPartCU->initSubCU(outTempCU, child_cu, partUnitIdx, nextDepth, qp); // clear sub partition datas or init.
@@ -1386,6 +1387,10 @@
             m_bestRecoYuv[depth]->copyToPicYuv(pic->getPicYuvRec(), cuAddr, absPartIdx);
     }
 
+    /* increment the analysisData buffer for each recursive call */
+    if (m_interAnalysisData)
+        m_interAnalysisData++;
+
 #if CHECKED_BUILD || _DEBUG
     /* Assert if Best prediction mode is NONE
      * Selected mode's RD-cost must be not MAX_INT64 */
@@ -1450,6 +1455,10 @@
                 outTempCU->initEstData();
                 if (m_param->bEnableCbfFastMode)
                     doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
+
+                /* increment the analysisData buffer for each recursive call */
+                if (m_interAnalysisData)
+                    m_interAnalysisData++;
             }
         }
 
@@ -2093,7 +2102,7 @@
         cu->m_totalDistortion = primitives.sa8d[sizeIdx](m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(), predYuv->getLumaAddr(), predYuv->getStride());
         cu->m_sa8dCost = m_rdCost.calcRdSADCost(cu->m_totalDistortion, cu->m_totalBits);
     }
-    else if (predInterSearch(cu, cuData, predYuv, false, false))
+    else if (predInterSearch(cu, cuData, predYuv, false, false, m_interAnalysisData))
     {
         int sizeIdx = cu->getLog2CUSize(0) - 2;
         uint32_t distortion = primitives.sa8d[sizeIdx](m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(), predYuv->getLumaAddr(), predYuv->getStride());
@@ -2124,7 +2133,7 @@
         checkDQP(tempCU);
         checkBestMode(bestCU, tempCU, depth);
     }
-    else if (predInterSearch(tempCU, cuData, m_tmpPredYuv[depth], bMergeOnly, true))
+    else if (predInterSearch(tempCU, cuData, m_tmpPredYuv[depth], bMergeOnly, true, m_interAnalysisData))
     {
         encodeResAndCalcRdInterCU(tempCU, cuData, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth]);
         checkDQP(tempCU);
diff -r f26e81eb555a -r ef61b042ab36 source/encoder/analysis.h
--- a/source/encoder/analysis.h	Mon Oct 13 14:36:40 2014 +0530
+++ b/source/encoder/analysis.h	Tue Oct 14 12:07:57 2014 +0530
@@ -109,6 +109,7 @@
 
     StatisticLog  m_sliceTypeLog[3];
     StatisticLog* m_log;
+    x265_inter_data* m_interAnalysisData;    // To store the inter analysis data per CU
 
     Analysis();
     bool create(uint32_t totalDepth, uint32_t maxWidth, ThreadLocalData* tld);
diff -r f26e81eb555a -r ef61b042ab36 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Mon Oct 13 14:36:40 2014 +0530
+++ b/source/encoder/search.cpp	Tue Oct 14 12:07:57 2014 +0530
@@ -1684,7 +1684,7 @@
 
 /* search of the best candidate for inter prediction
  * returns true if predYuv was filled with a motion compensated prediction */
-bool Search::predInterSearch(TComDataCU* cu, CU* cuData, TComYuv* predYuv, bool bMergeOnly, bool bChroma)
+bool Search::predInterSearch(TComDataCU* cu, CU* cuData, TComYuv* predYuv, bool bMergeOnly, bool bChroma, x265_inter_data* interAnalysisData)
 {
     MV amvpCand[2][MAX_NUM_REF][AMVP_NUM_CANDS];
     MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];
@@ -1755,6 +1755,11 @@
         list[0].cost = MAX_UINT;
         list[1].cost = MAX_UINT;
 
+        /* require for sharing mode, if cost is zero no need to call subpelCompare
+         * extract the best cost from mvcost and this is only for actual me, not required for
+         * lowres me and isCostZero is NULL when the me is called from slicetype */
+        bool costZero[2];
+
         getBlkBits(partSize, slice->isInterP(), partIdx, lastMode, listSelBits);
 
         // Uni-directional prediction
@@ -1812,10 +1817,24 @@
                     list[l].ref = ref;
                     list[l].cost = cost;
                     list[l].bits = bits;
+                    costZero[l] = !!satdCost;
                 }
             }
         }
 
+        if (m_param->analysisMode == X265_ANALYSIS_SAVE && interAnalysisData)
+        {
+            for (int32_t i = 0; i < 2; i++)
+            {
+                interAnalysisData->costZero[i] = costZero[i];
+                interAnalysisData->mvx[i] = list[i].mv.x;
+                interAnalysisData->mvy[i] = list[i].mv.y;
+                interAnalysisData->ref[i] = list[i].ref;
+            }
+            interAnalysisData->zOrder = cu->m_absIdxInCTU;
+            interAnalysisData->depth  = cu->getDepth(0);
+        }
+
         // Bi-directional prediction
         if (slice->isInterB() && !cu->isBipredRestriction() && list[0].cost != MAX_UINT && list[1].cost != MAX_UINT)
         {
diff -r f26e81eb555a -r ef61b042ab36 source/encoder/search.h
--- a/source/encoder/search.h	Mon Oct 13 14:36:40 2014 +0530
+++ b/source/encoder/search.h	Tue Oct 14 12:07:57 2014 +0530
@@ -101,7 +101,7 @@
     void     estIntraPredChromaQT(TComDataCU* cu, CU* cuData, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv);
 
     // estimation inter prediction (non-skip)
-    bool     predInterSearch(TComDataCU* cu, CU* cuData, TComYuv* predYuv, bool bMergeOnly, bool bChroma);
+    bool     predInterSearch(TComDataCU* cu, CU* cuData, TComYuv* predYuv, bool bMergeOnly, bool bChroma, x265_inter_data* m_interAnalysisData);
 
     // encode residual and compute rd-cost for inter mode
     void     encodeResAndCalcRdInterCU(TComDataCU* cu, CU* cuData, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, ShortYuv* bestResiYuv, TComYuv* reconYuv);


More information about the x265-devel mailing list