[x265] [PATCH] Included merge mode for FMD = ON. Changed the xComputeCostMerge2Nx2N() to calculate the SATD cost and decide the mode based on that

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Wed Jun 26 07:09:35 CEST 2013


# HG changeset patch
# User sumalatha
# Date 1372161004 -19800
# Node ID 6340ea9b1119e28fe467e895ccc1c02b035c9b8b
# Parent  e11febad302c5b4c1e183b8cf945b25a00e9b726
Included merge mode for FMD = ON. Changed the xComputeCostMerge2Nx2N() to calculate the SATD cost and decide the mode based on that.

diff -r e11febad302c -r 6340ea9b1119 source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Tue Jun 25 16:47:14 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncCu.h	Tue Jun 25 17:20:04 2013 +0530
@@ -149,7 +149,7 @@
     Void  xCheckBestMode(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth);
     
     Void  xCheckRDCostMerge2Nx2N(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode);
-    Void  xComputeCostMerge2Nx2N(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU,  Bool *earlyDetectionSkipMode);
+    Void  xComputeCostMerge2Nx2N(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU);
     Void  xComputeCostIntrainInter(TComDataCU*& rpcTempCU, PartSize eSize,UInt index);
     Void  xCheckRDCostInter(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG = false);
     Void  xComputeCostInter(TComDataCU*& rpcTempCU, PartSize ePartSize, UInt Index, Bool bUseMRG = false);
diff -r e11febad302c -r 6340ea9b1119 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Tue Jun 25 16:47:14 2013 +0530
+++ b/source/encoder/compress.cpp	Tue Jun 25 17:20:04 2013 +0530
@@ -23,7 +23,7 @@
 
 #include "TLibEncoder/TEncCu.h"
 #include <math.h>
-
+#include <common.h>
 #if _MSC_VER
 #pragma warning (disable: 4244)
 #pragma warning (disable: 4018)
@@ -87,7 +87,7 @@
  * \param rpcTempCU
  * \returns Void
  */
-Void TEncCu::xComputeCostMerge2Nx2N(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode)
+Void TEncCu::xComputeCostMerge2Nx2N(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU)
 {
     assert(rpcTempCU->getSlice()->getSliceType() != I_SLICE);
     TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
@@ -114,7 +114,6 @@
         mergeCandBuffer[ui] = 0;
     }
 
-    Bool bestIsSkip = false;
 
     UInt iteration;
     if (rpcTempCU->isLosslessCoded(0))
@@ -126,14 +125,8 @@
         iteration = 2;
     }
 
-    for (UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual)
-    {
         for (UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand)
         {
-            if (!(uiNoResidual == 1 && mergeCandBuffer[uiMergeCand] == 1))
-            {
-                if (!(bestIsSkip && uiNoResidual == 0))
-                {
                     // set MC parameters
                     rpcTempCU->setPredModeSubParts(MODE_INTER, 0, uhDepth); // interprets depth relative to LCU level
                     rpcTempCU->setCUTransquantBypassSubParts(m_pcEncCfg->getCUTransquantBypassFlagValue(),     0, uhDepth);
@@ -146,28 +139,19 @@
 
                     // do MC
                     m_pcPredSearch->motionCompensation(rpcTempCU, m_ppcPredYuvMode[4][uhDepth]);
-
+                  
                     /*Todo: Fix the satd cost estimates. Why is merge being chosen in high motion areas: estimated distortion is too low?*/
                     
-                    me_merge.setSourcePU(0,rpcTempCU->getWidth(0),rpcTempCU->getHeight(0));
-                    rpcTempCU->getTotalDistortion() = me_merge.bufSATD((pixel*)m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), 
-                                                m_ppcPredYuvTemp[uhDepth]->getStride());
-                    rpcTempCU->getTotalCost() = rpcTempCU->getTotalDistortion(); 
-                    x265_emms();
-                             
-
-                    if (uiNoResidual == 0)
-                    {
-                        if (rpcTempCU->getQtRootCbf(0) == 0)
-                        {
-                            mergeCandBuffer[uiMergeCand] = 1;
-                        }
-                    }
-
-                    rpcTempCU->setSkipFlagSubParts(rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth);
+                    m_pcPredSearch->encodeResAndCalcRdInterCU(rpcTempCU,
+                                                              m_ppcOrigYuv[uhDepth],
+                                                              m_ppcPredYuvMode[4][uhDepth],
+                                                              m_ppcResiYuvTemp[uhDepth],
+                                                              m_ppcResiYuvBest[uhDepth],
+                                                              m_ppcRecoYuvTemp[uhDepth],
+                                                              (true));      
+                  
                     Int orgQP = rpcTempCU->getQP(0);
 
-                    //xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
                     if (rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost())
                     {
                         TComDataCU* tmp = rpcTempCU;
@@ -181,45 +165,19 @@
                     }
 
                     rpcTempCU->initEstData(uhDepth, orgQP);
+                }
+            
+        
+     
+   
+                    me_merge.setSourcePU(0,rpcBestCU->getWidth(0),rpcBestCU->getHeight(0));
+                    rpcBestCU->getTotalDistortion() = me_merge.bufSATD((pixel*) m_ppcPredYuvMode[3][uhDepth]->getLumaAddr(), 
+                                                 m_ppcPredYuvMode[3][uhDepth]->getStride());
+                    rpcBestCU->getTotalCost() = rpcBestCU->getTotalDistortion(); 
+                    x265_emms();
 
-                    if (m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip)
-                    {
-                        bestIsSkip = rpcTempCU->getQtRootCbf(0) == 0;
-                    }
-                }
-            }
-        }
+     
 
-        if (uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection())
-        {
-            if (rpcTempCU->getQtRootCbf(0) == 0)
-            {
-                if (rpcTempCU->getMergeFlag(0))
-                {
-                    *earlyDetectionSkipMode = true;
-                }
-                else
-                {
-                    Int absoulte_MV = 0;
-                    for (UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++)
-                    {
-                        if (rpcTempCU->getSlice()->getNumRefIdx(RefPicList(uiRefListIdx)) > 0)
-                        {
-                            TComCUMvField* pcCUMvField = rpcTempCU->getCUMvField(RefPicList(uiRefListIdx));
-                            Int iHor = abs(pcCUMvField->getMvd(0).x);
-                            Int iVer = abs(pcCUMvField->getMvd(0).y);
-                            absoulte_MV += iHor + iVer;
-                        }
-                    }
-
-                    if (absoulte_MV == 0)
-                    {
-                        *earlyDetectionSkipMode = true;
-                    }
-                }
-            }
-        }
-    }
 }
 
 Void TEncCu::xComputeCostInter(TComDataCU*& rpcTempCU, PartSize ePartSize, UInt Index, Bool bUseMRG)
@@ -301,9 +259,9 @@
         }
 
         /*Compute  Merge Cost  */
-#if 0
-        Bool earlyDetectionSkipMode = false;
-        xComputeCostMerge2Nx2N(m_MergeBestCU[uiDepth], m_MergeCU[uiDepth], &earlyDetectionSkipMode);
+#if 1
+       
+        xComputeCostMerge2Nx2N(m_MergeBestCU[uiDepth], m_MergeCU[uiDepth]);
         rpcBestCU = m_MergeBestCU[uiDepth];
         YuvTemp = m_ppcPredYuvMode[3][uiDepth];
         m_ppcPredYuvMode[3][uiDepth] = m_ppcPredYuvBest[uiDepth];
@@ -328,12 +286,13 @@
         }
             
         /*Choose best mode; initialise rpcBestCU to 2Nx2N*/
-                
+        if(m_InterCU_2Nx2N[uiDepth]->getTotalCost()<rpcBestCU->getTotalCost()) {
         rpcBestCU = m_InterCU_2Nx2N[uiDepth];
 
         YuvTemp = m_ppcPredYuvMode[0][uiDepth];
         m_ppcPredYuvMode[0][uiDepth] = m_ppcPredYuvBest[uiDepth];
         m_ppcPredYuvBest[uiDepth] = YuvTemp;
+        }
         
         if (m_InterCU_Nx2N[uiDepth]->getTotalCost() < rpcBestCU->getTotalCost())
         {
@@ -353,6 +312,7 @@
         }
 
         /* Perform encode residual for the best mode chosen only*/
+        
         m_pcPredSearch->encodeResAndCalcRdInterCU(rpcBestCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvBest[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcResiYuvBest[uiDepth], m_ppcRecoYuvBest[uiDepth], false);
 
         /* Disable recursive analysis for whole CUs temporarily*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: June_25_sumalatha.patch
Type: text/x-patch
Size: 8458 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130626/f7724ff5/attachment-0001.bin>


More information about the x265-devel mailing list