[x265] [PATCH 2 of 3] analysis: do not save best merge candidate index anymore

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Thu Feb 11 08:24:13 CET 2016


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1454913447 -19800
#      Mon Feb 08 12:07:27 2016 +0530
# Node ID 969e64f43b9623c130317779a508b5c1bd57231a
# Parent  07eb2d73102b7bcd1dceaba3d575e50a8ec85c14
analysis: do not save best merge candidate index anymore

diff -r 07eb2d73102b -r 969e64f43b96 source/common/framedata.h
--- a/source/common/framedata.h	Tue Feb 09 18:55:54 2016 +0530
+++ b/source/common/framedata.h	Mon Feb 08 12:07:27 2016 +0530
@@ -172,7 +172,6 @@
     int32_t*    ref;
     uint8_t*    depth;
     uint8_t*    modes;
-    uint32_t*   bestMergeCand;
 };
 }
 #endif // ifndef X265_FRAMEDATA_H
diff -r 07eb2d73102b -r 969e64f43b96 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Tue Feb 09 18:55:54 2016 +0530
+++ b/source/encoder/analysis.cpp	Mon Feb 08 12:07:27 2016 +0530
@@ -74,7 +74,6 @@
 {
     m_reuseInterDataCTU = NULL;
     m_reuseRef = NULL;
-    m_reuseBestMergeCand = NULL;
     m_reuseMv = NULL;
 }
 bool Analysis::create(ThreadLocalData *tld)
@@ -149,7 +148,6 @@
         int numPredDir = m_slice->isInterP() ? 1 : 2;
         m_reuseInterDataCTU = (analysis_inter_data*)m_frame->m_analysisData.interData;
         m_reuseRef = &m_reuseInterDataCTU->ref[ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];
-        m_reuseBestMergeCand = &m_reuseInterDataCTU->bestMergeCand[ctu.m_cuAddr * CUGeom::MAX_GEOMS];
         m_reuseMv = &m_reuseInterDataCTU->mv[ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];
     }
     ProfileCUScope(ctu, totalCTUTime, totalCTUs);
@@ -612,7 +610,7 @@
         if (m_param->rdLevel <= 4)
             checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);
         else
-            checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom, false);
+            checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);
     }
 
     bool bNoSplit = false;
@@ -1381,7 +1379,7 @@
         {
             md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
             md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
-            checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom, true);
+            checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);
 
             // increment zOrder offset to point to next best depth in sharedDepth buffer
             zOrder += g_depthInc[g_maxCUDepth - 1][reuseDepth[zOrder]];
@@ -1401,7 +1399,7 @@
     {
         md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
         md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
-        checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom, false);
+        checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);
         foundSkip = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);
     }
 
@@ -1933,7 +1931,7 @@
 }
 
 /* sets md.bestMode if a valid merge candidate is found, else leaves it NULL */
-void Analysis::checkMerge2Nx2N_rd5_6(Mode& skip, Mode& merge, const CUGeom& cuGeom, bool isShareMergeCand)
+void Analysis::checkMerge2Nx2N_rd5_6(Mode& skip, Mode& merge, const CUGeom& cuGeom)
 {
     uint32_t depth = cuGeom.depth;
 
@@ -1961,19 +1959,13 @@
     bool triedPZero = false, triedBZero = false;
     bestPred->rdCost = MAX_INT64;
 
-    uint32_t first = 0, last = numMergeCand;
-    if (isShareMergeCand)
-    {
-        first = *m_reuseBestMergeCand;
-        last = first + 1;
-    }
     int safeX, maxSafeMv;
     if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE)
     {
         safeX = m_slice->m_refFrameList[0][0]->m_encData->m_pir.pirEndCol * g_maxCUSize - 3;
         maxSafeMv = (safeX - tempPred->cu.m_cuPelX) * 4;
     }
-    for (uint32_t i = first; i < last; i++)
+    for (uint32_t i = 0; i < numMergeCand; i++)
     {
         if (m_bFrameParallel &&
             (candMvField[i][0].mv.y >= (m_param->searchRange + 1) * 4 ||
@@ -2012,8 +2004,7 @@
 
         uint8_t hasCbf = true;
         bool swapped = false;
-        /* bypass encoding merge with residual if analysis-mode = load as only SKIP CUs enter this function */
-        if (!foundCbf0Merge && !isShareMergeCand)
+        if (!foundCbf0Merge)
         {
             /* if the best prediction has CBF (not a skip) then try merge with residual */
 
@@ -2063,13 +2054,6 @@
         bestPred->cu.setPURefIdx(1, (int8_t)candMvField[bestCand][1].refIdx, 0, 0);
         checkDQP(*bestPred, cuGeom);
     }
-
-    if (m_param->analysisMode)
-    {
-        if (m_param->analysisMode == X265_ANALYSIS_SAVE)
-            *m_reuseBestMergeCand = bestPred->cu.m_mvpIdx[0][0];
-        m_reuseBestMergeCand++;
-    }
 }
 
 void Analysis::checkInter_rd0_4(Mode& interMode, const CUGeom& cuGeom, PartSize partSize, uint32_t refMask[2])
diff -r 07eb2d73102b -r 969e64f43b96 source/encoder/analysis.h
--- a/source/encoder/analysis.h	Tue Feb 09 18:55:54 2016 +0530
+++ b/source/encoder/analysis.h	Mon Feb 08 12:07:27 2016 +0530
@@ -121,7 +121,6 @@
     analysis_inter_data* m_reuseInterDataCTU;
     MV*                  m_reuseMv;
     int32_t*             m_reuseRef;
-    uint32_t*            m_reuseBestMergeCand;
     uint32_t m_splitRefIdx[4];
     uint64_t* cacheCost;
 
@@ -140,7 +139,7 @@
 
     /* measure merge and skip */
     void checkMerge2Nx2N_rd0_4(Mode& skip, Mode& merge, const CUGeom& cuGeom);
-    void checkMerge2Nx2N_rd5_6(Mode& skip, Mode& merge, const CUGeom& cuGeom, bool isShareMergeCand);
+    void checkMerge2Nx2N_rd5_6(Mode& skip, Mode& merge, const CUGeom& cuGeom);
 
     /* measure inter options */
     void checkInter_rd0_4(Mode& interMode, const CUGeom& cuGeom, PartSize partSize, uint32_t refmask[2]);
diff -r 07eb2d73102b -r 969e64f43b96 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Tue Feb 09 18:55:54 2016 +0530
+++ b/source/encoder/encoder.cpp	Mon Feb 08 12:07:27 2016 +0530
@@ -1885,7 +1885,6 @@
         CHECKED_MALLOC_ZERO(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);
         CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);
         CHECKED_MALLOC(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);
-        CHECKED_MALLOC_ZERO(interData->bestMergeCand, uint32_t, analysis->numCUsInFrame * CUGeom::MAX_GEOMS);
         CHECKED_MALLOC_ZERO(interData->mv, MV, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);
         CHECKED_MALLOC_ZERO(interData->wt, WeightParam, 3 * numDir);
         analysis->interData = interData;
@@ -1912,7 +1911,6 @@
         X265_FREE(((analysis_inter_data*)analysis->interData)->ref);
         X265_FREE(((analysis_inter_data*)analysis->interData)->depth);
         X265_FREE(((analysis_inter_data*)analysis->interData)->modes);
-        X265_FREE(((analysis_inter_data*)analysis->interData)->bestMergeCand);
         X265_FREE(((analysis_inter_data*)analysis->interData)->mv);
         X265_FREE(((analysis_inter_data*)analysis->interData)->wt);
         X265_FREE(analysis->interData);
@@ -2021,7 +2019,6 @@
         
         int numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;
         X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);      
-        X265_FREAD(((analysis_inter_data *)analysis->interData)->bestMergeCand, sizeof(uint32_t), analysis->numCUsInFrame * CUGeom::MAX_GEOMS, m_analysisFile);
         X265_FREAD(((analysis_inter_data *)analysis->interData)->mv, sizeof(MV), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
         X265_FREAD(((analysis_inter_data *)analysis->interData)->wt, sizeof(WeightParam), 3 * numDir, m_analysisFile);
         consumedBytes += frameRecordSize;
@@ -2106,7 +2103,6 @@
         int numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;
         analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;
         analysis->frameRecordSize += depthBytes * 2;
-        analysis->frameRecordSize += sizeof(uint32_t) * analysis->numCUsInFrame * CUGeom::MAX_GEOMS;
         analysis->frameRecordSize += sizeof(MV) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;
         analysis->frameRecordSize += sizeof(WeightParam) * 3 * numDir;
     }
@@ -2132,7 +2128,6 @@
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
-        X265_FWRITE(((analysis_inter_data*)analysis->interData)->bestMergeCand, sizeof(uint32_t), analysis->numCUsInFrame * CUGeom::MAX_GEOMS, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->mv, sizeof(MV), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->wt, sizeof(WeightParam), 3 * numDir, m_analysisFile);
     }


More information about the x265-devel mailing list